You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2015/01/22 22:26:19 UTC
[3/3] jclouds git commit: Add more tests for delimiter, prefixes,
and marker
Add more tests for delimiter, prefixes, and marker
s3-tests uncovered interactions between these options which existing
tests do not exercise.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/da3e7463
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/da3e7463
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/da3e7463
Branch: refs/heads/master
Commit: da3e7463fd90932ff40f0ec2cad5404722b149fa
Parents: 46f4a4e
Author: Andrew Gaul <ga...@apache.org>
Authored: Tue Jan 20 14:09:40 2015 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Thu Jan 22 11:37:46 2015 -0800
----------------------------------------------------------------------
.../internal/BaseContainerIntegrationTest.java | 60 ++++++++++++++++++++
1 file changed, 60 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/da3e7463/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
index 6e3332e..2aa3478 100644
--- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
+++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
@@ -29,6 +29,7 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.io.IOException;
+import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -317,6 +318,65 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
}
@Test(groups = { "integration", "live" })
+ public void testDelimiter() throws Exception {
+ String containerName = getContainerName();
+ try {
+ for (String blobName : new String[] { "asdf", "boo/bar", "boo/baz/xyzzy", "cquux/thud", "cquux/bla" }) {
+ Blob blob = view.getBlobStore().blobBuilder(blobName).payload(TEST_STRING).build();
+ addBlobToContainer(containerName, blob);
+ }
+
+ // test root directory without marker
+ PageSet<? extends StorageMetadata> pageSet = view.getBlobStore().list(containerName);
+ assertThat(pageSet).hasSize(3);
+ assertThat(pageSet.getNextMarker()).isNull();
+
+ // list root directory with marker
+ ListContainerOptions options = new ListContainerOptions().maxResults(1);
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(1);
+ assertThat(pageSet.iterator().next().getName()).isEqualTo("asdf");
+ assertThat(pageSet.getNextMarker()).isEqualTo("asdf");
+
+ options.afterMarker(pageSet.getNextMarker());
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(1);
+ assertThat(pageSet.iterator().next().getName()).isEqualTo("boo");
+ assertThat(pageSet.getNextMarker()).isEqualTo("boo/");
+
+ options.afterMarker(pageSet.getNextMarker());
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(1);
+ assertThat(pageSet.iterator().next().getName()).isEqualTo("cquux");
+ assertThat(pageSet.getNextMarker()).isNull();
+
+ // list child directory with marker
+ options = new ListContainerOptions().inDirectory("boo").maxResults(1);
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(1);
+ assertThat(pageSet.iterator().next().getName()).isEqualTo("boo/bar");
+ assertThat(pageSet.getNextMarker()).isEqualTo("boo/bar");
+
+ options.afterMarker(pageSet.getNextMarker());
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(1);
+ assertThat(pageSet.iterator().next().getName()).isEqualTo("boo/baz");
+ assertThat(pageSet.getNextMarker()).isNull();
+
+ // list child directory without marker
+ options = new ListContainerOptions().inDirectory("boo").maxResults(2);
+ pageSet = view.getBlobStore().list(containerName, options);
+ assertThat(pageSet).hasSize(2);
+ Iterator<? extends StorageMetadata> it = pageSet.iterator();
+ assertThat(it.next().getName()).isEqualTo("boo/bar");
+ assertThat(it.next().getName()).isEqualTo("boo/baz");
+ assertThat(pageSet.getNextMarker()).isNull();
+ } finally {
+ returnContainer(containerName);
+ }
+ }
+
+ @Test(groups = { "integration", "live" })
public void containerExists() throws InterruptedException {
String containerName = getContainerName();
try {