@Test(groups = { "integration", "live" }) public void deleteContainerIfEmptyWithContents() throws InterruptedException { String containerName = getContainerName(); try { addBlobToContainer(containerName, "test"); awaitConsistency(); assertFalse(view.getBlobStore().deleteContainerIfEmpty(containerName)); awaitConsistency(); assertTrue(view.getBlobStore().containerExists(containerName)); } finally { recycleContainerAndAddToPool(containerName); } }
@Test(groups = { "integration", "live" }) public void testListContainer() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { add15UnderRoot(containerName); awaitConsistency(); Set<? extends StorageMetadata> container = view.getBlobStore().list(containerName); assertEquals(container.size(), 15); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void deleteContainerWithoutContents() throws InterruptedException { final String containerName = getContainerName(); try { view.getBlobStore().deleteContainer(containerName); awaitConsistency(); assertNotExists(containerName); } finally { // this container is now deleted, so we can't reuse it directly recycleContainerAndAddToPool(containerName); } }
@Test(groups = { "integration", "live" }) public void deleteContainerIfEmptyWithoutContents() throws InterruptedException { final String containerName = getContainerName(); try { assertTrue(view.getBlobStore().deleteContainerIfEmpty(containerName)); awaitConsistency(); assertNotExists(containerName); // verify that true is returned even if the container does not exist assertTrue(view.getBlobStore().deleteContainerIfEmpty(containerName)); } finally { // this container is now deleted, so we can't reuse it directly recycleContainerAndAddToPool(containerName); } }
@Test(groups = { "integration", "live" }) public void deleteContainerWithContents() throws InterruptedException { String containerName = getContainerName(); try { addBlobToContainer(containerName, "test"); view.getBlobStore().deleteContainer(containerName); awaitConsistency(); assertNotExists(containerName); } finally { recycleContainerAndAddToPool(containerName); } }
@Test(groups = { "integration", "live" }) public void testListRootUsesDelimiter() throws InterruptedException { String containerName = getContainerName(); try { String prefix = "rootdelimiter"; addTenObjectsUnderPrefix(containerName, prefix); add15UnderRoot(containerName); awaitConsistency(); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName); assert container.getNextMarker() == null; assertEquals(container.size(), 16); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void testWithDetails() throws InterruptedException, IOException { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); awaitConsistency(); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1).withDetails()); BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); } finally { returnContainer(containerName); } }
@Test public void testListMarkerAfterLastKey() throws Exception { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); validateContent(containerName, key); awaitConsistency(); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, afterMarker(key)); assertThat(container).isEmpty(); } finally { returnContainer(containerName); } }
@Test public void testListContainerWithZeroMaxResults() throws Exception { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); awaitConsistency(); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(0)); assertThat(container).isEmpty(); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void testListContainerPrefix() throws InterruptedException { String containerName = getContainerName(); try { String prefix = "containerprefix"; addTenObjectsUnderPrefix(containerName, prefix); add15UnderRoot(containerName); awaitConsistency(); PageSet<? extends StorageMetadata> container = view.getBlobStore().list( containerName, new ListContainerOptions().prefix(prefix + "/").delimiter("/")); assert container.getNextMarker() == null; assertEquals(container.size(), 10); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) // TODO: the test name does not describe its behavior public void testPutTwiceIsOkAndDoesntOverwrite() throws InterruptedException { String containerName = getContainerName(); try { view.getBlobStore().createContainerInLocation(null, containerName); Blob blob = view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build(); view.getBlobStore().putBlob(containerName, blob); view.getBlobStore().createContainerInLocation(null, containerName); awaitConsistency(); assertEquals(view.getBlobStore().countBlobs(containerName), 1); } finally { returnContainer(containerName); } }
awaitConsistency(); view.getBlobStore().createDirectory(containerName, directory + "/" + directory); awaitConsistency(); awaitConsistency(); awaitConsistency();