Fix createContainerInLocation return value.

Previously it always returned true.  Addresses issue 629.
This commit is contained in:
Andrew Gaul 2011-10-10 17:53:56 -07:00
parent 868b9ba93e
commit 48ee511275
2 changed files with 24 additions and 5 deletions

View File

@ -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)) {
getContainerToBlobs().put(name, new ConcurrentHashMap<String, Blob>()); return immediateFuture(Boolean.FALSE);
getContainerToLocation().put(name, location != null ? location : defaultLocation.get());
} }
return immediateFuture(getContainerToBlobs().containsKey(name)); getContainerToBlobs().put(name, new ConcurrentHashMap<String, Blob>());
getContainerToLocation().put(name, location != null ? location : defaultLocation.get());
return immediateFuture(Boolean.TRUE);
} }
/** /**

View File

@ -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);
}
}