Issue 86: refactored code up to storage level for create options and metadata listing

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1882 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-09-03 17:53:46 +00:00
parent 6373d05d2f
commit 6a8c3d160c
12 changed files with 204 additions and 126 deletions

View File

@ -32,10 +32,12 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.options.CreateContainerOptions;
import org.jclouds.azure.storage.blob.xml.AccountNameEnumerationResultsHandler;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.azure.storage.filters.SharedKeyAuthentication;
import org.jclouds.azure.storage.options.CreateOptions;
import org.jclouds.azure.storage.options.ListOptions;
import org.jclouds.azure.storage.reference.AzureStorageHeaders;
import org.jclouds.rest.Header;
@ -71,7 +73,7 @@ public interface AzureBlobConnection {
@XMLResponseParser(AccountNameEnumerationResultsHandler.class)
@Path("/")
@Query(key = "comp", value = "list")
ContainerMetadataList listContainers(ListOptions... listOptions);
MetadataList<ContainerMetadata> listContainers(ListOptions... listOptions);
/**
* The Create Container operation creates a new container under the specified account. If the
@ -121,7 +123,7 @@ public interface AzureBlobConnection {
@PUT
@Path("$root")
@Query(key = "restype", value = "container")
boolean createRootContainer(CreateContainerOptions... options);// TODO public is not supported!
boolean createRootContainer(CreateOptions... options);
/**
*

View File

@ -3,9 +3,9 @@ package org.jclouds.azure.storage.blob;
import org.jclouds.cloud.CloudContext;
/**
* Represents an authenticated context to Cloud Files.
* Represents an authenticated context to Azure Blob Service.
*
* @see <a href="http://www.rackspacecloud.com/cf-devguide-20090311.pdf" />
* @see <a href="http://msdn.microsoft.com/en-us/library/dd135733.aspx" />
* @see AzureBlobConnection
* @see CloudContext
* @author Adrian Cole

View File

@ -1,9 +1,6 @@
package org.jclouds.azure.storage.blob.options;
import java.util.Map.Entry;
import org.jclouds.azure.storage.reference.AzureStorageHeaders;
import org.jclouds.http.options.BaseHttpRequestOptions;
import org.jclouds.azure.storage.options.CreateOptions;
import com.google.common.collect.Multimap;
@ -14,7 +11,7 @@ import com.google.common.collect.Multimap;
* mutator (if needed):
* <p/>
* <code>
* import static org.jclouds.azure.storage.blob.options.PutBucketOptions.Builder.*
* import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.*
* import org.jclouds.azure.storage.blob.AzureBlobConnection;
* <p/>
* AzureBlobConnection connection = // get connection
@ -24,9 +21,14 @@ import com.google.common.collect.Multimap;
* @see <a href="http://msdn.microsoft.com/en-us/library/dd179466.aspx" />
* @author Adrian Cole
*/
public class CreateContainerOptions extends BaseHttpRequestOptions {
public class CreateContainerOptions extends CreateOptions {
public static final CreateContainerOptions NONE = new CreateContainerOptions();
@Override
public CreateContainerOptions withMetadata(Multimap<String, String> metadata) {
return (CreateContainerOptions) super.withMetadata(metadata);
}
/**
* Indicates whether a container may be accessed publicly
*/
@ -35,23 +37,6 @@ public class CreateContainerOptions extends BaseHttpRequestOptions {
return this;
}
/**
* A name-value pair to associate with the container as metadata.
*
* Note that these are stored at the server under the prefix: x-ms-meta-
*/
public CreateContainerOptions withMetadata(Multimap<String, String> metadata) {
for (Entry<String, String> entry : metadata.entries()) {
if (entry.getKey().startsWith(AzureStorageHeaders.USER_METADATA_PREFIX))
headers.put(entry.getKey(), entry.getValue());
else
headers
.put(AzureStorageHeaders.USER_METADATA_PREFIX + entry.getKey(), entry
.getValue());
}
return this;
}
public static class Builder {
/**
@ -67,7 +52,7 @@ public class CreateContainerOptions extends BaseHttpRequestOptions {
*/
public static CreateContainerOptions withMetadata(Multimap<String, String> metadata) {
CreateContainerOptions options = new CreateContainerOptions();
return options.withMetadata(metadata);
return (CreateContainerOptions) options.withMetadata(metadata);
}
}

View File

@ -28,7 +28,7 @@ import java.util.ArrayList;
import java.util.List;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService;
@ -45,7 +45,7 @@ import com.google.inject.Inject;
* @author Adrian Cole
*/
public class AccountNameEnumerationResultsHandler extends
ParseSax.HandlerWithResult<ContainerMetadataList> {
ParseSax.HandlerWithResult<MetadataList<ContainerMetadata>> {
private List<ContainerMetadata> containerMetadata = new ArrayList<ContainerMetadata>();
private String prefix;
@ -65,8 +65,9 @@ public class AccountNameEnumerationResultsHandler extends
this.dateParser = dateParser;
}
public ContainerMetadataList getResult() {
return new ContainerMetadataList(prefix, marker, maxResults, containerMetadata, nextMarker);
public MetadataList<ContainerMetadata> getResult() {
return new MetadataList<ContainerMetadata>(prefix, marker, maxResults, containerMetadata,
nextMarker);
}
public void endElement(String uri, String name, String qName) {
@ -74,10 +75,13 @@ public class AccountNameEnumerationResultsHandler extends
maxResults = Integer.parseInt(currentText.toString().trim());
} else if (qName.equals("Marker")) {
marker = currentText.toString().trim();
marker = (marker.equals("")) ? null : marker;
} else if (qName.equals("Prefix")) {
prefix = currentText.toString().trim();
prefix = (prefix.equals("")) ? null : prefix;
} else if (qName.equals("NextMarker")) {
nextMarker = currentText.toString().trim();
nextMarker = (nextMarker.equals("")) ? null : nextMarker;
} else if (qName.equals("Container")) {
containerMetadata.add(new ContainerMetadata(currentUrl, currentLastModified, currentETag));
currentUrl = null;

View File

@ -1,6 +1,7 @@
package org.jclouds.azure.storage.blob.xml;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.azure.storage.xml.AzureStorageParserFactory;
import org.jclouds.http.functions.ParseSax;
@ -17,12 +18,12 @@ import com.google.inject.Provider;
public class AzureBlobParserFactory extends AzureStorageParserFactory {
@Inject
private GenericParseFactory<ContainerMetadataList> parseContainerMetadataListFactory;
private GenericParseFactory<MetadataList<ContainerMetadata>> parseContainerMetadataListFactory;
@Inject
Provider<AccountNameEnumerationResultsHandler> containerMetaListHandlerProvider;
public ParseSax<ContainerMetadataList> createContainerMetadataListParser() {
public ParseSax<MetadataList<ContainerMetadata>> createContainerMetadataListParser() {
return parseContainerMetadataListFactory.create(containerMetaListHandlerProvider.get());
}
}

View File

@ -1,7 +1,8 @@
package org.jclouds.azure.storage.blob.xml.config;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.xml.AccountNameEnumerationResultsHandler;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.azure.storage.xml.AzureStorageParserFactory;
import org.jclouds.azure.storage.xml.config.AzureStorageParserModule;
import org.jclouds.command.ConfiguresResponseTransformer;
@ -17,13 +18,13 @@ import com.google.inject.assistedinject.FactoryProvider;
*/
@ConfiguresResponseTransformer
public class AzureBlobParserModule extends AzureStorageParserModule {
protected final TypeLiteral<AzureStorageParserFactory.GenericParseFactory<ContainerMetadataList>> accountNameEnumerationResultsHandler = new TypeLiteral<AzureStorageParserFactory.GenericParseFactory<ContainerMetadataList>>() {
protected final TypeLiteral<AzureStorageParserFactory.GenericParseFactory<MetadataList<ContainerMetadata>>> accountNameEnumerationResultsHandler = new TypeLiteral<AzureStorageParserFactory.GenericParseFactory<MetadataList<ContainerMetadata>>>() {
};
@Override
protected void bindParserImplementationsToReturnTypes() {
super.bindParserImplementationsToReturnTypes();
bind(new TypeLiteral<ParseSax.HandlerWithResult<ContainerMetadataList>>() {
bind(new TypeLiteral<ParseSax.HandlerWithResult<MetadataList<ContainerMetadata>>>() {
}).to(AccountNameEnumerationResultsHandler.class);
}
@ -32,7 +33,7 @@ public class AzureBlobParserModule extends AzureStorageParserModule {
super.bindCallablesThatReturnParseResults();
bind(accountNameEnumerationResultsHandler).toProvider(
FactoryProvider.newFactory(accountNameEnumerationResultsHandler,
new TypeLiteral<ParseSax<ContainerMetadataList>>() {
new TypeLiteral<ParseSax<MetadataList<ContainerMetadata>>>() {
}));
}

View File

@ -8,8 +8,9 @@ import java.net.URL;
import java.security.SecureRandom;
import org.jclouds.azure.storage.AzureStorageResponseException;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.options.CreateContainerOptions;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.azure.storage.options.ListOptions;
import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.http.HttpResponseException;
@ -48,9 +49,9 @@ public class AzureBlobConnectionLiveTest {
@Test
public void testListContainers() throws Exception {
ContainerMetadataList response = connection.listContainers();
MetadataList<ContainerMetadata> response = connection.listContainers();
assert null != response;
long initialContainerCount = response.getContainerMetadata().size();
long initialContainerCount = response.getMetadata().size();
assertTrue(initialContainerCount >= 0);
}
@ -73,9 +74,9 @@ public class AzureBlobConnectionLiveTest {
throw e;
}
}
ContainerMetadataList response = connection.listContainers();
MetadataList<ContainerMetadata> response = connection.listContainers();
assert null != response;
long containerCount = response.getContainerMetadata().size();
long containerCount = response.getMetadata().size();
assertTrue(containerCount >= 1);
// TODO ... check to see the container actually exists
}
@ -128,10 +129,10 @@ public class AzureBlobConnectionLiveTest {
@Test
public void testListContainersWithOptions() throws Exception {
ContainerMetadataList response = connection.listContainers(ListOptions.Builder.prefix(
privateContainer).maxResults(1));
MetadataList<ContainerMetadata> response = connection.listContainers(ListOptions.Builder
.prefix(privateContainer).maxResults(1));
assert null != response;
long initialContainerCount = response.getContainerMetadata().size();
long initialContainerCount = response.getMetadata().size();
assertTrue(initialContainerCount >= 0);
assertEquals(privateContainer, response.getPrefix());
assertEquals(1, response.getMaxResults());

View File

@ -12,6 +12,7 @@ import javax.ws.rs.HttpMethod;
import org.jclouds.azure.storage.blob.options.CreateContainerOptions;
import org.jclouds.azure.storage.blob.xml.config.AzureBlobParserModule;
import org.jclouds.azure.storage.options.CreateOptions;
import org.jclouds.azure.storage.options.ListOptions;
import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
@ -45,6 +46,8 @@ public class AzureBlobConnectionTest {
.getClass();
private static final Class<? extends CreateContainerOptions[]> createContainerOptionsVarargsClass = new CreateContainerOptions[] {}
.getClass();
private static final Class<? extends CreateOptions[]> createOptionsVarargsClass = new CreateOptions[] {}
.getClass();
public void testListContainers() throws SecurityException, NoSuchMethodException {
Method method = AzureBlobConnection.class
@ -142,7 +145,7 @@ public class AzureBlobConnectionTest {
public void testCreateRootContainer() throws SecurityException, NoSuchMethodException {
Method method = AzureBlobConnection.class.getMethod("createRootContainer",
createContainerOptionsVarargsClass);
createOptionsVarargsClass);
URI endpoint = URI.create("http://localhost");
HttpRequest httpMethod = processor.createRequest(endpoint, method, new Object[] {});
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
@ -176,7 +179,7 @@ public class AzureBlobConnectionTest {
public void testCreateRootContainerOptions() throws SecurityException, NoSuchMethodException {
Method method = AzureBlobConnection.class.getMethod("createRootContainer",
createContainerOptionsVarargsClass);
createOptionsVarargsClass);
URI endpoint = URI.create("http://localhost");
HttpRequest httpMethod = processor.createRequest(endpoint, method,
new Object[] { withPublicAcl().withMetadata(ImmutableMultimap.of("foo", "bar")) });

View File

@ -29,7 +29,7 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.azure.storage.blob.domain.ContainerMetadata;
import org.jclouds.azure.storage.blob.domain.ContainerMetadataList;
import org.jclouds.azure.storage.domain.MetadataList;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseSax;
import org.testng.annotations.Test;
@ -46,30 +46,11 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/test_list_containers.xml");
ContainerMetadataList list = new ContainerMetadataList(null, null, 3, ImmutableList.of(
new ContainerMetadata(URI.create("http://myaccount.blob.core.windows.net/audio"),
dateService.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/images"), dateService
.rfc822DateParse("Wed, 14 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C1EEEC")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/textfiles"), dateService
.rfc822DateParse("Wed, 15 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7BACAC3"))
), "video");
ParseSax<ContainerMetadataList> parser = parserFactory.createContainerMetadataListParser();
ContainerMetadataList result = parser.parse(is);
assertEquals(result, list);
}
public void testApplyInputStreamWithOptions() {
InputStream is = getClass().getResourceAsStream("/test_list_containers_options.xml");
ContainerMetadataList list = new ContainerMetadataList("prefix", "marker", 1, ImmutableList
.of(new ContainerMetadata(
URI.create("http://myaccount.blob.core.windows.net/audio"), dateService
.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
MetadataList<ContainerMetadata> list = new MetadataList<ContainerMetadata>(null, null, 3,
ImmutableList.of(new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/audio"), dateService
.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/images"), dateService
.rfc822DateParse("Wed, 14 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C1EEEC")), new ContainerMetadata(URI
@ -78,8 +59,30 @@ public class AccountNameEnumerationResultsHandlerTest extends BaseHandlerTest {
.fromHexString("0x8CACB9BD7BACAC3"))
), "video");
ParseSax<ContainerMetadataList> parser = parserFactory.createContainerMetadataListParser();
ContainerMetadataList result = parser.parse(is);
ParseSax<MetadataList<ContainerMetadata>> parser = parserFactory
.createContainerMetadataListParser();
MetadataList<ContainerMetadata> result = parser.parse(is);
assertEquals(result, list);
}
public void testApplyInputStreamWithOptions() {
InputStream is = getClass().getResourceAsStream("/test_list_containers_options.xml");
MetadataList<ContainerMetadata> list = new MetadataList<ContainerMetadata>("prefix",
"marker", 1, ImmutableList.of(new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/audio"), dateService
.rfc822DateParse("Wed, 13 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C6B1B2")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/images"), dateService
.rfc822DateParse("Wed, 14 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7C1EEEC")), new ContainerMetadata(URI
.create("http://myaccount.blob.core.windows.net/textfiles"), dateService
.rfc822DateParse("Wed, 15 Aug 2008 20:39:39 GMT"), HttpUtils
.fromHexString("0x8CACB9BD7BACAC3"))
), "video");
ParseSax<MetadataList<ContainerMetadata>> parser = parserFactory
.createContainerMetadataListParser();
MetadataList<ContainerMetadata> result = parser.parse(is);
assertEquals(result, list);
}
}

View File

@ -21,7 +21,7 @@
* under the License.
* ====================================================================
*/
package org.jclouds.azure.storage.blob.domain;
package org.jclouds.azure.storage.domain;
import java.util.List;
@ -30,36 +30,20 @@ import java.util.List;
* @author Adrian Cole
*
*/
public class ContainerMetadataList {
private String prefix;
private String marker;
private int maxResults;
private List<ContainerMetadata> containerMetadata;
private String nextMarker;
@Override
public String toString() {
return "ContainerMetadataList [containerMetadata=" + containerMetadata + ", marker=" + marker
+ ", maxResults=" + maxResults + ", nextMarker=" + nextMarker + ", prefix=" + prefix
+ "]";
}
public ContainerMetadataList(String prefix, String marker, int maxResults,
List<ContainerMetadata> containerMetadata, String nextMarker) {
this.prefix = prefix;
this.marker = marker;
this.maxResults = maxResults;
this.containerMetadata = containerMetadata;
this.nextMarker = nextMarker;
}
public class MetadataList<T> {
private final String prefix;
private final String marker;
private final int maxResults;
private final List<T> metadata;
private final String nextMarker;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((containerMetadata == null) ? 0 : containerMetadata.hashCode());
result = prime * result + ((marker == null) ? 0 : marker.hashCode());
result = prime * result + maxResults;
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
result = prime * result + ((nextMarker == null) ? 0 : nextMarker.hashCode());
result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
return result;
@ -73,12 +57,7 @@ public class ContainerMetadataList {
return false;
if (getClass() != obj.getClass())
return false;
ContainerMetadataList other = (ContainerMetadataList) obj;
if (containerMetadata == null) {
if (other.containerMetadata != null)
return false;
} else if (!containerMetadata.equals(other.containerMetadata))
return false;
MetadataList<?> other = (MetadataList<?>) obj;
if (marker == null) {
if (other.marker != null)
return false;
@ -86,6 +65,11 @@ public class ContainerMetadataList {
return false;
if (maxResults != other.maxResults)
return false;
if (metadata == null) {
if (other.metadata != null)
return false;
} else if (!metadata.equals(other.metadata))
return false;
if (nextMarker == null) {
if (other.nextMarker != null)
return false;
@ -99,40 +83,35 @@ public class ContainerMetadataList {
return true;
}
public void setPrefix(String prefix) {
@Override
public String toString() {
return "MetadataList [metadata=" + metadata + ", marker=" + marker + ", maxResults="
+ maxResults + ", nextMarker=" + nextMarker + ", prefix=" + prefix + "]";
}
public MetadataList(String prefix, String marker, int maxResults, List<T> metadata,
String nextMarker) {
this.prefix = prefix;
this.marker = marker;
this.maxResults = maxResults;
this.metadata = metadata;
this.nextMarker = nextMarker;
}
public String getPrefix() {
return prefix;
}
public void setMarker(String marker) {
this.marker = marker;
}
public String getMarker() {
return marker;
}
public void setMaxResults(int maxResults) {
this.maxResults = maxResults;
}
public int getMaxResults() {
return maxResults;
}
public void setContainerMetadata(List<ContainerMetadata> containerMetadata) {
this.containerMetadata = containerMetadata;
}
public List<ContainerMetadata> getContainerMetadata() {
return containerMetadata;
}
public void setNextMarker(String nextMarker) {
this.nextMarker = nextMarker;
public List<T> getMetadata() {
return metadata;
}
public String getNextMarker() {

View File

@ -0,0 +1,59 @@
package org.jclouds.azure.storage.options;
import java.util.Map.Entry;
import org.jclouds.azure.storage.reference.AzureStorageHeaders;
import org.jclouds.http.options.BaseHttpRequestOptions;
import com.google.common.collect.Multimap;
/**
* Contains common options supported in the REST API for the Create operation. <h2>
* Usage</h2> The recommended way to instantiate a CreateOptions object is to statically import
* CreateOptions.* and invoke a static creation method followed by an instance mutator (if
* needed):
* <p/>
* <code>
* import static org.jclouds.azure.storage.options.CreateOptions.Builder.*
* import org.jclouds.azure.storage.queue.AzureQueueConnection;
* <p/>
* AzureQueueConnection connection = // get connection
* Multimap<String,String> metadata = // ...
* boolean createdWithPublicAcl = connection.createQueue("containerName", withMetdata(metadata));
* <code> *
*
* @see <a href="http://msdn.microsoft.com/en-us/library/dd179466.aspx" />
* @author Adrian Cole
*/
public class CreateOptions extends BaseHttpRequestOptions {
public static final CreateOptions NONE = new CreateOptions();
/**
* A name-value pair to associate with the container as metadata.
*
* Note that these are stored at the server under the prefix: x-ms-meta-
*/
public CreateOptions withMetadata(Multimap<String, String> metadata) {
for (Entry<String, String> entry : metadata.entries()) {
if (entry.getKey().startsWith(AzureStorageHeaders.USER_METADATA_PREFIX))
headers.put(entry.getKey(), entry.getValue());
else
headers
.put(AzureStorageHeaders.USER_METADATA_PREFIX + entry.getKey(), entry
.getValue());
}
return this;
}
public static class Builder {
/**
* @see CreateOptions#withMetadata(Multimap<String, String>)
*/
public static CreateOptions withMetadata(Multimap<String, String> metadata) {
CreateOptions options = new CreateOptions();
return options.withMetadata(metadata);
}
}
}

View File

@ -0,0 +1,40 @@
package org.jclouds.azure.storage.options;
import static org.testng.Assert.assertEquals;
import org.jclouds.azure.storage.reference.AzureStorageHeaders;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap;
/**
* Tests behavior of {@code CreateOptions}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "azurequeue.CreateOptionsTest")
public class CreateOptionsTest {
public void testMetadata() {
CreateOptions options = new CreateOptions().withMetadata(ImmutableMultimap.of(
"test", "foo"));
assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
AzureStorageHeaders.USER_METADATA_PREFIX + "test"));
}
public void testMetadataAlreadyPrefixed() {
CreateOptions options = new CreateOptions().withMetadata(ImmutableMultimap.of(
AzureStorageHeaders.USER_METADATA_PREFIX + "test", "foo"));
assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
AzureStorageHeaders.USER_METADATA_PREFIX + "test"));
}
public void testMetadataStatic() {
CreateOptions options = CreateOptions.Builder.withMetadata(ImmutableMultimap.of(
"test", "foo"));
assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
AzureStorageHeaders.USER_METADATA_PREFIX + "test"));
}
}