@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 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 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).calculateMD5().build()); 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); } }