Merge pull request #106 from andrewgaul/issue-629

Issue 629: Fix createContainerInLocation return value.
This commit is contained in:
Adrian Cole 2011-10-11 11:34:12 -07:00
commit dbc84d82ed
2 changed files with 24 additions and 5 deletions

View File

@ -360,11 +360,12 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
*/
@Override
public ListenableFuture<Boolean> createContainerInLocation(final Location location, final String name) {
if (!getContainerToBlobs().containsKey(name)) {
getContainerToBlobs().put(name, new ConcurrentHashMap<String, Blob>());
getContainerToLocation().put(name, location != null ? location : defaultLocation.get());
if (getContainerToBlobs().containsKey(name)) {
return immediateFuture(Boolean.FALSE);
}
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 org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
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 org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.jclouds.domain.Location;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@ -65,4 +69,18 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
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);
}
}