@Test(groups = { "integration", "live" }) public void blobNotFound() throws InterruptedException { String container = getContainerName(); String name = "test"; try { assert !view.getBlobStore().blobExists(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void deleteObjectNotFound() throws InterruptedException { String container = getContainerName(); String name = "test"; try { view.getBlobStore().removeBlob(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void deleteObjectNotFound() throws InterruptedException { String container = getContainerName(); String name = "test"; try { view.getBlobStore().removeBlob(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void blobNotFound() throws InterruptedException { String container = getContainerName(); String name = "test"; try { assert !view.getBlobStore().blobExists(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }, expectedExceptions = {KeyNotFoundException.class}) public void testCopy404BlobFail() throws Exception { BlobStore blobStore = view.getBlobStore(); String container = getContainerName(); try { blobStore.copyBlob(container, "blob", container, "blob2", CopyOptions.NONE); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetRangeOutOfRange() throws InterruptedException, IOException { String container = getContainerName(); try { String name = "apples"; addObjectAndValidateContent(container, name); try { view.getBlobStore().getBlob(container, name, range(TEST_STRING.length(), TEST_STRING.length() + 1)); failBecauseExceptionWasNotThrown(HttpResponseException.class); } catch (HttpResponseException e) { assertThat(e.getResponse().getStatusCode()).isEqualTo(416); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }, dataProvider = "delete") public void deleteObject(String name) throws InterruptedException { String container = getContainerName(); try { addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN); view.getBlobStore().removeBlob(container, name); assertContainerEmptyDeleting(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }, expectedExceptions = {KeyNotFoundException.class}) public void testCopy404BlobMetaFail() throws Exception { BlobStore blobStore = view.getBlobStore(); String container = getContainerName(); try { blobStore.copyBlob(container, "blob", container, "blob2", CopyOptions.builder().userMetadata(ImmutableMap.of("x", "1")).build()); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testCreateBlobWithExpiry() throws InterruptedException { String container = getContainerName(); BlobStore blobStore = view.getBlobStore(); try { final String blobName = "hello"; final Date expires = new Date((System.currentTimeMillis() / 1000) * 1000 + 60 * 1000); blobStore.putBlob(container, blobStore.blobBuilder(blobName).payload(TEST_STRING).expires(expires).build()); assertConsistencyAwareBlobExpiryMetadata(container, blobName, expires); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testCreateBlobWithExpiry() throws InterruptedException { String container = getContainerName(); BlobStore blobStore = view.getBlobStore(); try { final String blobName = "hello"; final Date expires = new Date((System.currentTimeMillis() / 1000) * 1000 + 60 * 1000); blobStore.putBlob(container, blobStore.blobBuilder(blobName).payload(TEST_STRING).expires(expires).build()); assertConsistencyAwareBlobExpiryMetadata(container, blobName, expires); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetTwoRanges() throws InterruptedException, IOException { String container = getContainerName(); try { String name = "apples"; addObjectAndValidateContent(container, name); Blob blob = view.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length())); validateMetadata(blob.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob), TEST_STRING); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetRange() throws InterruptedException, IOException { String container = getContainerName(); try { String name = "apples"; addObjectAndValidateContent(container, name); Blob blob1 = view.getBlobStore().getBlob(container, name, range(0, 5)); validateMetadata(blob1.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob1), TEST_STRING.substring(0, 6)); Blob blob2 = view.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length())); validateMetadata(blob2.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob2), TEST_STRING.substring(6, TEST_STRING.length())); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetTwoRanges() throws InterruptedException, IOException { String container = getContainerName(); try { String name = "apples"; addObjectAndValidateContent(container, name); Blob blob = view.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length())); validateMetadata(blob.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob), TEST_STRING); } finally { returnContainer(container); } }
private void putBlobWithMd5(byte[] payload, HashCode contentMD5) throws InterruptedException, IOException { String container = getContainerName(); BlobStore blobStore = view.getBlobStore(); try { String blobName = "putBlobWithMd5-" + new Random().nextLong(); Blob blob = blobStore .blobBuilder(blobName) .payload(payload) .contentMD5(contentMD5) .build(); blobStore.putBlob(container, blob); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }, dataProvider = "delete") public void deleteObject(String name) throws InterruptedException { String container = getContainerName(); try { addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN); awaitConsistency(); view.getBlobStore().removeBlob(container, name); awaitConsistency(); assertContainerEmptyDeleting(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }, dataProvider = "delete") public void deleteMultipleObjects(String name) throws InterruptedException { String name2 = name + "2"; String container = getContainerName(); try { addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN); addBlobToContainer(container, name2, name2, MediaType.TEXT_PLAIN); awaitConsistency(); view.getBlobStore().removeBlobs(container, ImmutableSet.of(name, name2)); awaitConsistency(); assertContainerEmptyDeleting(container, name); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfNoneMatch() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; String goodETag = addObjectAndValidateContent(container, name); view.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee")); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag)); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfNoneMatch() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; String goodETag = addObjectAndValidateContent(container, name); view.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee")); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag)); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testMultipartUploadNoPartsAbort() throws Exception { BlobStore blobStore = view.getBlobStore(); String container = getContainerName(); try { String name = "blob-name"; Blob blob = blobStore.blobBuilder(name).build(); MultipartUpload mpu = blobStore.initiateMultipartUpload(container, blob.getMetadata(), new PutOptions()); List<MultipartPart> parts = blobStore.listMultipartUpload(mpu); assertThat(parts).isEqualTo(ImmutableList.of()); blobStore.abortMultipartUpload(mpu); blob = blobStore.getBlob(container, name); assertThat(blob).isNull(); } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfMatch() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; String goodETag = addObjectAndValidateContent(container, name); view.getBlobStore().getBlob(container, name, ifETagMatches(goodETag)); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifETagMatches("powerfrisbee")); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 412); } } finally { returnContainer(container); } }