mirror of https://github.com/apache/jclouds.git
Fix createContainerInLocation return value.
Previously it always returned true. Addresses issue 629.
This commit is contained in:
parent
868b9ba93e
commit
48ee511275
|
@ -360,11 +360,12 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Boolean> createContainerInLocation(final Location location, final String name) {
|
public ListenableFuture<Boolean> createContainerInLocation(final Location location, final String name) {
|
||||||
if (!getContainerToBlobs().containsKey(name)) {
|
if (getContainerToBlobs().containsKey(name)) {
|
||||||
|
return immediateFuture(Boolean.FALSE);
|
||||||
|
}
|
||||||
getContainerToBlobs().put(name, new ConcurrentHashMap<String, Blob>());
|
getContainerToBlobs().put(name, new ConcurrentHashMap<String, Blob>());
|
||||||
getContainerToLocation().put(name, location != null ? location : defaultLocation.get());
|
getContainerToLocation().put(name, location != null ? location : defaultLocation.get());
|
||||||
}
|
return immediateFuture(Boolean.TRUE);
|
||||||
return immediateFuture(getContainerToBlobs().containsKey(name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,14 +21,18 @@ package org.jclouds.blobstore.integration;
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
|
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.blobstore.BlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.domain.PageSet;
|
import org.jclouds.blobstore.domain.PageSet;
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -65,4 +69,18 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = { "integration", "live" })
|
||||||
|
public void testDuplicateCreateContainer() {
|
||||||
|
BlobStore blobStore = context.getBlobStore();
|
||||||
|
Location location = null;
|
||||||
|
String container = "container";
|
||||||
|
boolean created;
|
||||||
|
|
||||||
|
created = blobStore.createContainerInLocation(location, container);
|
||||||
|
assertTrue(created);
|
||||||
|
|
||||||
|
created = blobStore.createContainerInLocation(location, container);
|
||||||
|
assertFalse(created);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue