private String addObjectAndValidateContent(String sourcecontainer, String sourceKey) throws InterruptedException { String eTag = addBlobToContainer(sourcecontainer, sourceKey); validateContent(sourcecontainer, sourceKey); return eTag; }
private String addObjectAndValidateContent(String sourcecontainer, String sourceKey) throws InterruptedException { String eTag = addBlobToContainer(sourcecontainer, sourceKey); validateContent(sourcecontainer, sourceKey); awaitConsistency(); return eTag; }
@Test(groups = { "integration", "live" }) public void testGetIfUnmodifiedSince() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; Date before = new Date(System.currentTimeMillis() - 1000); addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 1000); view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after)); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 412); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfModifiedSince() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; Date before = new Date(System.currentTimeMillis() - 1000); // first create the blob addObjectAndValidateContent(container, name); // now, modify it addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 1000); view.getBlobStore().getBlob(container, name, ifModifiedSince(before)); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifModifiedSince(after)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfUnmodifiedSince() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; Date before = new Date(System.currentTimeMillis() - 10000); addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 10000); awaitConsistency(); view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after)); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 412); } } finally { returnContainer(container); } }
@Test(groups = { "integration", "live" }) public void testGetIfModifiedSince() throws InterruptedException { String container = getContainerName(); try { String name = "apples"; Date before = new Date(System.currentTimeMillis() - 1000); // first create the blob addObjectAndValidateContent(container, name); // now, modify it addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 1000); view.getBlobStore().getBlob(container, name, ifModifiedSince(before)); validateContent(container, name); try { view.getBlobStore().getBlob(container, name, ifModifiedSince(after)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); } } 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); } }
@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); } }
@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); } }
Blob newObject = validateContent(container, name);
@Test(groups = { "integration", "live" }) public void testMetadata() throws InterruptedException, IOException { String name = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the // providers. Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build(); String container = getContainerName(); try { assertNull(view.getBlobStore().blobMetadata(container, "powderpuff")); addBlobToContainer(container, blob); Blob newObject = validateContent(container, name); BlobMetadata metadata = newObject.getMetadata(); validateMetadata(metadata); validateMetadata(metadata, container, name); validateMetadata(view.getBlobStore().blobMetadata(container, name)); // write 2 items with the same name to ensure that provider doesn't // accept dupes blob.getMetadata().getUserMetadata().put("Adrian", "wonderpuff"); blob.getMetadata().getUserMetadata().put("Adrian", "powderpuff"); addBlobToContainer(container, blob); validateMetadata(view.getBlobStore().blobMetadata(container, name)); } finally { returnContainer(container); } }