@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 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 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 testSetContainerAccess() throws Exception { BlobStore blobStore = view.getBlobStore(); String containerName = getContainerName(); try { assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PRIVATE); blobStore.setContainerAccess(containerName, ContainerAccess.PUBLIC_READ); assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PUBLIC_READ); String blobName = "blob"; blobStore.putBlob(containerName, blobStore.blobBuilder(blobName).payload("").build()); // test that blob is anonymously readable HttpRequest request = view.getSigner().signGetBlob(containerName, blobName).toBuilder() .replaceQueryParams(ImmutableMap.<String, String>of()).build(); HttpResponse response = view.utils().http().invoke(request); assertThat(response.getStatusCode()).isEqualTo(200); blobStore.setContainerAccess(containerName, ContainerAccess.PRIVATE); assertThat(blobStore.getContainerAccess(containerName)).isEqualTo(ContainerAccess.PRIVATE); } finally { recycleContainerAndAddToPool(containerName); } }