From b62a6309bec7c6b3a04feb00441cea3cc9b34ea9 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 30 Jan 2011 02:32:00 -0800 Subject: [PATCH] workaround to walrus not having NextMarker in bucket listing --- .../internal/ListBucketResponseImpl.java | 10 ++++------ .../org/jclouds/s3/xml/ListBucketHandler.java | 5 +++-- ...rseObjectInfoListFromJsonResponseTest.java | 2 +- .../domain/internal/PageSetImpl.java | 4 ++-- .../BaseContainerIntegrationTest.java | 19 ++++++++++++++++++- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/internal/ListBucketResponseImpl.java b/apis/s3/src/main/java/org/jclouds/s3/domain/internal/ListBucketResponseImpl.java index fc301db1f0..3cac79fc34 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/internal/ListBucketResponseImpl.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/internal/ListBucketResponseImpl.java @@ -19,7 +19,7 @@ package org.jclouds.s3.domain.internal; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.jclouds.s3.domain.ListBucketResponse; @@ -32,8 +32,7 @@ import com.google.common.collect.Iterables; * @author Adrian Cole * */ -public class ListBucketResponseImpl extends HashSet implements - ListBucketResponse { +public class ListBucketResponseImpl extends LinkedHashSet implements ListBucketResponse { /** The serialVersionUID */ private static final long serialVersionUID = -4475709781001190244L; protected final String name; @@ -45,9 +44,8 @@ public class ListBucketResponseImpl extends HashSet implements protected final Set commonPrefixes; protected final boolean truncated; - public ListBucketResponseImpl(String name, Iterable contents, String prefix, - String marker, String nextMarker, int maxKeys, String delimiter, boolean isTruncated, - Set commonPrefixes) { + public ListBucketResponseImpl(String name, Iterable contents, String prefix, String marker, + String nextMarker, int maxKeys, String delimiter, boolean isTruncated, Set commonPrefixes) { Iterables.addAll(this, contents); this.name = name; this.prefix = prefix; diff --git a/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java b/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java index 5979fa392c..0c3d322868 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java +++ b/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java @@ -71,8 +71,9 @@ public class ListBucketHandler extends ParseSax.HandlerWithResult expects = Sets.newHashSet(); + Set expects = Sets.newLinkedHashSet(); ObjectInfoImpl one = i.getInstance(ObjectInfoImpl.class); one.name = "test_obj_1"; one.hash = CryptoStreams.hex("4281c348eaf83e70ddce0e07221c3d28"); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/PageSetImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/PageSetImpl.java index 1297a00715..413b62bed5 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/PageSetImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/PageSetImpl.java @@ -19,7 +19,7 @@ package org.jclouds.blobstore.domain.internal; -import java.util.HashSet; +import java.util.LinkedHashSet; import javax.annotation.Nullable; @@ -27,7 +27,7 @@ import org.jclouds.blobstore.domain.PageSet; import com.google.common.collect.Iterables; -public class PageSetImpl extends HashSet implements PageSet { +public class PageSetImpl extends LinkedHashSet implements PageSet { /** The serialVersionUID */ private static final long serialVersionUID = -7133632087734650835L; 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 b4d1321ceb..4d0dcfccc8 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -93,7 +93,8 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); - assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata().getContentType(); + assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() + .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), new Long(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); @@ -123,6 +124,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String containerName = getContainerName(); try { addAlphabetUnderRoot(containerName); + PageSet container = context.getBlobStore().list(containerName, maxResults(1)); assert container.getNextMarker() != null; @@ -255,6 +257,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String containerName = getContainerName(); try { addAlphabetUnderRoot(containerName); + PageSet container = context.getBlobStore().list(containerName, maxResults(5)); assertEquals(container.size(), 5); assert container.getNextMarker() != null; @@ -330,6 +333,20 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { blob.setPayload(letter + "content"); context.getBlobStore().putBlob(containerName, blob); } + assertContainerSize(containerName, 26); + + } + + protected void assertContainerSize(final String containerName, final int size) throws InterruptedException { + assertConsistencyAware(new Runnable() { + public void run() { + try { + assertEquals(context.getBlobStore().countBlobs(containerName), size); + } catch (Exception e) { + propagateIfPossible(e); + } + } + }); } protected void add15UnderRoot(String containerName) throws InterruptedException {