Issue 108

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1942 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-03 22:33:10 +00:00
parent a1ca5773c7
commit e95e8f3429
11 changed files with 111 additions and 86 deletions

View File

@ -24,7 +24,7 @@
package org.jclouds.azure.storage.blob.domain; package org.jclouds.azure.storage.blob.domain;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.SortedSet;
import org.jclouds.azure.storage.domain.BoundedTreeSet; import org.jclouds.azure.storage.domain.BoundedTreeSet;
@ -33,7 +33,7 @@ import org.jclouds.azure.storage.domain.BoundedTreeSet;
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
public class ArrayListBlobsResponse extends BoundedTreeSet<BlobMetadata> implements public class TreeSetListBlobsResponse extends BoundedTreeSet<BlobMetadata> implements
ListBlobsResponse { ListBlobsResponse {
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = -4475709781001190244L; private static final long serialVersionUID = -4475709781001190244L;
@ -43,9 +43,9 @@ public class ArrayListBlobsResponse extends BoundedTreeSet<BlobMetadata> impleme
@Override @Override
public String toString() { public String toString() {
return "ArrayListBlobsResponse [blobPrefix=" + blobPrefix + ", containerUrl=" + containerUrl return "TreeSetListBlobsResponse [blobPrefix=" + blobPrefix + ", containerUrl="
+ ", delimiter=" + delimiter + ", nextMarker=" + nextMarker + ", marker=" + marker + containerUrl + ", delimiter=" + delimiter + ", nextMarker=" + nextMarker
+ ", maxResults=" + maxResults + ", prefix=" + prefix + "]"; + ", marker=" + marker + ", maxResults=" + maxResults + ", prefix=" + prefix + "]";
} }
@Override @Override
@ -66,7 +66,7 @@ public class ArrayListBlobsResponse extends BoundedTreeSet<BlobMetadata> impleme
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
ArrayListBlobsResponse other = (ArrayListBlobsResponse) obj; TreeSetListBlobsResponse other = (TreeSetListBlobsResponse) obj;
if (blobPrefix == null) { if (blobPrefix == null) {
if (other.blobPrefix != null) if (other.blobPrefix != null)
return false; return false;
@ -85,8 +85,9 @@ public class ArrayListBlobsResponse extends BoundedTreeSet<BlobMetadata> impleme
return true; return true;
} }
public ArrayListBlobsResponse(URI containerUrl, List<BlobMetadata> contents, String prefix, public TreeSetListBlobsResponse(URI containerUrl, SortedSet<BlobMetadata> contents,
String marker, int maxResults, String nextMarker, String delimiter, String blobPrefix) { String prefix, String marker, int maxResults, String nextMarker, String delimiter,
String blobPrefix) {
super(contents, prefix, marker, maxResults, nextMarker); super(contents, prefix, marker, maxResults, nextMarker);
this.containerUrl = containerUrl; this.containerUrl = containerUrl;
this.delimiter = delimiter; this.delimiter = delimiter;

View File

@ -24,18 +24,19 @@
package org.jclouds.azure.storage.blob.xml; package org.jclouds.azure.storage.blob.xml;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.SortedSet;
import java.util.List;
import javax.inject.Inject;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata; import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import javax.inject.Inject; import com.google.common.collect.Sets;
/** /**
* Parses the following XML document: * Parses the following XML document:
@ -48,7 +49,7 @@ import javax.inject.Inject;
public class AccountNameEnumerationResultsHandler extends public class AccountNameEnumerationResultsHandler extends
ParseSax.HandlerWithResult<BoundedSortedSet<ContainerMetadata>> { ParseSax.HandlerWithResult<BoundedSortedSet<ContainerMetadata>> {
private List<ContainerMetadata> containerMetadata = new ArrayList<ContainerMetadata>(); private SortedSet<ContainerMetadata> containerMetadata = Sets.newTreeSet();
private String prefix; private String prefix;
private String marker; private String marker;
private int maxResults; private int maxResults;

View File

@ -24,12 +24,13 @@
package org.jclouds.azure.storage.blob.xml; package org.jclouds.azure.storage.blob.xml;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.SortedSet;
import java.util.List;
import javax.inject.Inject;
import org.jclouds.azure.storage.blob.domain.ArrayListBlobsResponse;
import org.jclouds.azure.storage.blob.domain.BlobMetadata; import org.jclouds.azure.storage.blob.domain.BlobMetadata;
import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse;
import org.jclouds.azure.storage.blob.domain.TreeSetListBlobsResponse;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
@ -37,7 +38,7 @@ import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.inject.Inject; import com.google.common.collect.Sets;
/** /**
* Parses the following XML document: * Parses the following XML document:
@ -50,7 +51,7 @@ import javax.inject.Inject;
public class ContainerNameEnumerationResultsHandler extends public class ContainerNameEnumerationResultsHandler extends
ParseSax.HandlerWithResult<ListBlobsResponse> { ParseSax.HandlerWithResult<ListBlobsResponse> {
private List<BlobMetadata> blobMetadata = new ArrayList<BlobMetadata>(); private SortedSet<BlobMetadata> blobMetadata = Sets.newTreeSet();
private String prefix; private String prefix;
private String marker; private String marker;
private int maxResults; private int maxResults;
@ -79,7 +80,7 @@ public class ContainerNameEnumerationResultsHandler extends
} }
public ListBlobsResponse getResult() { public ListBlobsResponse getResult() {
return new ArrayListBlobsResponse(containerUrl, blobMetadata, prefix, marker, maxResults, return new TreeSetListBlobsResponse(containerUrl, blobMetadata, prefix, marker, maxResults,
nextMarker, delimiter, blobPrefix); nextMarker, delimiter, blobPrefix);
} }

View File

@ -33,11 +33,11 @@ import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
import org.jclouds.azure.storage.blob.AzureBlobStore; import org.jclouds.azure.storage.blob.AzureBlobStore;
import org.jclouds.azure.storage.blob.domain.ArrayListBlobsResponse;
import org.jclouds.azure.storage.blob.domain.Blob; import org.jclouds.azure.storage.blob.domain.Blob;
import org.jclouds.azure.storage.blob.domain.BlobMetadata; import org.jclouds.azure.storage.blob.domain.BlobMetadata;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata; import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse;
import org.jclouds.azure.storage.blob.domain.TreeSetListBlobsResponse;
import org.jclouds.azure.storage.blob.options.CreateContainerOptions; import org.jclouds.azure.storage.blob.options.CreateContainerOptions;
import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.CreateOptions;
@ -48,7 +48,6 @@ import org.jclouds.util.DateService;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
@ -104,8 +103,8 @@ public class StubAzureBlobStore extends StubBlobStore<ContainerMetadata, BlobMet
} }
})); }));
return new ArrayListBlobsResponse(URI.create("http://localhost"), Lists return new TreeSetListBlobsResponse(URI.create("http://localhost"), contents, null,
.newArrayList(contents), null, null, 5000, null, null, null); null, 5000, null, null, null);
} }
}; };
} }

View File

@ -29,15 +29,15 @@ import java.io.InputStream;
import java.net.URI; import java.net.URI;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata; import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedSet;
/** /**
* Tests behavior of {@code ParseFlavorListFromGsonResponseTest} * Tests behavior of {@code ParseFlavorListFromGsonResponseTest}
@ -60,9 +60,9 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/test_list_containers.xml"); InputStream is = getClass().getResourceAsStream("/test_list_containers.xml");
BoundedSortedSet<ContainerMetadata> list = new BoundedTreeSet<ContainerMetadata>(ImmutableList BoundedSortedSet<ContainerMetadata> list = new BoundedTreeSet<ContainerMetadata>(
.of(new ContainerMetadata( ImmutableSortedSet.of(new ContainerMetadata(URI
URI.create("http://myaccount.blob.core.windows.net/audio"), dateService .create("http://myaccount.blob.core.windows.net/audio"), dateService
.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils .rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI .fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/images"), dateService .create("http://myaccount.blob.core.windows.net/images"), dateService
@ -74,8 +74,8 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
), null, null, 3, "video"); ), null, null, 3, "video");
BoundedSortedSet<ContainerMetadata> result = (BoundedSortedSet<ContainerMetadata>) factory.create( BoundedSortedSet<ContainerMetadata> result = (BoundedSortedSet<ContainerMetadata>) factory
injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); .create(injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is);
assertEquals(result, list); assertEquals(result, list);
} }
@ -83,9 +83,9 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testApplyInputStreamWithOptions() { public void testApplyInputStreamWithOptions() {
InputStream is = getClass().getResourceAsStream("/test_list_containers_options.xml"); InputStream is = getClass().getResourceAsStream("/test_list_containers_options.xml");
BoundedSortedSet<ContainerMetadata> list = new BoundedTreeSet<ContainerMetadata>(ImmutableList BoundedSortedSet<ContainerMetadata> list = new BoundedTreeSet<ContainerMetadata>(
.of(new ContainerMetadata( ImmutableSortedSet.of(new ContainerMetadata(URI
URI.create("http://myaccount.blob.core.windows.net/audio"), dateService .create("http://myaccount.blob.core.windows.net/audio"), dateService
.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils .rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI .fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/images"), dateService .create("http://myaccount.blob.core.windows.net/images"), dateService
@ -96,8 +96,8 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
.fromHexString("0x8CACB9BD7BACAC3")) .fromHexString("0x8CACB9BD7BACAC3"))
), "prefix", "marker", 1, "video"); ), "prefix", "marker", 1, "video");
BoundedSortedSet<ContainerMetadata> result = (BoundedSortedSet<ContainerMetadata>) factory.create( BoundedSortedSet<ContainerMetadata> result = (BoundedSortedSet<ContainerMetadata>) factory
injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); .create(injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is);
assertEquals(result, list); assertEquals(result, list);
} }
} }

View File

@ -28,9 +28,9 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; 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.BlobMetadata;
import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.domain.ListBlobsResponse;
import org.jclouds.azure.storage.blob.domain.TreeSetListBlobsResponse;
import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
@ -38,7 +38,7 @@ import org.jclouds.util.DateService;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedSet;
/** /**
* Tests behavior of {@code ContainerNameEnumerationResultsHandlerTest} * Tests behavior of {@code ContainerNameEnumerationResultsHandlerTest}
@ -60,27 +60,40 @@ public class ContainerNameEnumerationResultsHandlerTest extends BaseHandlerTest
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/test_list_blobs.xml"); InputStream is = getClass().getResourceAsStream("/test_list_blobs.xml");
ListBlobsResponse list = new ArrayListBlobsResponse(URI ListBlobsResponse list = new TreeSetListBlobsResponse(
.create("http://myaccount.blob.core.windows.net/mycontainer"), ImmutableList.of( URI.create("http://myaccount.blob.core.windows.net/mycontainer"),
new BlobMetadata("blob1.txt", URI ImmutableSortedSet
.of(
new BlobMetadata(
"blob1.txt",
URI
.create("http://myaccount.blob.core.windows.net/mycontainer/blob1.txt"), .create("http://myaccount.blob.core.windows.net/mycontainer/blob1.txt"),
dateService.rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"), HttpUtils dateService
.fromHexString("0x8CAE7D55D050B8B"), 8, .rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"),
"text/plain; charset=UTF-8", null, null, null), new BlobMetadata("blob2.txt", URI HttpUtils.fromHexString("0x8CAE7D55D050B8B"), 8,
.create("http://myaccount.blob.core.windows.net/mycontainer/blob2.txt"),
dateService.rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"), HttpUtils
.fromHexString("0x8CAE7D55CF6C339"), 14,
"text/plain; charset=UTF-8", null, null, null), "text/plain; charset=UTF-8", null, null, null),
new BlobMetadata("newblob1.txt", URI new BlobMetadata(
"blob2.txt",
URI
.create("http://myaccount.blob.core.windows.net/mycontainer/blob2.txt"),
dateService
.rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"),
HttpUtils.fromHexString("0x8CAE7D55CF6C339"), 14,
"text/plain; charset=UTF-8", null, null, null),
new BlobMetadata(
"newblob1.txt",
URI
.create("http://myaccount.blob.core.windows.net/mycontainer/newblob1.txt"), .create("http://myaccount.blob.core.windows.net/mycontainer/newblob1.txt"),
dateService.rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"), HttpUtils dateService
.fromHexString("0x8CAE7D55CF6C339"), 25, .rfc822DateParse("Thu, 18 Sep 2008 18:41:57 GMT"),
HttpUtils.fromHexString("0x8CAE7D55CF6C339"), 25,
"text/plain; charset=UTF-8", null, null, null) "text/plain; charset=UTF-8", null, null, null)
), null, null, 4, "newblob2.txt", null, "myfolder/"); ), null, null, 4, "newblob2.txt", null, "myfolder/");
BoundedSortedSet<ListBlobsResponse> result = (BoundedSortedSet<ListBlobsResponse>) factory.create( BoundedSortedSet<ListBlobsResponse> result = (BoundedSortedSet<ListBlobsResponse>) factory
injector.getInstance(ContainerNameEnumerationResultsHandler.class)).parse(is); .create(injector.getInstance(ContainerNameEnumerationResultsHandler.class))
.parse(is);
assertEquals(result, list); assertEquals(result, list);
} }

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.azure.storage.domain; package org.jclouds.azure.storage.domain;
import java.util.List; import java.util.SortedSet;
/** /**
* *
@ -68,7 +68,7 @@ public class BoundedTreeSet<T> extends org.jclouds.rest.BoundedTreeSet<T> implem
+ maxResults + ", prefix=" + prefix + "]"; + maxResults + ", prefix=" + prefix + "]";
} }
public BoundedTreeSet(List<T> contents, String prefix, String marker, int maxResults, public BoundedTreeSet(SortedSet<T> contents, String prefix, String marker, int maxResults,
String nextMarker) { String nextMarker) {
super(contents, prefix, marker, maxResults); super(contents, prefix, marker, maxResults);
this.nextMarker = nextMarker; this.nextMarker = nextMarker;

View File

@ -30,7 +30,7 @@ import java.net.URI;
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
public class QueueMetadata { public class QueueMetadata implements Comparable<QueueMetadata> {
private final String name; private final String name;
private final URI url; private final URI url;
@ -83,4 +83,7 @@ public class QueueMetadata {
return url; return url;
} }
public int compareTo(QueueMetadata o) {
return (this == o) ? 0 : getName().compareTo(o.getName());
}
} }

View File

@ -24,16 +24,16 @@
package org.jclouds.azure.storage.queue.xml; package org.jclouds.azure.storage.queue.xml;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.SortedSet;
import java.util.List; import java.util.TreeSet;
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;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.azure.storage.queue.domain.QueueMetadata;
import org.jclouds.http.functions.ParseSax;
/** /**
* Parses the following XML document: * Parses the following XML document:
* <p/> * <p/>
@ -45,7 +45,7 @@ import javax.inject.Inject;
public class AccountNameEnumerationResultsHandler extends public class AccountNameEnumerationResultsHandler extends
ParseSax.HandlerWithResult<BoundedSortedSet<QueueMetadata>> { ParseSax.HandlerWithResult<BoundedSortedSet<QueueMetadata>> {
private List<QueueMetadata> metadata = new ArrayList<QueueMetadata>(); private SortedSet<QueueMetadata> metadata = new TreeSet<QueueMetadata>();
private String prefix; private String prefix;
private String marker; private String marker;
private int maxResults; private int maxResults;

View File

@ -28,13 +28,13 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.BoundedSortedSet;
import org.jclouds.azure.storage.domain.BoundedTreeSet;
import org.jclouds.azure.storage.queue.domain.QueueMetadata; import org.jclouds.azure.storage.queue.domain.QueueMetadata;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedSet;
/** /**
* Tests behavior of {@code ParseFlavorListFromGsonResponseTest} * Tests behavior of {@code ParseFlavorListFromGsonResponseTest}
@ -47,11 +47,15 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/test_list_queues.xml"); InputStream is = getClass().getResourceAsStream("/test_list_queues.xml");
BoundedSortedSet<QueueMetadata> list = new BoundedTreeSet<QueueMetadata>(ImmutableList.of( BoundedSortedSet<QueueMetadata> list = new BoundedTreeSet<QueueMetadata>(ImmutableSortedSet
new QueueMetadata("q1", URI.create("http://myaccount.queue.core.windows.net/q1")), .of(
new QueueMetadata("q2", URI.create("http://myaccount.queue.core.windows.net/q2")), new QueueMetadata("q1", URI
new QueueMetadata("q3", URI.create("http://myaccount.queue.core.windows.net/q3"))), .create("http://myaccount.queue.core.windows.net/q1")),
"q", null, 3, "q4"); 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");
BoundedSortedSet<QueueMetadata> result = (BoundedSortedSet<QueueMetadata>) factory.create( BoundedSortedSet<QueueMetadata> result = (BoundedSortedSet<QueueMetadata>) factory.create(
injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is);
assertEquals(result, list); assertEquals(result, list);
@ -60,10 +64,13 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testApplyInputStreamWithOptions() { public void testApplyInputStreamWithOptions() {
InputStream is = getClass().getResourceAsStream("/test_list_queues_options.xml"); InputStream is = getClass().getResourceAsStream("/test_list_queues_options.xml");
BoundedSortedSet<QueueMetadata> list = new BoundedTreeSet<QueueMetadata>(ImmutableList.of( BoundedSortedSet<QueueMetadata> list = new BoundedTreeSet<QueueMetadata>(ImmutableSortedSet
new QueueMetadata("q4", URI.create("http://myaccount.queue.core.windows.net/q4")), .of(
new QueueMetadata("q5", URI.create("http://myaccount.queue.core.windows.net/q5"))), new QueueMetadata("q4", URI
"q", "q4", 3, null); .create("http://myaccount.queue.core.windows.net/q4")),
new QueueMetadata("q5", URI
.create("http://myaccount.queue.core.windows.net/q5"))), "q",
"q4", 3, null);
BoundedSortedSet<QueueMetadata> result = (BoundedSortedSet<QueueMetadata>) factory.create( BoundedSortedSet<QueueMetadata> result = (BoundedSortedSet<QueueMetadata>) factory.create(
injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is); injector.getInstance(AccountNameEnumerationResultsHandler.class)).parse(is);

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.rest; package org.jclouds.rest;
import java.util.List; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> { public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> {
@ -34,7 +34,7 @@ public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T>
protected final String marker; protected final String marker;
protected final int maxResults; protected final int maxResults;
public BoundedTreeSet(List<T> contents, String prefix, String marker, int maxResults) { public BoundedTreeSet(SortedSet<T> contents, String prefix, String marker, int maxResults) {
this.addAll(contents); this.addAll(contents);
this.prefix = prefix; this.prefix = prefix;
this.marker = marker; this.marker = marker;