From a1ca5773c7c87033036218a67f9e62233a7d6006 Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Sat, 3 Oct 2009 19:53:27 +0000 Subject: [PATCH] Issue 108: changed from List to SortedSet git-svn-id: http://jclouds.googlecode.com/svn/trunk@1941 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../java/org/jclouds/aws/s3/S3BlobStore.java | 4 +-- .../s3/domain/ArrayListBucketResponse.java | 2 +- .../jclouds/aws/s3/domain/BucketMetadata.java | 13 ++++--- .../aws/s3/domain/ListBucketResponse.java | 2 +- .../aws/s3/config/S3ContextModuleTest.java | 35 +++++++++--------- .../integration/S3ServiceIntegrationTest.java | 6 ++-- .../aws/s3/jets3t/JCloudsS3Service.java | 3 +- .../java/org/jclouds/aws/s3/jets3t/Util.java | 3 +- .../s3/jets3t/JCloudsS3ServiceLiveTest.java | 4 +-- .../org/jclouds/aws/s3/samples/MainApp.java | 17 ++++++--- .../GetAllBucketsController.java | 11 +++--- .../googleappengine/JCloudsServlet.java | 15 +++++--- .../googleappengine/domain/BucketResult.java | 7 +++- .../azure/storage/blob/AzureBlobStore.java | 8 ++--- .../blob/domain/ArrayListBlobsResponse.java | 4 +-- .../blob/domain/ListBlobsResponse.java | 4 +-- .../AccountNameEnumerationResultsHandler.java | 10 +++--- .../storage/blob/AzureBlobStoreLiveTest.java | 16 ++++----- .../blob/internal/StubAzureBlobStore.java | 4 +-- ...ountNameEnumerationResultsHandlerTest.java | 12 +++---- ...inerNameEnumerationResultsHandlerTest.java | 4 +-- ...BoundedList.java => BoundedSortedSet.java} | 2 +- ...ayBoundedList.java => BoundedTreeSet.java} | 8 ++--- .../storage/queue/AzureQueueConnection.java | 4 +-- .../AccountNameEnumerationResultsHandler.java | 10 +++--- .../queue/AzureQueueConnectionLiveTest.java | 8 ++--- ...ountNameEnumerationResultsHandlerTest.java | 12 +++---- .../java/org/jclouds/blobstore/BlobStore.java | 6 ++-- .../org/jclouds/blobstore/ListableMap.java | 6 ++-- .../org/jclouds/blobstore/domain/Blob.java | 6 +++- .../blobstore/domain/ContainerMetadata.java | 6 +++- .../internal/BaseBlobIntegrationTest.java | 4 +-- .../BaseContainerIntegrationTest.java | 5 +-- .../internal/BaseServiceIntegrationTest.java | 4 +-- .../integration/internal/StubBlobStore.java | 12 +++---- ...BoundedList.java => BoundedSortedSet.java} | 4 +-- ...ayBoundedList.java => BoundedTreeSet.java} | 6 ++-- .../org/jclouds/mezeo/pcs2/PCSBlobStore.java | 6 ++-- .../pcs2/functions/FindIdInContainerList.java | 6 ++-- .../pcs2/functions/FindIdInFileList.java | 6 ++-- .../mezeo/pcs2/PCSBlobStoreLiveTest.java | 4 +-- .../jclouds/mezeo/pcs2/PCSBlobStoreTest.java | 23 ++++++------ .../pcs2/config/PCSContextModuleTest.java | 36 +++++++++---------- .../functions/FindIdInContainerListTest.java | 4 +-- .../functions/FindIdInFileListIdTest.java | 4 +-- .../cloudfiles/CloudFilesBlobStore.java | 10 +++--- .../CloudFilesBlobStoreLiveTest.java | 16 ++++----- .../internal/StubCloudFilesBlobStore.java | 8 ++--- 48 files changed, 217 insertions(+), 193 deletions(-) rename azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/{BoundedList.java => BoundedSortedSet.java} (93%) rename azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/{ArrayBoundedList.java => BoundedTreeSet.java} (89%) rename core/src/main/java/org/jclouds/rest/{BoundedList.java => BoundedSortedSet.java} (93%) rename core/src/main/java/org/jclouds/rest/{ArrayBoundedList.java => BoundedTreeSet.java} (88%) diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3BlobStore.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3BlobStore.java index 6bbaeb88e8..d79381feb2 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3BlobStore.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3BlobStore.java @@ -23,7 +23,7 @@ */ package org.jclouds.aws.s3; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -328,7 +328,7 @@ public interface S3BlobStore extends BlobStore listContainers(); + SortedSet listContainers(); /** * Copies one object to another bucket, retaining UserMetadata from the source. The destination diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ArrayListBucketResponse.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ArrayListBucketResponse.java index af9d71beaa..24bce9a8c3 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ArrayListBucketResponse.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ArrayListBucketResponse.java @@ -31,7 +31,7 @@ import java.util.SortedSet; * @author Adrian Cole * */ -public class ArrayListBucketResponse extends org.jclouds.rest.ArrayBoundedList +public class ArrayListBucketResponse extends org.jclouds.rest.BoundedTreeSet implements ListBucketResponse { /** The serialVersionUID */ private static final long serialVersionUID = -4475709781001190244L; diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java index dbfbe1804d..2f6b26ef05 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java @@ -80,17 +80,16 @@ public class BucketMetadata extends ContainerMetadata { super.setName(name); } - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Metadata [canonicalUser=").append(canonicalUser).append("]"); - return builder.toString(); - } - public String getName() { return name; } + @Override + public String toString() { + return "BucketMetadata [canonicalUser=" + canonicalUser + ", creationDate=" + creationDate + + ", name=" + name + "]"; + } + /** * Every bucket and object in Amazon S3 has an owner, the user that created the bucket or * object. The owner of a bucket or object cannot be changed. However, if the object is diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ListBucketResponse.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ListBucketResponse.java index c144f4deda..f9029d8385 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ListBucketResponse.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/domain/ListBucketResponse.java @@ -48,7 +48,7 @@ import java.util.SortedSet; * @author Adrian Cole * @see */ -public interface ListBucketResponse extends org.jclouds.rest.BoundedList { +public interface ListBucketResponse extends org.jclouds.rest.BoundedSortedSet { /** * Example: diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3ContextModuleTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3ContextModuleTest.java index 26c7400bff..7de9b442b8 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3ContextModuleTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3ContextModuleTest.java @@ -54,24 +54,23 @@ import com.google.inject.TypeLiteral; public class S3ContextModuleTest { Injector createInjector() { - return Guice.createInjector(new RestS3ConnectionModule(), - new BlobStoreMapsModule( - new TypeLiteral() { - }, new TypeLiteral() { - }, new TypeLiteral() { - }, new TypeLiteral() { - }), new S3ContextModule() { - @Override - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user"); - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) - .to("http://localhost"); - super.configure(); - } - }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), + return Guice.createInjector(new RestS3ConnectionModule(), BlobStoreMapsModule.Builder + .newBuilder(new TypeLiteral() { + }, new TypeLiteral() { + }, new TypeLiteral() { + }, new TypeLiteral() { + }).build(), new S3ContextModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( + "user"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) + .to("key"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)).to( + "http://localhost"); + super.configure(); + } + }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), new ExecutorServiceModule(new WithinThreadExecutorService())); } diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/integration/S3ServiceIntegrationTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/integration/S3ServiceIntegrationTest.java index 11ba244ea3..8d326afd75 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/integration/S3ServiceIntegrationTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/integration/S3ServiceIntegrationTest.java @@ -23,7 +23,7 @@ */ package org.jclouds.aws.s3.integration; -import java.util.List; +import java.util.SortedSet; import org.jclouds.aws.s3.S3BlobStore; import org.jclouds.aws.s3.domain.BucketMetadata; @@ -42,8 +42,8 @@ public class S3ServiceIntegrationTest extends void containerExists() throws Exception { String containerName = getContainerName(); try { - List list = context.getApi().listContainers(); - BucketMetadata firstContainer = list.get(0); + SortedSet list = context.getApi().listContainers(); + BucketMetadata firstContainer = list.first(); BucketMetadata toMatch = new BucketMetadata(containerName); toMatch.setOwner(firstContainer.getOwner()); assert list.contains(toMatch); diff --git a/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java b/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java index 708848b2d6..b62fecc5f6 100644 --- a/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java +++ b/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java @@ -29,6 +29,7 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.s3.S3BlobStore; @@ -264,7 +265,7 @@ public class JCloudsS3Service extends S3Service { @Override protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException { try { - List jcBucketList = connection.listContainers(); + SortedSet jcBucketList = connection.listContainers(); return Util.convertBuckets(jcBucketList); } catch (Exception e) { Utils. rethrowIfRuntimeOrSameType(e); diff --git a/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java b/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java index d3f9a6f022..d3ce80fe62 100644 --- a/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java +++ b/aws/s3/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java @@ -32,6 +32,7 @@ import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.SortedSet; import java.util.Map.Entry; import javax.ws.rs.core.MediaType; @@ -81,7 +82,7 @@ public class Util { } public static S3Bucket[] convertBuckets( - List jcBucketMDs) { + SortedSet jcBucketMDs) { List jsBuckets = new ArrayList(jcBucketMDs.size()); for (org.jclouds.aws.s3.domain.BucketMetadata jcBucketMD : jcBucketMDs) { jsBuckets.add(convertBucket(jcBucketMD)); diff --git a/aws/s3/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java b/aws/s3/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java index 649a38d3b8..0b072e5830 100755 --- a/aws/s3/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java +++ b/aws/s3/extensions/jets3t/src/test/java/org/jclouds/aws/s3/jets3t/JCloudsS3ServiceLiveTest.java @@ -35,8 +35,8 @@ import java.io.IOException; import java.io.InputStream; import java.security.NoSuchAlgorithmException; import java.util.Iterator; -import java.util.List; import java.util.Map; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -211,7 +211,7 @@ public class JCloudsS3ServiceLiveTest // Ensure there is at least 1 bucket in S3 account to list and compare. S3Bucket[] jsBuckets = service.listAllBuckets(); - List jcBuckets = context.getApi() + SortedSet jcBuckets = context.getApi() .listContainers(); assert jsBuckets.length == jcBuckets.size(); diff --git a/aws/s3/samples/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java b/aws/s3/samples/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java index adb1c85e6e..09c3dee94a 100644 --- a/aws/s3/samples/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java +++ b/aws/s3/samples/createandlistbuckets/src/main/java/org/jclouds/aws/s3/samples/MainApp.java @@ -23,6 +23,7 @@ */ package org.jclouds.aws.s3.samples; +import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -30,6 +31,9 @@ import java.util.concurrent.TimeoutException; import org.jclouds.aws.s3.S3Context; import org.jclouds.aws.s3.S3ContextFactory; import org.jclouds.aws.s3.domain.BucketMetadata; +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.domain.Blob; /** * This the Main class of an Application that demonstrates the use of the CreateListOwnedBuckets @@ -44,8 +48,9 @@ public class MainApp { public static int PARAMETERS = 3; public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"accesskeyid\" \"secretekey\" \"bucketName\" "; + @SuppressWarnings("unchecked") public static void main(String[] args) throws InterruptedException, ExecutionException, - TimeoutException { + TimeoutException, IOException { if (args.length < PARAMETERS) throw new IllegalArgumentException(INVALID_SYNTAX); @@ -56,15 +61,19 @@ public class MainApp { String bucketName = args[2]; // Init - S3Context context = S3ContextFactory.createContext(accesskeyid, secretkey); + BlobStoreContext context = S3ContextFactory.createContext(accesskeyid, secretkey); try { // Create Bucket - context.getApi().createContainer(bucketName).get(10, TimeUnit.SECONDS); + ((S3Context) context).getApi().createContainer(bucketName).get(10, TimeUnit.SECONDS); + BlobMap blobMap = context.createBlobMap(bucketName); + Blob blob = context.newBlob("test"); + blob.setData("testdata"); + blobMap.put("test", blob); // List bucket - for (BucketMetadata bucketObj : context.getApi().listContainers()) { + for (BucketMetadata bucketObj : ((S3Context) context).getApi().listContainers()) { System.out.println(String.format(" %1$s", bucketObj)); System.out.println(String.format(": %1$s entries%n", context.createInputStreamMap( bucketObj.getName()).size())); diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java index ec21252b9a..752e2d163e 100644 --- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java +++ b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllBucketsController.java @@ -24,7 +24,7 @@ package org.jclouds.samples.googleappengine; import java.io.IOException; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -44,7 +44,8 @@ import org.jclouds.logging.Logger; import org.jclouds.samples.googleappengine.domain.BucketResult; import org.jclouds.samples.googleappengine.functions.MetadataToBucketResult; -import com.google.common.collect.Lists; +import com.google.appengine.repackaged.com.google.common.collect.Sets; +import com.google.common.collect.Iterables; /** * Shows an example of how to use @{link S3Connection} injected with Guice. @@ -85,9 +86,9 @@ public class GetAllBucketsController extends HttpServlet { private void addMyBucketsToRequest(HttpServletRequest request) throws InterruptedException, ExecutionException, TimeoutException { System.err.println(context.getAccount() + ":" + context.getEndPoint()); - List myBucketMetadata = context.getApi().listContainers(); - List myBuckets = Lists.transform(myBucketMetadata, - metadataToBucketResultProvider.get()); + SortedSet myBucketMetadata = context.getApi().listContainers(); + SortedSet myBuckets = Sets.newTreeSet(Iterables.transform(myBucketMetadata, + metadataToBucketResultProvider.get())); request.setAttribute("buckets", myBuckets); } } \ No newline at end of file diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java index 3b6be500cb..eda558c9db 100644 --- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java +++ b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/JCloudsServlet.java @@ -24,8 +24,7 @@ package org.jclouds.samples.googleappengine; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; @@ -43,6 +42,8 @@ import org.jclouds.aws.s3.domain.ListBucketResponse; import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.logging.Logger; +import com.google.common.collect.Sets; + /** * Shows an example of how to use @{link S3Connection} injected with Guice. * @@ -69,7 +70,7 @@ public class JCloudsServlet extends HttpServlet { @Resource protected Logger logger = Logger.NULL; - public static class BucketResult { + public static class BucketResult implements Comparable { private String name; private String size = "unknown"; private String status = "ok"; @@ -97,14 +98,18 @@ public class JCloudsServlet extends HttpServlet { public String getStatus() { return status; } + + public int compareTo(BucketResult o) { + return (this == o) ? 0 : getName().compareTo(o.getName()); + } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { - List myBucketMetadata = context.getApi().listContainers(); - List myBuckets = new ArrayList(); + SortedSet myBucketMetadata = context.getApi().listContainers(); + SortedSet myBuckets = Sets.newTreeSet(); for (BucketMetadata metadata : myBucketMetadata) { BucketResult result = new BucketResult(); result.setName(metadata.getName()); diff --git a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/BucketResult.java b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/BucketResult.java index 9318cc6157..8c9bfb5358 100644 --- a/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/BucketResult.java +++ b/aws/s3/samples/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/BucketResult.java @@ -23,7 +23,8 @@ */ package org.jclouds.samples.googleappengine.domain; -public class BucketResult { + +public class BucketResult implements Comparable{ private String name; private String size = "unknown"; private String status = "ok"; @@ -51,4 +52,8 @@ public class BucketResult { public String getStatus() { return status; } + + public int compareTo(BucketResult o) { + return (this == o) ? 0 : getName().compareTo(o.getName()); + } } diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobStore.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobStore.java index 5c689725d7..d87f769222 100644 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobStore.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobStore.java @@ -23,7 +23,7 @@ */ package org.jclouds.azure.storage.blob; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -45,7 +45,7 @@ import org.jclouds.azure.storage.blob.functions.ReturnTrueIfContainerAlreadyExis import org.jclouds.azure.storage.blob.options.CreateContainerOptions; import org.jclouds.azure.storage.blob.xml.AccountNameEnumerationResultsHandler; import org.jclouds.azure.storage.blob.xml.ContainerNameEnumerationResultsHandler; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.filters.SharedKeyAuthentication; import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.ListOptions; @@ -97,13 +97,13 @@ public interface AzureBlobStore extends BlobStore listContainers(); + SortedSet listContainers(); @GET @XMLResponseParser(AccountNameEnumerationResultsHandler.class) @Path("/") @QueryParams(keys = "comp", values = "list") - BoundedList listContainers(ListOptions listOptions); + BoundedSortedSet listContainers(ListOptions listOptions); @HEAD @Path("{container}") diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ArrayListBlobsResponse.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ArrayListBlobsResponse.java index 4b1585f921..f331cb7f98 100644 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ArrayListBlobsResponse.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ArrayListBlobsResponse.java @@ -26,14 +26,14 @@ package org.jclouds.azure.storage.blob.domain; import java.net.URI; import java.util.List; -import org.jclouds.azure.storage.domain.ArrayBoundedList; +import org.jclouds.azure.storage.domain.BoundedTreeSet; /** * * @author Adrian Cole * */ -public class ArrayListBlobsResponse extends ArrayBoundedList implements +public class ArrayListBlobsResponse extends BoundedTreeSet implements ListBlobsResponse { /** The serialVersionUID */ private static final long serialVersionUID = -4475709781001190244L; diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ListBlobsResponse.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ListBlobsResponse.java index b35332d0fa..79f34f5d51 100644 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ListBlobsResponse.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/domain/ListBlobsResponse.java @@ -25,13 +25,13 @@ package org.jclouds.azure.storage.blob.domain; import java.net.URI; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; /** * * @author Adrian Cole */ -public interface ListBlobsResponse extends BoundedList { +public interface ListBlobsResponse extends BoundedSortedSet { public URI getContainerUrl(); public String getBlobPrefix(); diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java index 8e7ae19fb1..3c2336b6fd 100755 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java @@ -28,8 +28,8 @@ import java.util.ArrayList; import java.util.List; import org.jclouds.azure.storage.blob.domain.ContainerMetadata; -import org.jclouds.azure.storage.domain.ArrayBoundedList; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedTreeSet; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; @@ -46,7 +46,7 @@ import javax.inject.Inject; * @author Adrian Cole */ public class AccountNameEnumerationResultsHandler extends - ParseSax.HandlerWithResult> { + ParseSax.HandlerWithResult> { private List containerMetadata = new ArrayList(); private String prefix; @@ -66,8 +66,8 @@ public class AccountNameEnumerationResultsHandler extends this.dateParser = dateParser; } - public BoundedList getResult() { - return new ArrayBoundedList(containerMetadata, prefix, marker, maxResults, + public BoundedSortedSet getResult() { + return new BoundedTreeSet(containerMetadata, prefix, marker, maxResults, nextMarker); } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreLiveTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreLiveTest.java index 7e6f9cf51f..0d208865c1 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreLiveTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/AzureBlobStoreLiveTest.java @@ -32,7 +32,7 @@ import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; import java.net.URL; import java.security.SecureRandom; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -43,7 +43,7 @@ import org.jclouds.azure.storage.blob.domain.BlobMetadata; import org.jclouds.azure.storage.blob.domain.ContainerMetadata; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.options.CreateContainerOptions; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.options.ListOptions; import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpUtils; @@ -79,7 +79,7 @@ public class AzureBlobStoreLiveTest { @Test public void testListContainers() throws Exception { - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); assert null != response; long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); @@ -108,7 +108,7 @@ public class AzureBlobStoreLiveTest { throw e; } } - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); assert null != response; long containerCount = response.size(); assertTrue(containerCount >= 1); @@ -176,7 +176,7 @@ public class AzureBlobStoreLiveTest { @Test public void testListContainersWithOptions() throws Exception { - BoundedList response = connection.listContainers(ListOptions.Builder + BoundedSortedSet response = connection.listContainers(ListOptions.Builder .prefix(privateContainer).maxResults(1)); assert null != response; long initialContainerCount = response.size(); @@ -196,7 +196,7 @@ public class AzureBlobStoreLiveTest { public void testListOwnedContainers() throws Exception { // Test default listing - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); // assertEquals(response.size(), initialContainerCount + 2);// if the containers already // exist, this will fail @@ -204,12 +204,12 @@ public class AzureBlobStoreLiveTest { response = connection.listContainers(ListOptions.Builder.prefix( privateContainer.substring(0, privateContainer.length() - 1)).maxResults(1)); assertEquals(response.size(), 1); - assertEquals(response.get(0).getName(), privateContainer); + assertEquals(response.first().getName(), privateContainer); response = connection.listContainers(ListOptions.Builder.prefix(publicContainer) .maxResults(1)); assertEquals(response.size(), 1); - assertEquals(response.get(0).getName(), publicContainer); + assertEquals(response.first().getName(), publicContainer); } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobStore.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobStore.java index acc86ba71d..d8f1f8f808 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobStore.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobStore.java @@ -39,7 +39,7 @@ import org.jclouds.azure.storage.blob.domain.BlobMetadata; import org.jclouds.azure.storage.blob.domain.ContainerMetadata; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.options.CreateContainerOptions; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.ListOptions; import org.jclouds.blobstore.ContainerNotFoundException; @@ -66,7 +66,7 @@ public class StubAzureBlobStore extends StubBlobStore listContainers(ListOptions options) { + public BoundedSortedSet listContainers(ListOptions options) { return null; } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandlerTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandlerTest.java index 7ff5e64c0e..da68e75d43 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandlerTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandlerTest.java @@ -29,8 +29,8 @@ import java.io.InputStream; import java.net.URI; import org.jclouds.azure.storage.blob.domain.ContainerMetadata; -import org.jclouds.azure.storage.domain.ArrayBoundedList; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedTreeSet; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.util.DateService; @@ -60,7 +60,7 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { @SuppressWarnings("unchecked") public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_containers.xml"); - BoundedList list = new ArrayBoundedList(ImmutableList + BoundedSortedSet list = new BoundedTreeSet(ImmutableList .of(new ContainerMetadata( URI.create("http://myaccount.blob.core.windows.net/audio"), dateService .rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils @@ -74,7 +74,7 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { ), null, null, 3, "video"); - BoundedList result = (BoundedList) factory.create( + BoundedSortedSet result = (BoundedSortedSet) factory.create( injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); @@ -83,7 +83,7 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { @SuppressWarnings("unchecked") public void testApplyInputStreamWithOptions() { InputStream is = getClass().getResourceAsStream("/test_list_containers_options.xml"); - BoundedList list = new ArrayBoundedList(ImmutableList + BoundedSortedSet list = new BoundedTreeSet(ImmutableList .of(new ContainerMetadata( URI.create("http://myaccount.blob.core.windows.net/audio"), dateService .rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils @@ -96,7 +96,7 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { .fromHexString("0x8CACB9BD7BACAC3")) ), "prefix", "marker", 1, "video"); - BoundedList result = (BoundedList) factory.create( + BoundedSortedSet result = (BoundedSortedSet) factory.create( injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandlerTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandlerTest.java index 020900ea2e..3eaf599cfa 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandlerTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandlerTest.java @@ -31,7 +31,7 @@ import java.net.URI; import org.jclouds.azure.storage.blob.domain.ArrayListBlobsResponse; import org.jclouds.azure.storage.blob.domain.BlobMetadata; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.util.DateService; @@ -79,7 +79,7 @@ public class ContainerNameEnumerationResultsHandlerTest extends BaseHandlerTest ), null, null, 4, "newblob2.txt", null, "myfolder/"); - BoundedList result = (BoundedList) factory.create( + BoundedSortedSet result = (BoundedSortedSet) factory.create( injector.getInstance(ContainerNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedList.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedSortedSet.java similarity index 93% rename from azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedList.java rename to azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedSortedSet.java index fa0dfbf773..26e3a1fd73 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedList.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedSortedSet.java @@ -28,7 +28,7 @@ package org.jclouds.azure.storage.domain; * @author Adrian Cole * */ -public interface BoundedList extends org.jclouds.rest.BoundedList { +public interface BoundedSortedSet extends org.jclouds.rest.BoundedSortedSet { String getNextMarker(); diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/ArrayBoundedList.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedTreeSet.java similarity index 89% rename from azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/ArrayBoundedList.java rename to azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedTreeSet.java index 17f40ab773..3182fb17b3 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/ArrayBoundedList.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/domain/BoundedTreeSet.java @@ -30,8 +30,8 @@ import java.util.List; * @author Adrian Cole * */ -public class ArrayBoundedList extends org.jclouds.rest.ArrayBoundedList implements - BoundedList { +public class BoundedTreeSet extends org.jclouds.rest.BoundedTreeSet implements + BoundedSortedSet { /** The serialVersionUID */ private static final long serialVersionUID = -4475709781001190244L; @@ -53,7 +53,7 @@ public class ArrayBoundedList extends org.jclouds.rest.ArrayBoundedList im return false; if (getClass() != obj.getClass()) return false; - ArrayBoundedList other = (ArrayBoundedList) obj; + BoundedTreeSet other = (BoundedTreeSet) obj; if (nextMarker == null) { if (other.nextMarker != null) return false; @@ -68,7 +68,7 @@ public class ArrayBoundedList extends org.jclouds.rest.ArrayBoundedList im + maxResults + ", prefix=" + prefix + "]"; } - public ArrayBoundedList(List contents, String prefix, String marker, int maxResults, + public BoundedTreeSet(List contents, String prefix, String marker, int maxResults, String nextMarker) { super(contents, prefix, marker, maxResults); this.nextMarker = nextMarker; diff --git a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueConnection.java b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueConnection.java index 961fcca917..80b687c320 100644 --- a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueConnection.java +++ b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/AzureQueueConnection.java @@ -33,7 +33,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import org.jclouds.azure.storage.AzureQueue; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.filters.SharedKeyAuthentication; import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.ListOptions; @@ -85,7 +85,7 @@ public interface AzureQueueConnection { @XMLResponseParser(AccountNameEnumerationResultsHandler.class) @Path("/") @QueryParams(keys = "comp", values = "list") - BoundedList listQueues(ListOptions... listOptions); + BoundedSortedSet listQueues(ListOptions... listOptions); /** * The Create Queue operation creates a new queue under the specified account. diff --git a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandler.java b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandler.java index 546668013b..d5305d1d15 100755 --- a/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandler.java +++ b/azure/storage/queue/core/src/main/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandler.java @@ -27,8 +27,8 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; -import org.jclouds.azure.storage.domain.ArrayBoundedList; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedTreeSet; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.queue.domain.QueueMetadata; import org.jclouds.http.functions.ParseSax; @@ -43,7 +43,7 @@ import javax.inject.Inject; * @author Adrian Cole */ public class AccountNameEnumerationResultsHandler extends - ParseSax.HandlerWithResult> { + ParseSax.HandlerWithResult> { private List metadata = new ArrayList(); private String prefix; @@ -59,8 +59,8 @@ public class AccountNameEnumerationResultsHandler extends public AccountNameEnumerationResultsHandler() { } - public BoundedList getResult() { - return new ArrayBoundedList(metadata, prefix, marker, maxResults, nextMarker); + public BoundedSortedSet getResult() { + return new BoundedTreeSet(metadata, prefix, marker, maxResults, nextMarker); } public void endElement(String uri, String name, String qName) { diff --git a/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/AzureQueueConnectionLiveTest.java b/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/AzureQueueConnectionLiveTest.java index d7bb54c0fa..e42f3197fd 100644 --- a/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/AzureQueueConnectionLiveTest.java +++ b/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/AzureQueueConnectionLiveTest.java @@ -29,7 +29,7 @@ import static org.testng.Assert.assertTrue; import java.lang.reflect.UndeclaredThrowableException; import java.security.SecureRandom; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.ListOptions; import org.jclouds.azure.storage.queue.domain.QueueMetadata; @@ -66,7 +66,7 @@ public class AzureQueueConnectionLiveTest { @Test public void testListQueues() throws Exception { - BoundedList response = connection.listQueues(); + BoundedSortedSet response = connection.listQueues(); assert null != response; long initialQueueCount = response.size(); assertTrue(initialQueueCount >= 0); @@ -90,7 +90,7 @@ public class AzureQueueConnectionLiveTest { throw e; } } - BoundedList response = connection.listQueues(); + BoundedSortedSet response = connection.listQueues(); assert null != response; long queueCount = response.size(); assertTrue(queueCount >= 1); @@ -100,7 +100,7 @@ public class AzureQueueConnectionLiveTest { @Test public void testListQueuesWithOptions() throws Exception { - BoundedList response = connection.listQueues(ListOptions.Builder.prefix( + BoundedSortedSet response = connection.listQueues(ListOptions.Builder.prefix( privateQueue).maxResults(1)); assert null != response; long initialQueueCount = response.size(); diff --git a/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandlerTest.java b/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandlerTest.java index d43bf2daed..6a7fc6e070 100644 --- a/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandlerTest.java +++ b/azure/storage/queue/core/src/test/java/org/jclouds/azure/storage/queue/xml/AccountNameEnumerationResultsHandlerTest.java @@ -28,8 +28,8 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import org.jclouds.azure.storage.domain.ArrayBoundedList; -import org.jclouds.azure.storage.domain.BoundedList; +import org.jclouds.azure.storage.domain.BoundedTreeSet; +import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.queue.domain.QueueMetadata; import org.jclouds.http.functions.BaseHandlerTest; import org.testng.annotations.Test; @@ -47,12 +47,12 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { @SuppressWarnings("unchecked") public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/test_list_queues.xml"); - BoundedList list = new ArrayBoundedList(ImmutableList.of( + BoundedSortedSet list = new BoundedTreeSet(ImmutableList.of( new QueueMetadata("q1", URI.create("http://myaccount.queue.core.windows.net/q1")), new QueueMetadata("q2", URI.create("http://myaccount.queue.core.windows.net/q2")), new QueueMetadata("q3", URI.create("http://myaccount.queue.core.windows.net/q3"))), "q", null, 3, "q4"); - BoundedList result = (BoundedList) factory.create( + BoundedSortedSet result = (BoundedSortedSet) factory.create( injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); } @@ -60,12 +60,12 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest { @SuppressWarnings("unchecked") public void testApplyInputStreamWithOptions() { InputStream is = getClass().getResourceAsStream("/test_list_queues_options.xml"); - BoundedList list = new ArrayBoundedList(ImmutableList.of( + BoundedSortedSet list = new BoundedTreeSet(ImmutableList.of( new QueueMetadata("q4", URI.create("http://myaccount.queue.core.windows.net/q4")), new QueueMetadata("q5", URI.create("http://myaccount.queue.core.windows.net/q5"))), "q", "q4", 3, null); - BoundedList result = (BoundedList) factory.create( + BoundedSortedSet result = (BoundedSortedSet) factory.create( injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); diff --git a/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStore.java index 2e4c9ca740..a29ec08567 100644 --- a/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -23,7 +23,7 @@ */ package org.jclouds.blobstore; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.Future; import org.jclouds.blobstore.domain.Blob; @@ -35,7 +35,7 @@ import org.jclouds.http.options.GetOptions; * Provides hooks needed to run a blob store */ public interface BlobStore> { - List listContainers(); + SortedSet listContainers(); boolean containerExists(String container); @@ -50,7 +50,7 @@ public interface BlobStore deleteContainer(String container); - Future> listBlobs(String container); + Future> listBlobs(String container); Future putBlob(String container, B blob); diff --git a/blobstore/core/src/main/java/org/jclouds/blobstore/ListableMap.java b/blobstore/core/src/main/java/org/jclouds/blobstore/ListableMap.java index 74a5d63f90..c16cc3219a 100755 --- a/blobstore/core/src/main/java/org/jclouds/blobstore/ListableMap.java +++ b/blobstore/core/src/main/java/org/jclouds/blobstore/ListableMap.java @@ -23,8 +23,8 @@ */ package org.jclouds.blobstore; -import java.util.List; import java.util.Map; +import java.util.SortedSet; import org.jclouds.blobstore.domain.BlobMetadata; @@ -34,12 +34,12 @@ import org.jclouds.blobstore.domain.BlobMetadata; * @author Adrian Cole * */ -public interface ListableMap extends Map { +public interface ListableMap extends Map { /** * * @return blob listing that this map represents */ - List listContainer(); + SortedSet listContainer(); } \ No newline at end of file diff --git a/blobstore/core/src/main/java/org/jclouds/blobstore/domain/Blob.java b/blobstore/core/src/main/java/org/jclouds/blobstore/domain/Blob.java index e081439a29..e5ffc1c19d 100644 --- a/blobstore/core/src/main/java/org/jclouds/blobstore/domain/Blob.java +++ b/blobstore/core/src/main/java/org/jclouds/blobstore/domain/Blob.java @@ -43,7 +43,7 @@ import org.jclouds.http.HttpUtils.MD5InputStreamResult; * * @author Adrian Cole */ -public class Blob { +public class Blob implements Comparable> { @SuppressWarnings("unchecked") @Override @@ -217,4 +217,8 @@ public class Blob { this.metadata = metadata; } + public int compareTo(Blob o) { + return (this == o) ? 0 : getKey().compareTo(o.getKey()); + } + } diff --git a/blobstore/core/src/main/java/org/jclouds/blobstore/domain/ContainerMetadata.java b/blobstore/core/src/main/java/org/jclouds/blobstore/domain/ContainerMetadata.java index 447b499961..fb264802b7 100644 --- a/blobstore/core/src/main/java/org/jclouds/blobstore/domain/ContainerMetadata.java +++ b/blobstore/core/src/main/java/org/jclouds/blobstore/domain/ContainerMetadata.java @@ -30,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; * * @author Adrian Cole */ -public class ContainerMetadata { +public class ContainerMetadata implements Comparable { protected String name; @@ -77,4 +77,8 @@ public class ContainerMetadata { return false; return true; } + + public int compareTo(ContainerMetadata o) { + return (this == o) ? 0 : getName().compareTo(o.getName()); + } } \ No newline at end of file diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index 867d24b1c5..f6de16baca 100755 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -38,7 +38,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Collections; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -314,7 +314,7 @@ public class BaseBlobIntegrationTest, C extends Con private void assertContainerEmptyDeleting(String containerName, String key) throws InterruptedException, ExecutionException, TimeoutException { - List listing = context.getApi().listBlobs(containerName).get(10, TimeUnit.SECONDS); + SortedSet listing = context.getApi().listBlobs(containerName).get(10, TimeUnit.SECONDS); assertEquals(listing.size(), 0, String.format( "deleting %s, we still have %s left in container %s, using encoding %s", key, listing.size(), containerName, LOCAL_ENCODING)); diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 84411cb29f..96691df96b 100755 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -26,7 +26,7 @@ package org.jclouds.blobstore.integration.internal; import static org.testng.Assert.assertEquals; import java.io.UnsupportedEncodingException; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -126,7 +126,8 @@ public class BaseContainerIntegrationTest, C extend String containerName = getContainerName(); try { add15UnderRoot(containerName); - List container = context.getApi().listBlobs(containerName).get(10, TimeUnit.SECONDS); + SortedSet container = context.getApi().listBlobs(containerName).get(10, + TimeUnit.SECONDS); assertEquals(container.size(), 15); } finally { returnContainer(containerName); diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java index 8e658bc96d..9b8b91f0f5 100755 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java @@ -23,7 +23,7 @@ */ package org.jclouds.blobstore.integration.internal; -import java.util.List; +import java.util.SortedSet; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.domain.Blob; @@ -40,7 +40,7 @@ public class BaseServiceIntegrationTest, C extends @Test(groups = { "integration", "live" }) void containerDoesntExist() throws Exception { - List list = context.getApi().listContainers(); + SortedSet list = context.getApi().listContainers(); assert !list.contains(new ContainerMetadata("shouldntexist")); } diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/StubBlobStore.java b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/StubBlobStore.java index 84b924c601..be7a6e6754 100755 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/StubBlobStore.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/StubBlobStore.java @@ -141,9 +141,9 @@ public class StubBlobStore> listBlobs(final String name) { - return new FutureBase>() { - public List get() throws InterruptedException, ExecutionException { + public Future> listBlobs(final String name) { + return new FutureBase>() { + public SortedSet get() throws InterruptedException, ExecutionException { final Map realContents = getContainerToBlobs().get(name); if (realContents == null) @@ -155,7 +155,7 @@ public class StubBlobStore listContainers() { - return Lists.newArrayList(Iterables.transform(getContainerToBlobs().keySet(), + public SortedSet listContainers() { + return Sets.newTreeSet(Iterables.transform(getContainerToBlobs().keySet(), new Function() { public C apply(String name) { C cmd = containerMetaProvider.get(); diff --git a/core/src/main/java/org/jclouds/rest/BoundedList.java b/core/src/main/java/org/jclouds/rest/BoundedSortedSet.java similarity index 93% rename from core/src/main/java/org/jclouds/rest/BoundedList.java rename to core/src/main/java/org/jclouds/rest/BoundedSortedSet.java index 99422008cb..b34adc379f 100644 --- a/core/src/main/java/org/jclouds/rest/BoundedList.java +++ b/core/src/main/java/org/jclouds/rest/BoundedSortedSet.java @@ -23,14 +23,14 @@ */ package org.jclouds.rest; -import java.util.List; +import java.util.SortedSet; /** * * @author Adrian Cole * */ -public interface BoundedList extends List { +public interface BoundedSortedSet extends SortedSet { String getPrefix(); diff --git a/core/src/main/java/org/jclouds/rest/ArrayBoundedList.java b/core/src/main/java/org/jclouds/rest/BoundedTreeSet.java similarity index 88% rename from core/src/main/java/org/jclouds/rest/ArrayBoundedList.java rename to core/src/main/java/org/jclouds/rest/BoundedTreeSet.java index a31323e505..e91dc21a5d 100644 --- a/core/src/main/java/org/jclouds/rest/ArrayBoundedList.java +++ b/core/src/main/java/org/jclouds/rest/BoundedTreeSet.java @@ -23,10 +23,10 @@ */ package org.jclouds.rest; -import java.util.ArrayList; import java.util.List; +import java.util.TreeSet; -public class ArrayBoundedList extends ArrayList implements BoundedList { +public class BoundedTreeSet extends TreeSet implements BoundedSortedSet { /** The serialVersionUID */ private static final long serialVersionUID = -7133632087734650835L; @@ -34,7 +34,7 @@ public class ArrayBoundedList extends ArrayList implements BoundedList protected final String marker; protected final int maxResults; - public ArrayBoundedList(List contents, String prefix, String marker, int maxResults) { + public BoundedTreeSet(List contents, String prefix, String marker, int maxResults) { this.addAll(contents); this.prefix = prefix; this.marker = marker; diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSBlobStore.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSBlobStore.java index cae8dc09bc..dc15fdf0ed 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSBlobStore.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSBlobStore.java @@ -23,7 +23,7 @@ */ package org.jclouds.mezeo.pcs2; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.Future; import javax.ws.rs.DELETE; @@ -83,7 +83,7 @@ public interface PCSBlobStore extends BlobStore listContainers(); + SortedSet listContainers(); @GET @ExceptionParser(ReturnFalseIfContainerNotFound.class) @@ -111,7 +111,7 @@ public interface PCSBlobStore extends BlobStore> listBlobs( + Future> listBlobs( @PathParam("containerResourceId") @ParamParser(ContainerNameToResourceId.class) String containerName); @POST diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerList.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerList.java index d9456627bd..887c123e4b 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerList.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerList.java @@ -1,6 +1,6 @@ package org.jclouds.mezeo.pcs2.functions; -import java.util.List; +import java.util.SortedSet; import javax.inject.Inject; @@ -20,12 +20,12 @@ public class FindIdInContainerList implements Function { } public String apply(String key) { - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); return idForNameInListOrException(key, response); } @VisibleForTesting - String idForNameInListOrException(String toFind, List containerMetadataList) { + String idForNameInListOrException(String toFind, SortedSet containerMetadataList) { for (ContainerMetadata data : containerMetadataList) { if (toFind.equals(data.getName())) { String path = data.getUrl().getPath(); diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileList.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileList.java index b16ba2c1f2..a6c6b7e1bb 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileList.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileList.java @@ -1,7 +1,7 @@ package org.jclouds.mezeo.pcs2.functions; import java.util.Arrays; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.TimeUnit; import javax.inject.Inject; @@ -25,7 +25,7 @@ public class FindIdInFileList implements Function { } public String apply(Key key) { - List response; + SortedSet response; try { response = connection.listBlobs(key.getContainer()).get(10, TimeUnit.SECONDS); } catch (Exception e) { @@ -36,7 +36,7 @@ public class FindIdInFileList implements Function { } @VisibleForTesting - String idForNameInListOrException(String container, String toFind, List response) { + String idForNameInListOrException(String container, String toFind, SortedSet response) { for (FileMetadata data : response) { if (toFind.equals(data.getKey())) { String path = data.getUrl().getPath(); diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreLiveTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreLiveTest.java index 404269275e..e2c4debf1d 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreLiveTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreLiveTest.java @@ -30,7 +30,7 @@ import static org.testng.Assert.assertTrue; import java.io.InputStream; import java.net.URI; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; @@ -73,7 +73,7 @@ public class PCSBlobStoreLiveTest { @Test public void testListContainers() throws Exception { - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); assertNotNull(response); long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreTest.java index 2fb5727c66..887503441c 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/PCSBlobStoreTest.java @@ -31,7 +31,7 @@ import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.net.URI; import java.util.Collections; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -76,13 +76,13 @@ import org.jclouds.util.Utils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableSortedSet; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.internal.ImmutableList; /** * Tests behavior of {@code PCSConnection} @@ -102,11 +102,11 @@ public class PCSBlobStoreTest { return null; } - public Future> listBlobs(String containerName) { - return new StubBlobStore.FutureBase>() { - public List get() throws InterruptedException, ExecutionException { + public Future> listBlobs(String containerName) { + return new StubBlobStore.FutureBase>() { + public SortedSet get() throws InterruptedException, ExecutionException { - return ImmutableList + return ImmutableSortedSet .of( new FileMetadata( "more", @@ -132,8 +132,8 @@ public class PCSBlobStoreTest { } - public List listContainers() { - return ImmutableList + public SortedSet listContainers() { + return ImmutableSortedSet .of(new ContainerMetadata( "mycontainer", URI @@ -383,7 +383,6 @@ public class PCSBlobStoreTest { JaxrsAnnotationProcessor processor; private JaxrsAnnotationProcessor utilProcessor; - @SuppressWarnings("unchecked") @BeforeClass void setupFactory() { Injector injector = Guice.createInjector(new AbstractModule() { @@ -431,12 +430,12 @@ public class PCSBlobStoreTest { throws UnsupportedEncodingException { return new BasicAuthentication(user, password); } - }, new JaxrsModule(), new BlobStoreMapsModule(new TypeLiteral() { + }, new JaxrsModule(), BlobStoreMapsModule.Builder.newBuilder(new TypeLiteral() { }, new TypeLiteral() { }, new TypeLiteral() { }, new TypeLiteral() { - }), new PCSContextModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), - new JavaUrlHttpCommandExecutorServiceModule()); + }).build(), new PCSContextModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); processor = injector.getInstance(Key .get(new TypeLiteral>() { diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java index bdd5320dfb..ba017dd541 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java @@ -31,26 +31,22 @@ import com.google.inject.TypeLiteral; public class PCSContextModuleTest { Injector createInjector() { - return Guice.createInjector(new RestPCSBlobStoreModule(), - new BlobStoreMapsModule( - new TypeLiteral() { - }, new TypeLiteral() { - }, new TypeLiteral() { - }, new TypeLiteral() { - }), new PCSContextModule() { - @Override - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_USER)) - .to("user"); - bindConstant() - .annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_PASSWORD)).to( - "key"); - bindConstant() - .annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_ENDPOINT)).to( - "http://localhost"); - super.configure(); - } - }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), + return Guice.createInjector(new RestPCSBlobStoreModule(), BlobStoreMapsModule.Builder + .newBuilder(new TypeLiteral() { + }, new TypeLiteral() { + }, new TypeLiteral() { + }, new TypeLiteral() { + }).build(), new PCSContextModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_USER)).to("user"); + bindConstant().annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_PASSWORD)).to( + "key"); + bindConstant().annotatedWith(Jsr330.named(PCSConstants.PROPERTY_PCS2_ENDPOINT)).to( + "http://localhost"); + super.configure(); + } + }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), new ExecutorServiceModule(new WithinThreadExecutorService())); } diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerListTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerListTest.java index ecc36198ed..8c295d03c1 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerListTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInContainerListTest.java @@ -34,7 +34,7 @@ import org.jclouds.mezeo.pcs2.domain.ContainerMetadata; import org.jclouds.util.DateService; import org.testng.annotations.Test; -import com.google.inject.internal.ImmutableList; +import com.google.common.collect.ImmutableSortedSet; /** * Tests behavior of {@code ContainerResourceId} @@ -45,7 +45,7 @@ import com.google.inject.internal.ImmutableList; public class FindIdInContainerListTest { private DateService dateService = new DateService(); - private final ImmutableList OF = ImmutableList + private final ImmutableSortedSet OF = ImmutableSortedSet .of(new ContainerMetadata( "test1", URI diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileListIdTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileListIdTest.java index 463bfd65dc..c6fd01edbd 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileListIdTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/functions/FindIdInFileListIdTest.java @@ -36,7 +36,7 @@ import org.jclouds.mezeo.pcs2.domain.FileMetadata; import org.jclouds.util.DateService; import org.testng.annotations.Test; -import com.google.inject.internal.ImmutableList; +import com.google.common.collect.ImmutableSortedSet; /** * Tests behavior of {@code ContainerResourceId} @@ -47,7 +47,7 @@ import com.google.inject.internal.ImmutableList; public class FindIdInFileListIdTest { private DateService dateService = new DateService(); - private final ImmutableList OF = ImmutableList.of(new FileMetadata("more", URI + private final ImmutableSortedSet OF = ImmutableSortedSet.of(new FileMetadata("more", URI .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A"), dateService.fromSeconds(1254005157), dateService.fromSeconds(1254005158), dateService .fromSeconds(1254005159), "adrian@jclouds.org", false, false, 1, 254288, diff --git a/rackspace/cloudfiles/core/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStore.java b/rackspace/cloudfiles/core/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStore.java index bb596bc932..3f3db3760c 100644 --- a/rackspace/cloudfiles/core/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStore.java +++ b/rackspace/cloudfiles/core/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStore.java @@ -23,7 +23,7 @@ */ package org.jclouds.rackspace.cloudfiles; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -96,13 +96,13 @@ public interface CloudFilesBlobStore extends @ResponseParser(ParseContainerListFromJsonResponse.class) @QueryParams(keys = "format", values = "json") @Path("/") - List listContainers(); + SortedSet listContainers(); @GET @ResponseParser(ParseContainerListFromJsonResponse.class) @QueryParams(keys = "format", values = "json") @Path("/") - List listContainers(ListContainerOptions options); + SortedSet listContainers(ListContainerOptions options); @HEAD @Path("{container}") @@ -122,7 +122,7 @@ public interface CloudFilesBlobStore extends @QueryParams(keys = "format", values = "json") @ResponseParser(ParseBlobMetadataListFromJsonResponse.class) @Path("{container}") - Future> listBlobs(@PathParam("container") String container); + Future> listBlobs(@PathParam("container") String container); @PUT @Path("{container}/{key}") @@ -175,7 +175,7 @@ public interface CloudFilesBlobStore extends @QueryParams(keys = "format", values = "json") @Path("/") @Endpoint(CloudFilesCDN.class) - List listCDNContainers(ListCdnContainerOptions... options); + SortedSet listCDNContainers(ListCdnContainerOptions... options); // TODO: Container name is not included in CDN HEAD response headers, so we cannot populate it // here. diff --git a/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStoreLiveTest.java b/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStoreLiveTest.java index 5199c0bf8d..5cf5f5cb53 100644 --- a/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStoreLiveTest.java +++ b/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesBlobStoreLiveTest.java @@ -30,7 +30,7 @@ import static org.testng.Assert.fail; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.List; +import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; @@ -111,7 +111,7 @@ public class CloudFilesBlobStoreLiveTest { // List CDN metadata for containers, and ensure all CDN info is available for enabled // container - List cdnMetadataList = connection.listCDNContainers(); + SortedSet cdnMetadataList = connection.listCDNContainers(); assertTrue(cdnMetadataList.size() >= 1); assertTrue(Iterables.any(cdnMetadataList, new Predicate() { public boolean apply(ContainerCDNMetadata cdnMetadata) { @@ -132,7 +132,7 @@ public class CloudFilesBlobStoreLiveTest { cdnMetadataList = connection.listCDNContainers(ListCdnContainerOptions.Builder.afterMarker( containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1)); assertEquals(cdnMetadataList.size(), 1); - assertEquals(cdnMetadataList.get(0).getName(), containerNameWithCDN); + assertEquals(cdnMetadataList.first().getName(), containerNameWithCDN); // Enable CDN with PUT for the same container, this time with a custom TTL long ttl = 4000; @@ -168,7 +168,7 @@ public class CloudFilesBlobStoreLiveTest { @Test public void testListOwnedContainers() throws Exception { - List response = connection.listContainers(); + SortedSet response = connection.listContainers(); assertNotNull(response); long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); @@ -188,12 +188,12 @@ public class CloudFilesBlobStoreLiveTest { response = connection.listContainers(ListContainerOptions.Builder.afterMarker( containerJsr330[0].substring(0, containerJsr330[0].length() - 1)).maxResults(1)); assertEquals(response.size(), 1); - assertEquals(response.get(0).getName(), containerJsr330[0]); + assertEquals(response.first().getName(), containerJsr330[0]); response = connection.listContainers(ListContainerOptions.Builder.afterMarker( containerJsr330[0]).maxResults(1)); assertEquals(response.size(), 1); - assertEquals(response.get(0).getName(), containerJsr330[1]); + assertEquals(response.first().getName(), containerJsr330[1]); // Cleanup and test containers have been removed assertTrue(connection.deleteContainer(containerJsr330[0]).get(10, TimeUnit.SECONDS)); @@ -233,12 +233,12 @@ public class CloudFilesBlobStoreLiveTest { String containerName1 = bucketPrefix + ".hello"; assertTrue(connection.createContainer(containerName1).get(10, TimeUnit.SECONDS)); // List only the container just created, using a marker with the container name less 1 char - List response = connection + SortedSet response = connection .listContainers(ListContainerOptions.Builder.afterMarker( containerName1.substring(0, containerName1.length() - 1)).maxResults(1)); assertNotNull(response); assertEquals(response.size(), 1); - assertEquals(response.get(0).getName(), bucketPrefix + ".hello"); + assertEquals(response.first().getName(), bucketPrefix + ".hello"); String containerName2 = bucketPrefix + "?should-be-illegal-question-char"; try { diff --git a/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/internal/StubCloudFilesBlobStore.java b/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/internal/StubCloudFilesBlobStore.java index d7f0cbf002..b72a725a5c 100644 --- a/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/internal/StubCloudFilesBlobStore.java +++ b/rackspace/cloudfiles/core/src/test/java/org/jclouds/rackspace/cloudfiles/internal/StubCloudFilesBlobStore.java @@ -23,8 +23,8 @@ */ package org.jclouds.rackspace.cloudfiles.internal; -import java.util.List; import java.util.Map; +import java.util.SortedSet; import javax.inject.Inject; import javax.inject.Provider; @@ -51,7 +51,7 @@ import com.google.common.collect.Multimap; public class StubCloudFilesBlobStore extends StubBlobStore> implements CloudFilesBlobStore { - + @Inject protected StubCloudFilesBlobStore(Map>> containerToBlobs, DateService dateService, Provider containerMetaProvider, @@ -63,7 +63,7 @@ public class StubCloudFilesBlobStore extends return null; } - public List listContainers(ListContainerOptions options) { + public SortedSet listContainers(ListContainerOptions options) { return null; } @@ -88,7 +88,7 @@ public class StubCloudFilesBlobStore extends return null; } - public List listCDNContainers(ListCdnContainerOptions... options) { + public SortedSet listCDNContainers(ListCdnContainerOptions... options) { return null; }