diff --git a/pom.client.xml b/pom.client.xml index 09313c8d9c6bb..3cd12bca3fbdb 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -523,6 +523,7 @@ -snippetpath ${project.basedir}/eventhubs/client/azure-eventhubs/src/samples/java -snippetpath ${project.basedir}/keyvault/client/keys/src/samples/java -snippetpath ${project.basedir}/keyvault/client/secrets/src/samples/java + -snippetpath ${project.basedir}/storage/client/queue/src/samples/java diff --git a/storage/client/pom.xml b/storage/client/pom.xml index 80aa347a87a09..f0e064f22a8a1 100644 --- a/storage/client/pom.xml +++ b/storage/client/pom.xml @@ -86,35 +86,4 @@ test - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - false - false - - - - org.apache.maven.plugins - maven-javadoc-plugin - - false - false - - - - - com.github.spotbugs - spotbugs-maven-plugin - - false - - - - diff --git a/storage/client/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java b/storage/client/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java index 31bf01f4d5cbb..7cc1017b0cf93 100644 --- a/storage/client/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java +++ b/storage/client/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java @@ -85,21 +85,22 @@ private String buildStringToSign(URL requestURL, String httpMethod, Map httpHeaders, final String headerName) { + final String headerValue = httpHeaders.get(headerName); + return headerValue == null ? "" : headerValue; + } } diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java b/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java index eab2a19707d5c..b4edfacce5c54 100644 --- a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java @@ -1,29 +1,535 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. package com.azure.storage.queue; -import com.azure.core.ServiceClient; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.http.rest.VoidResponse; +import com.azure.core.util.Context; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; import com.azure.storage.queue.implementation.AzureQueueStorageBuilder; import com.azure.storage.queue.implementation.AzureQueueStorageImpl; - +import com.azure.storage.queue.models.DequeuedMessage; +import com.azure.storage.queue.models.EnqueuedMessage; +import com.azure.storage.queue.models.MessageIdUpdateHeaders; +import com.azure.storage.queue.models.MessageIdsUpdateResponse; +import com.azure.storage.queue.models.PeekedMessage; +import com.azure.storage.queue.models.QueueGetPropertiesHeaders; +import com.azure.storage.queue.models.QueueMessage; +import com.azure.storage.queue.models.QueueProperties; +import com.azure.storage.queue.models.QueuesGetPropertiesResponse; +import com.azure.storage.queue.models.SignedIdentifier; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.UpdatedMessage; +import java.net.MalformedURLException; import java.net.URL; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * This class provides a client that contains all the operations for interacting with a queue in Azure Storage Queue. + * Operations allowed by the client are creating and deleting the queue, retrieving and updating metadata and access + * policies of the queue, and enqueuing, dequeuing, peeking, updating, and deleting messages. + * + *

Instantiating an Asynchronous Queue Client

+ * + *
+ * QueueAsyncClient client = QueueAsyncClient.builder()
+ *     .connectionString(connectionString)
+ *     .endpoint(endpoint)
+ *     .queueName(queueName)
+ *     .buildAsync();
+ * 
+ * + *

View {@link QueueClientBuilder this} for additional ways to construct the client.

+ * + * @see QueueClientBuilder + * @see QueueClient + * @see SharedKeyCredential + * @see SASTokenCredential + */ +public final class QueueAsyncClient { + private final AzureQueueStorageImpl client; + private final String queueName; + + /** + * Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl#url() endpoint}. + * Each service call goes through the {@link HttpPipeline pipeline} in the {@code client}. + * + * @param client Client that interacts with the service interfaces + * @param queueName Name of the queue + */ + QueueAsyncClient(AzureQueueStorageImpl client, String queueName) { + this.queueName = queueName; + + this.client = new AzureQueueStorageBuilder().pipeline(client.httpPipeline()) + .url(client.url()) + .version(client.version()) + .build(); + } + + /** + * Creates a QueueAsyncClient that sends requests to the storage queue service at {@code endpoint}. + * Each service call goes through the {@code httpPipeline}. + * + * @param endpoint URL for the Storage Queue service + * @param httpPipeline HttpPipeline that the HTTP requests and response flow through + * @param queueName Name of the queue + */ + QueueAsyncClient(URL endpoint, HttpPipeline httpPipeline, String queueName) { + this.queueName = queueName; + + this.client = new AzureQueueStorageBuilder().pipeline(httpPipeline) + .url(endpoint.toString()) + .build(); + } + + /** + * Creates a builder that can configure options for the QueueAsyncClient before creating an instance of it. + * + * @return A new {@link QueueClientBuilder} used create QueueAsyncClient instances. + */ + public static QueueClientBuilder builder() { + return new QueueClientBuilder(); + } + + /** + * @return the URL of the storage queue + */ + public URL getQueueUrl() { + try { + return new URL(client.url()); + } catch (MalformedURLException ex) { + throw new IllegalStateException("Queue URL is malformed"); + } + } + + /** + * Creates a new queue. + * + *

Code Samples

+ * + *

Create a queue

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.create + * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If a queue with the same name already exists in the queue service. + */ + public Mono create() { + return create(null); + } + + /** + * Creates a new queue. + * + *

Code Samples

+ * + *

Create a queue with metadata "queue:metadataMap"

+ * + *
+     * client.create(Collections.singletonMap("queue", "metadataMap"))
+     *     .subscribe(response -> System.out.printf("Create completed with status code %d", response.statusCode()));
+     * 
+ * + * @param metadata Metadata to associate with the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If a queue with the same name and different metadata already exists in the queue service. + */ + public Mono create(Map metadata) { + return client.queues().createWithRestResponseAsync(queueName, null, metadata, null, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Permanently deletes the queue. + * + *

Code Samples

+ * + *

Delete a queue

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.delete + * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono delete() { + return client.queues().deleteWithRestResponseAsync(queueName, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Retrieves metadata and approximate message count of the queue. + * + *

Code Samples

+ * + *

Get the properties of the queue

+ * + *
+     * client.getProperties()
+     *     .subscribe(response -> {
+     *         QueueProperties properties = response.value();
+     *         System.out.printf("Metadata: %s, Approximate message count: %d", properties.metadata(), properties.approximateMessagesCount());
+     *     });
+     * 
+ * + * @return A response containing a {@link QueueProperties} value which contains the metadata and approximate + * messages count of the queue. + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono> getProperties() { + return client.queues().getPropertiesWithRestResponseAsync(queueName, Context.NONE) + .map(this::getQueuePropertiesResponse); + } + + /** + * Sets the metadata of the queue. + * + * Passing in a {@code null} value for metadata will clear the metadata associated with the queue. + * + *

Code Samples

+ * + *

Set the queue's metadata to "queue:metadataMap"

+ * + *
+     * client.setMetadata(Collections.singletonMap("queue", "metadataMap"))
+     *     .subscribe(response -> System.out.printf("Setting metadata completed with status code %d", response.statusCode()));
+     * 
+ * + *

Clear the queue's metadata

+ * + *
+     * client.setMetadata(null)
+     *     .subscribe(response -> System.out.printf("Clearing metadata completed with status code %d", response.statusCode()));
+     * 
+ * + * @param metadata Metadata to set on the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono setMetadata(Map metadata) { + return client.queues().setMetadataWithRestResponseAsync(queueName, null, metadata, null, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Retrieves stored access policies specified on the queue. + * + *

Code Samples

+ * + *

List the stored access policies

+ * + *
+     * client.getAccessPolicy()
+     *     .subscribe(result -> System.out.printf("Access policy %s allows these permissions: %s", result.id(), result.accessPolicy().permission()));
+     * 
+ * + * @return The stored access policies specified on the queue. + * @throws StorageErrorException If the queue doesn't exist + */ + public Flux getAccessPolicy() { + return client.queues().getAccessPolicyWithRestResponseAsync(queueName, Context.NONE) + .flatMapMany(response -> Flux.fromIterable(response.value())); + } -public class QueueAsyncClient extends ServiceClient { - private final String endpoint; - private final AzureQueueStorageImpl generateClient; - private final String apiVersion; + /** + * Sets stored access policies on the queue. + * + *

Code Samples

+ * + *

Set a read only stored access policy

+ * + *
+     * AccessPolicy policy = new AccessPolicy().permission("r")
+     *     .start(OffsetDateTime.now(ZoneOffset.UTC))
+     *     .expiry(OffsetDateTime.now(ZoneOffset.UTC).addDays(10));
+     *
+     * SignedIdentifier permission = new SignedIdentifier().id("mypolicy").accessPolicy(accessPolicy);
+     *
+     * client.setAccessPolicy(Collections.singletonList(permission))
+     *     .subscribe(response -> System.out.printf("Setting access policies completed with status code %d", response.statusCode()));
+     * 
+ * + * @param permissions Access policies to set on the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist, a stored access policy doesn't have all fields filled out, + * or the queue will have more than five policies. + */ + public Mono setAccessPolicy(List permissions) { + return client.queues().setAccessPolicyWithRestResponseAsync(queueName, permissions, null, null, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Deletes all messages in the queue. + * + *

Code Samples

+ * + *

Clear the messages

+ * + *
+     * client.clear()
+     *     .subscribe(response -> System.out.printf("Clearing messages completed with status code %d", response.statusCode()));
+     * 
+ * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono clearMessages() { + return client.messages().clearWithRestResponseAsync(queueName, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Enqueues a message that has a time-to-live of 7 days and is instantly visible. + * + *

Code Samples

+ * + *

Enqueue a message of "Hello, Azure"

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.enqueueMessage#string + * + * @param messageText Message text + * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and + * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata + * about the enqueued message. + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono> enqueueMessage(String messageText) { + return enqueueMessage(messageText, Duration.ofSeconds(0), Duration.ofDays(7)); + } + + /** + * Enqueues a message with a given time-to-live and a timeout period where the message is invisible in the queue. + * + *

Code Samples

+ * + *

Add a message of "Hello, Azure" that has a timeout of 5 seconds

+ * + *
+     * client.enqueueMessage("Hello, Azure", Duration.ofSeconds(5), null)
+     *     .subscribe(response -> {
+     *         EnqueuedMessage enqueuedMessage = response.value();
+     *         System.out.printf("Message %s becomes visible at %s", enqueuedMessage.messageId(), enqueuedMessage.timeNextVisible());
+     *     });
+     * 
+ * + *

Add a message of "Goodbye, Azure" that has a time to live of 5 seconds

+ * + *
+     * client.enqueueMessage("Goodbye, Azure", null, Duration.ofSeconds(5))
+     *     .subscribe(response -> {
+     *         EnqueuedMessage enqueuedMessage = response.value();
+     *         System.out.printf("Message %s expires at %s", enqueuedMessage.messageId(), enqueuedMessage.expirationTime());
+     *     });
+     * 
+ * + * @param messageText Message text + * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. + * If unset the value will default to 0 and the message will be instantly visible. The timeout must be between 0 + * seconds and 7 days. + * @param timeToLive Optional. How long the message will stay alive in the queue in seconds. If unset the value will + * default to 7 days, if -1 is passed the message will not expire. The time to live must be -1 or any positive number. + * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and + * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata + * about the enqueued message. + * @throws StorageErrorException If the queue doesn't exist or the {@code visibilityTimeout} or {@code timeToLive} + * are outside of the allowed limits. + */ + public Mono> enqueueMessage(String messageText, Duration visibilityTimeout, Duration timeToLive) { + Integer visibilityTimeoutInSeconds = (visibilityTimeout == null) ? null : (int) visibilityTimeout.getSeconds(); + Integer timeToLiveInSeconds = (timeToLive == null) ? null : (int) timeToLive.getSeconds(); + QueueMessage message = new QueueMessage().messageText(messageText); + + return client.messages().enqueueWithRestResponseAsync(queueName, message, visibilityTimeoutInSeconds, timeToLiveInSeconds, null, null, Context.NONE) + .map(response -> new SimpleResponse<>(response, response.value().get(0))); + } + + /** + * Retrieves the first message in the queue and hides it from other operations for 30 seconds. + * + *

Code Samples

+ * + *

Dequeue a message

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.dequeueMessages + * + * @return The first {@link DequeuedMessage} in the queue, it contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message, additionally it contains other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist + */ + public Flux dequeueMessages() { + return dequeueMessages(1, Duration.ofSeconds(30)); + } + + /** + * Retrieves up to the maximum number of messages from the queue and hides them from other operations for 30 seconds. + * + *

Code Samples

+ * + *

Dequeue up to 5 messages

+ * + *
+     * client.dequeueMessages(5)
+     *     .subscribe(result -> System.out.printf("Dequeued %s and it becomes visible at %s" result.messageId(), result.timeNextVisible()));
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested + * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 + * messages. + * @return Up to {@code maxMessages} {@link DequeuedMessage DequeuedMessages} from the queue. Each DequeuedMessage contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message and other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} is outside of the allowed bounds + */ + public Flux dequeueMessages(Integer maxMessages) { + return dequeueMessages(maxMessages, Duration.ofSeconds(30)); + } + + /** + * Retrieves up to the maximum number of messages from the queue and hides them from other operations for the + * timeout period. + * + *

Code Samples

+ * + *

Dequeue up to 5 messages and give them a 60 second timeout period

+ * + *
+     * client.dequeueMessages(5, Duration.ofSeconds(60))
+     *     .subscribe(result -> System.out.printf("Dequeued %s and it becomes visible at %s" result.messageId(), result.timeNextVisible()));
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested + * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 + * messages. + * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. + * If left empty the dequeued messages will be invisible for 30 seconds. The timeout must be between 1 second and 7 days. + * @return Up to {@code maxMessages} {@link DequeuedMessage DequeuedMessages} from the queue. Each DeqeuedMessage contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message and other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} or {@code visibilityTimeout} is + * outside of the allowed bounds + */ + public Flux dequeueMessages(Integer maxMessages, Duration visibilityTimeout) { + Integer visibilityTimeoutInSeconds = (visibilityTimeout == null) ? null : (int) visibilityTimeout.getSeconds(); + return client.messages().dequeueWithRestResponseAsync(queueName, maxMessages, visibilityTimeoutInSeconds, null, null, Context.NONE) + .flatMapMany(response -> Flux.fromIterable(response.value())); + } + + /** + * Peeks the first message in the queue. + * + * Peeked messages don't contain the necessary information needed to interact with the message nor will it hide + * messages from other operations on the queue. + * + *

Code Samples

+ * + *

Peek the first message

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.peekMessages + * + * @return A {@link PeekedMessage} that contains metadata about the message. + */ + public Flux peekMessages() { + return peekMessages(null); + } + + /** + * Peek messages from the front of the queue up to the maximum number of messages. + * + * Peeked messages don't contain the necessary information needed to interact with the message nor will it hide + * messages from other operations on the queue. + * + *

Code Samples

+ * + *

Peek up to the first five messages

+ * + *
+     * client.peekMessages(5)
+     *     .subscribe(result -> System.out.printf("Peeked message %s has been dequeued %d times", result.messageId(), result.dequeueCount()));
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to peek, if there are less messages exist in the queue than requested + * all the messages will be peeked. If left empty only 1 message will be peeked, the allowed range is 1 to 32 + * messages. + * @return Up to {@code maxMessages} {@link PeekedMessage PeekedMessages} from the queue. Each PeekedMessage contains + * metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} is outside of the allowed bounds + */ + public Flux peekMessages(Integer maxMessages) { + return client.messages().peekWithRestResponseAsync(queueName, maxMessages, null, null, Context.NONE) + .flatMapMany(response -> Flux.fromIterable(response.value())); + } - private QueueAsyncClient(URL endpoint, HttpPipeline httpPipeline) { - super(httpPipeline); - this.endpoint = endpoint.toString(); - this.generateClient = new AzureQueueStorageBuilder().pipeline(httpPipeline).url(this.endpoint).build(); - this.apiVersion = this.generateClient.version(); + /** + * Updates the specific message in the queue with a new message and resets the visibility timeout. + * + *

Code Samples

+ * + *

Dequeue the first message and update it to "Hello again, Azure" and hide it for 5 seconds

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.updateMessage + * + * @param messageText Updated value for the message + * @param messageId Id of the message to update + * @param popReceipt Unique identifier that must match for the message to be updated + * @param visibilityTimeout The timeout period for how long the message is invisible in the queue in seconds. The + * timeout period must be between 1 second and 7 days. + * @return A {@link UpdatedMessage} that contains the new {@link UpdatedMessage#popReceipt() popReceipt} to interact + * with the message, additionally contains the updated metadata about the message. + * @throws StorageErrorException If the queue or messageId don't exist, the popReceipt doesn't match on the message, + * or the {@code visibilityTimeout} is outside the allowed bounds + */ + public Mono> updateMessage(String messageText, String messageId, String popReceipt, Duration visibilityTimeout) { + QueueMessage message = new QueueMessage().messageText(messageText); + return client.messageIds().updateWithRestResponseAsync(queueName, messageId, message, popReceipt, (int) visibilityTimeout.getSeconds(), Context.NONE) + .map(this::getUpdatedMessageResponse); } /** - * Creates a appendBlobClientBuilder that can configure options for the SecretAsyncClient before creating an instance of it. - * @return A new appendBlobClientBuilder to create a SecretAsyncClient from. + * Deletes the specified message in the queue + * + *

Code Samples

+ * + *

Delete the first message

+ * + * @codesnippet com.azure.storage.queue.queueAsyncClient.deleteMessage + * + * @param messageId Id of the message to deleted + * @param popReceipt Unique identifier that must match for the message to be deleted + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue or messageId don't exist or the popReceipt doesn't match on the message + */ + public Mono deleteMessage(String messageId, String popReceipt) { + return client.messageIds().deleteWithRestResponseAsync(queueName, messageId, popReceipt, Context.NONE) + .map(VoidResponse::new); + } + + /* + * Maps the HTTP headers returned from the service to the expected response type + * @param response Service response + * @return Mapped response + */ + private Response getQueuePropertiesResponse(QueuesGetPropertiesResponse response) { + QueueGetPropertiesHeaders propertiesHeaders = response.deserializedHeaders(); + QueueProperties properties = new QueueProperties(propertiesHeaders.metadata(), propertiesHeaders.approximateMessagesCount()); + return new SimpleResponse<>(response, properties); + } + + /* + * Maps the HTTP headers returned from the service to the expected response type + * @param response Service response + * @return Mapped response */ - public static QueueAsyncClientBuilder builder() { - return new QueueAsyncClientBuilder(); + private Response getUpdatedMessageResponse(MessageIdsUpdateResponse response) { + MessageIdUpdateHeaders headers = response.deserializedHeaders(); + UpdatedMessage updatedMessage = new UpdatedMessage(headers.popReceipt(), headers.timeNextVisible()); + return new SimpleResponse<>(response, updatedMessage); } } diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClientBuilder.java b/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClientBuilder.java deleted file mode 100644 index b76c9c63e8700..0000000000000 --- a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClientBuilder.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.azure.storage.queue; - -public class QueueAsyncClientBuilder { - -} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueClient.java b/storage/client/src/main/java/com/azure/storage/queue/QueueClient.java new file mode 100644 index 0000000000000..133b241e6d0c3 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueClient.java @@ -0,0 +1,448 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.VoidResponse; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.queue.models.DequeuedMessage; +import com.azure.storage.queue.models.EnqueuedMessage; +import com.azure.storage.queue.models.PeekedMessage; +import com.azure.storage.queue.models.QueueProperties; +import com.azure.storage.queue.models.SignedIdentifier; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.UpdatedMessage; +import java.net.URL; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** + * This class provides a client that contains all the operations for interacting with a queue in Azure Storage Queue. + * Operations allowed by the client are creating and deleting the queue, retrieving and updating metadata and access + * policies of the queue, and enqueuing, dequeuing, peeking, updating, and deleting messages. + * + *

Instantiating an Synchronous Queue Client

+ * + *
+ * QueueClient client = QueueClient.builder()
+ *     .connectionString(connectionString)
+ *     .endpoint(endpoint)
+ *     .queueName(queueName)
+ *     .build();
+ * 
+ * + *

View {@link QueueClientBuilder this} for additional ways to construct the client.

+ * + * @see QueueClientBuilder + * @see QueueAsyncClient + * @see SharedKeyCredential + * @see SASTokenCredential + */ +public final class QueueClient { + private final QueueAsyncClient client; + + /** + * Creates a QueueClient that wraps a QueueAsyncClient and blocks requests. + * + * @param client QueueAsyncClient that is used to send requests + */ + QueueClient(QueueAsyncClient client) { + this.client = client; + } + + /** + * Creates a builder that can configure options for the QueueClient before creating an instance of it. + * + * @return A new {@link QueueClientBuilder} used create QueueClient instances. + */ + public static QueueClientBuilder builder() { + return new QueueClientBuilder(); + } + + /** + * @return the URL of the storage queue + */ + public URL getQueueUrl() { + return client.getQueueUrl(); + } + + /** + * Creates a new queue. + * + *

Code Samples

+ * + *

Create a queue

+ * + *@codesnippet com.azure.storage.queue.queueClient.create + * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If a queue with the same name already exists in the queue service. + */ + public VoidResponse create() { + return create(null); + } + + /** + * Creates a new queue. + * + *

Code Samples

+ * + *

Create a queue with metadata "queue:metadataMap"

+ * + *
+     * VoidResponse response = client.create(Collections.singletonMap("queue", "metadataMap"));
+     * System.out.printf("Create completed with status code %d", response.statusCode());
+     * 
+ * + * @param metadata Metadata to associate with the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If a queue with the same name and different metadata already exists in the queue service. + */ + public VoidResponse create(Map metadata) { + return client.create(metadata).block(); + } + + /** + * Permanently deletes the queue. + * + *

Code Samples

+ * + *

Delete a queue

+ * + * @codesnippet com.azure.storage.queue.queueClient.delete + * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public VoidResponse delete() { + return client.delete().block(); + } + + /** + * Retrieves metadata and approximate message count of the queue. + * + *

Code Samples

+ * + *

Get the properties of the queue

+ * + *
+     * QueueProperties properties = client.getProperties().value();
+     * System.out.printf("Metadata: %s, Approximate message count: %d", properties.metadata(), properties.approximateMessagesCount());
+     * 
+ * + * @return A response containing a {@link QueueProperties} value which contains the metadata and approximate + * messages count of the queue. + * @throws StorageErrorException If the queue doesn't exist + */ + public Response getProperties() { + return client.getProperties().block(); + } + + /** + * Sets the metadata of the queue. + * + * Passing in a {@code null} value for metadata will clear the metadata associated with the queue. + * + *

Code Samples

+ * + *

Set the queue's metadata to "queue:metadataMap"

+ * + *
+     * VoidResponse response = client.setMetadata(Collections.singletonMap("queue", "metadataMap"));
+     * System.out.printf("Setting metadata completed with status code %d", response.statusCode());
+     * 
+ * + *

Clear the queue's metadata

+ * + *
+     * VoidResponse response = client.setMetadata(null);
+     * System.out.printf("Clearing metadata completed with status code %d", response.statusCode());
+     * 
+ * + * @param metadata Metadata to set on the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public VoidResponse setMetadata(Map metadata) { + return client.setMetadata(metadata).block(); + } + + /** + * Retrieves stored access policies specified on the queue. + * + *

Code Samples

+ * + *

List the stored access policies

+ * + *
+     * for (SignedIdentifier permission : client.getAccessPolicy()) {
+     *     System.out.printf("Access policy %s allows these permissions: %s", permission.id(), permission.accessPolicy().permission());
+     * }
+     *
+     * @return The stored access policies specified on the queue.
+     * @throws StorageErrorException If the queue doesn't exist
+     */
+    public Iterable getAccessPolicy() {
+        return client.getAccessPolicy().toIterable();
+    }
+
+    /**
+     * Sets stored access policies on the queue.
+     *
+     * 

Code Samples

+ * + *

Set a read only stored access policy

+ * + *
+     * AccessPolicy policy = new AccessPolicy().permission("r")
+     *     .start(OffsetDateTime.now(ZoneOffset.UTC))
+     *     .expiry(OffsetDateTime.now(ZoneOffset.UTC).addDays(10));
+     *
+     * SignedIdentifier permission = new SignedIdentifier().id("mypolicy").accessPolicy(accessPolicy);
+     *
+     * VoidResponse response = client.setAccessPolicy(Collections.singletonList(permission));
+     * System.out.printf("Setting access policies completed with status code %d", response.statusCode());
+     * 
+ * + * @param permissions Access policies to set on the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist, a stored access policy doesn't have all fields filled out, + * or the queue will have more than five policies. + */ + public VoidResponse setAccessPolicy(List permissions) { + return client.setAccessPolicy(permissions).block(); + } + + /** + * Deletes all messages in the queue. + * + *

Code Samples

+ * + *

Clear the messages

+ * + *
+     * VoidResponse response = client.clear();
+     * System.out.printf("Clearing messages completed with status code %d", response.statusCode());
+     * 
+ * + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public VoidResponse clearMessages() { + return client.clearMessages().block(); + } + + /** + * Enqueues a message that has a time-to-live of 7 days and is instantly visible. + * + *

Code Samples

+ * + *

Enqueue a message of "Hello, Azure"

+ * + * @codesnippet com.azure.storage.queue.queueClient.enqueueMessage#string + * + * @param messageText Message text + * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and + * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata + * about the enqueued message. + * @throws StorageErrorException If the queue doesn't exist + */ + public Response enqueueMessage(String messageText) { + return enqueueMessage(messageText, Duration.ofSeconds(0), Duration.ofDays(7)); + } + + /** + * Enqueues a message with a given time-to-live and a timeout period where the message is invisible in the queue. + * + *

Code Samples

+ * + *

Add a message of "Hello, Azure" that has a timeout of 5 seconds

+ * + *
+     * EnqueuedMessage enqueuedMessage = client.enqueueMessage("Hello, Azure", Duration.ofSeconds(5), null);
+     * System.out.printf("Message %s becomes visible at %s", enqueuedMessage.messageId(), enqueuedMessage.timeNextVisible());
+     * 
+ * + *

Add a message of "Goodbye, Azure" that has a time to live of 5 seconds

+ * + *
+     * EnqueuedMessage enqueuedMessage = client.enqueueMessage("Goodbye, Azure", null, Duration.ofSeconds(5));
+     * System.out.printf("Message %s expires at %s", enqueuedMessage.messageId(), enqueuedMessage.expirationTime());
+     * 
+ * + * @param messageText Message text + * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. + * If unset the value will default to 0 and the message will be instantly visible. The timeout must be between 0 + * seconds and 7 days. + * @param timeToLive Optional. How long the message will stay alive in the queue in seconds. If unset the value will + * default to 7 days, if -1 is passed the message will not expire. The time to live must be -1 or any positive number. + * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and + * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata + * about the enqueued message. + * @throws StorageErrorException If the queue doesn't exist or the {@code visibilityTimeout} or {@code timeToLive} + * are outside of the allowed limits. + */ + public Response enqueueMessage(String messageText, Duration visibilityTimeout, Duration timeToLive) { + return client.enqueueMessage(messageText, visibilityTimeout, timeToLive).block(); + } + + /** + * Retrieves the first message in the queue and hides it from other operations for 30 seconds. + * + *

Code Samples

+ * + *

Dequeue a message

+ * + * @codesnippet com.azure.storage.queue.queueClient.dequeueMessages + * + * @return The first {@link DequeuedMessage} in the queue, it contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message, additionally it contains other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist + */ + public Iterable dequeueMessages() { + return dequeueMessages(1, Duration.ofSeconds(30)); + } + + /** + * Retrieves up to the maximum number of messages from the queue and hides them from other operations for 30 seconds. + * + *

Code Samples

+ * + *

Dequeue up to 5 messages

+ * + *
+     * for (DequeuedMessage dequeuedMessage : client.dequeue(5)) {
+     *     System.out.printf("Dequeued %s and it becomes visible at %s", dequeuedMessage.messageId(), dequeuedMessage.timeNextVisible());
+     * }
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested + * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 + * messages. + * @return Up to {@code maxMessages} {@link DequeuedMessage DequeuedMessages} from the queue. Each DequeuedMessage contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message and other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} is outside of the allowed bounds + */ + public Iterable dequeueMessages(Integer maxMessages) { + return dequeueMessages(maxMessages, Duration.ofSeconds(30)); + } + + /** + * Retrieves up to the maximum number of messages from the queue and hides them from other operations for the + * timeout period. + * + *

Code Samples

+ * + *

Dequeue up to 5 messages and give them a 60 second timeout period

+ * + *
+     * for (DequeuedMessage dequeuedMessage : client.dequeue(5, Duration.ofSeconds(60))) {
+     *     System.out.printf("Dequeued %s and it becomes visible at %s", dequeuedMessage.messageId(), dequeuedMessage.timeNextVisible());
+     * }
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested + * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 + * messages. + * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. + * If left empty the dequeued messages will be invisible for 30 seconds. The timeout must be between 1 second and 7 days. + * @return Up to {@code maxMessages} {@link DequeuedMessage DequeuedMessages} from the queue. Each DeqeuedMessage contains + * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact + * with the message and other metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} or {@code visibilityTimeout} is + * outside of the allowed bounds + */ + public Iterable dequeueMessages(Integer maxMessages, Duration visibilityTimeout) { + return client.dequeueMessages(maxMessages, visibilityTimeout).toIterable(); + } + + /** + * Peeks the first message in the queue. + * + * Peeked messages don't contain the necessary information needed to interact with the message nor will it hide + * messages from other operations on the queue. + * + *

Code Samples

+ * + *

Peek the first message

+ * + * @codesnippet com.azure.storage.queue.queueClient.peekMessages + * + * @return A {@link PeekedMessage} that contains metadata about the message. + */ + public Iterable peekMessages() { + return peekMessages(null); + } + + /** + * Peek messages from the front of the queue up to the maximum number of messages. + * + * Peeked messages don't contain the necessary information needed to interact with the message nor will it hide + * messages from other operations on the queue. + * + *

Code Samples

+ * + *

Peek up to the first five messages

+ * + *
+     * for (PeekedMessage peekedMessage : client.peekMessages(5)) {
+     *     System.out.printf("Peeked message %s has been dequeued %d times", peekedMessage.messageId(), peekedMessage.dequeueCount());
+     * }
+     * 
+ * + * @param maxMessages Optional. Maximum number of messages to peek, if there are less messages exist in the queue than requested + * all the messages will be peeked. If left empty only 1 message will be peeked, the allowed range is 1 to 32 + * messages. + * @return Up to {@code maxMessages} {@link PeekedMessage PeekedMessages} from the queue. Each PeekedMessage contains + * metadata about the message. + * @throws StorageErrorException If the queue doesn't exist or {@code maxMessages} is outside of the allowed bounds + */ + public Iterable peekMessages(Integer maxMessages) { + return client.peekMessages(maxMessages).toIterable(); + } + + /** + * Updates the specific message in the queue with a new message and resets the visibility timeout. + * + *

Code Samples

+ * + *

Dequeue the first message and update it to "Hello again, Azure" and hide it for 5 seconds

+ * + * @codesnippet com.azure.storage.queue.queueClient.updateMessage + * + * @param messageText Updated value for the message + * @param messageId Id of the message to update + * @param popReceipt Unique identifier that must match for the message to be updated + * @param visibilityTimeout The timeout period for how long the message is invisible in the queue in seconds. The + * timeout period must be between 1 second and 7 days. + * @return A {@link UpdatedMessage} that contains the new {@link UpdatedMessage#popReceipt() popReceipt} to interact + * with the message, additionally contains the updated metadata about the message. + * @throws StorageErrorException If the queue or messageId don't exist, the popReceipt doesn't match on the message, + * or the {@code visibilityTimeout} is outside the allowed bounds + */ + public Response updateMessage(String messageText, String messageId, String popReceipt, Duration visibilityTimeout) { + return client.updateMessage(messageText, messageId, popReceipt, visibilityTimeout).block(); + } + + /** + * Deletes the specified message in the queue + * + *

Code Samples

+ * + *

Delete the first message

+ * + * @codesnippet com.azure.storage.queue.queueClient.deleteMessage + * + * @param messageId Id of the message to deleted + * @param popReceipt Unique identifier that must match for the message to be deleted + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue or messageId don't exist or the popReceipt doesn't match on the message + */ + public VoidResponse deleteMessage(String messageId, String popReceipt) { + return client.deleteMessage(messageId, popReceipt).block(); + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueClientBuilder.java b/storage/client/src/main/java/com/azure/storage/queue/QueueClientBuilder.java new file mode 100644 index 0000000000000..af8ef3b9893ab --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueClientBuilder.java @@ -0,0 +1,357 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.implementation.http.UrlBuilder; +import com.azure.core.implementation.http.policy.spi.HttpPolicyProviders; +import com.azure.core.implementation.util.ImplUtils; +import com.azure.core.util.configuration.Configuration; +import com.azure.core.util.configuration.ConfigurationManager; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.common.policy.SASTokenCredentialPolicy; +import com.azure.storage.common.policy.SharedKeyCredentialPolicy; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.HashMap; + +/** + * This class provides a fluent builder API to help aid the configuration and instantiation of the {@link QueueClient QueueClients} + * and {@link QueueAsyncClient QueueAsyncClients}, calling {@link QueueClientBuilder#build() build} constructs an + * instance of QueueClient and calling {@link QueueClientBuilder#buildAsync() buildAsync} constructs an instance of + * QueueAsyncClient. + * + *

The client needs the endpoint of the Azure Storage Queue service, name of the queue, and authorization credentials. + * {@link QueueClientBuilder#endpoint(String) endpoint} gives the builder the endpoint and may give the builder the + * {@link QueueClientBuilder#queueName(String) queueName} and a {@link SASTokenCredential} that authorizes the client.

+ * + *

Instantiating a synchronous Queue Service Client with SAS token

+ * @codesnippet com.azure.storage.queue.queueClient.instantiation.sastoken + * + *

Instantiating an Asynchronous Queue Service Client with SAS token

+ * @codesnippet com.azure.storage.queue.queueAsyncClient.instantiation.sastoken + * + *

If the {@code endpoint} doesn't contain the queue name or {@code SASTokenCredential} they may be set using + * {@link QueueClientBuilder#queueName(String) queueName} and {@link QueueClientBuilder#credential(SASTokenCredential) credential}.

+ * + *
+ * QueueClient client = QueueClient.builder()
+ *     .endpoint(endpointWithoutQueueNameOrSASTokenQueryParams)
+ *     .queueName(queueName)
+ *     .credential(SASTokenCredential.fromQuery(SASTokenQueryParams))
+ *     .build();
+ * 
+ * + *
+ * QueueAsyncClient client = QueueAsyncClient.builder()
+ *     .endpoint(endpointWithoutQueueNameOrSASTokenQueryParams)
+ *     .queueName(queueName)
+ *     .credential(SASTokenCredential.fromQuery(SASTokenQueryParams))
+ *     .buildAsync();
+ * 
+ * + *

Another way to authenticate the client is using a {@link SharedKeyCredential}. To create a SharedKeyCredential + * a connection string from the Storage Queue service must be used. Set the SharedKeyCredential with + * {@link QueueClientBuilder#connectionString(String) connectionString}. If the builder has both a SASTokenCredential and + * SharedKeyCredential the SharedKeyCredential will be preferred when authorizing requests sent to the service.

+ * + *

Instantiating a synchronous Queue Client with connection string.

+ * @codesnippet com.azure.storage.queue.queueClient.instantiation.connectionstring + * + *

Instantiating an Asynchronous Queue Client with connection string.

+ * @codesnippet com.azure.storage.queue.queueAsyncClient.instantiation.connectionstring + * + * @see QueueClient + * @see QueueAsyncClient + * @see SASTokenCredential + * @see SharedKeyCredential + */ +public final class QueueClientBuilder { + private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); + private final List policies; + + private URL endpoint; + private String queueName; + private SASTokenCredential sasTokenCredential; + private SharedKeyCredential sharedKeyCredential; + private HttpClient httpClient; + private HttpPipeline pipeline; + private HttpLogDetailLevel logLevel; + private RetryPolicy retryPolicy; + private Configuration configuration; + + QueueClientBuilder() { + retryPolicy = new RetryPolicy(); + logLevel = HttpLogDetailLevel.NONE; + policies = new ArrayList<>(); + + configuration = ConfigurationManager.getConfiguration(); + } + + /** + * Creates a {@link QueueClient} based on options set in the builder. Every time {@code build()} is + * called a new instance of {@link QueueClient} is created. + * + *

+ * If {@link QueueClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline}, + * {@link QueueClientBuilder#endpoint(String) endpoint}, and + * {@link QueueClientBuilder#queueName(String) queueName} are used to create the {@link QueueAsyncClient client}. + * All other builder settings are ignored. + *

+ * + * @return A QueueClient with the options set from the builder. + * @throws NullPointerException If {@code endpoint} or {@code queueName} have not been set. + * @throws IllegalStateException If neither a {@link SharedKeyCredential} or {@link SASTokenCredential} has been set. + */ + public QueueClient build() { + return new QueueClient(buildAsync()); + } + + /** + * Creates a {@link QueueAsyncClient} based on options set in the builder. Every time {@code buildAsync()} is + * called a new instance of {@link QueueAsyncClient} is created. + * + *

+ * If {@link QueueClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline}, + * {@link QueueClientBuilder#endpoint(String) endpoint}, and + * {@link QueueClientBuilder#queueName(String) queueName} are used to create the {@link QueueAsyncClient client}. + * All other builder settings are ignored. + *

+ * + * @return A QueueAsyncClient with the options set from the builder. + * @throws NullPointerException If {@code endpoint} or {@code queueName} have not been set. + * @throws IllegalStateException If neither a {@link SharedKeyCredential} or {@link SASTokenCredential} has been set. + */ + public QueueAsyncClient buildAsync() { + Objects.requireNonNull(endpoint); + Objects.requireNonNull(queueName); + + if (pipeline != null) { + return new QueueAsyncClient(endpoint, pipeline, queueName); + } + + if (sasTokenCredential == null && sharedKeyCredential == null) { + throw new IllegalArgumentException("Credentials are required for authorization"); + } + + // Closest to API goes first, closest to wire goes last. + final List policies = new ArrayList<>(); + + policies.add(new UserAgentPolicy(QueueConfiguration.NAME, QueueConfiguration.VERSION, configuration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddDatePolicy()); + + if (sharedKeyCredential != null) { + policies.add(new SharedKeyCredentialPolicy(sharedKeyCredential)); + } else { + policies.add(new SASTokenCredentialPolicy(sasTokenCredential)); + } + + HttpPolicyProviders.addBeforeRetryPolicies(policies); + + policies.add(retryPolicy); + + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(logLevel)); + + HttpPipeline pipeline = HttpPipeline.builder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .build(); + + return new QueueAsyncClient(endpoint, pipeline, queueName); + } + + /** + * Sets the endpoint for the Azure Storage Queue instance that the client will interact with. + * + *

The first path segment, if the endpoint contains path segments, will be assumed to be the name of the queue + * that the client will interact with.

+ * + *

Query parameters of the endpoint will be parsed using {@link SASTokenCredential#fromQuery(String) fromQuery} in an + * attempt to generate a {@link SASTokenCredential} to authenticate requests sent to the service.

+ * + * @param endpoint The URL of the Azure Storage Queue instance to send service requests to and receive responses from. + * @return the updated QueueClientBuilder object + * @throws IllegalArgumentException If {@code endpoint} isn't a proper URL + */ + public QueueClientBuilder endpoint(String endpoint) { + Objects.requireNonNull(endpoint); + try { + UrlBuilder urlBuilder = UrlBuilder.parse(endpoint); + URL fullURL = new URL(endpoint); + this.endpoint = new URL(fullURL.getProtocol() + "://" + fullURL.getHost()); + + // Attempt to get the queue name from the URL passed + String[] pathSegments = fullURL.getPath().split("/", 2); + if (pathSegments.length == 2 && !ImplUtils.isNullOrEmpty(pathSegments[1])) { + this.queueName = pathSegments[1]; + } + + // Attempt to get the SAS token from the URL passed + SASTokenCredential credential = SASTokenCredential.fromQuery(fullURL.getQuery()); + if (credential != null) { + this.sasTokenCredential = credential; + } + } catch (MalformedURLException ex) { + throw new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed."); + } + + Objects.requireNonNull(endpoint); + try { + URL fullURL = new URL(endpoint); + this.endpoint = new URL(fullURL.getProtocol() + "://" + fullURL.getHost()); + + // Attempt to get the queue name from the URL passed + String[] pathSegments = fullURL.getPath().split("/", 2); + if (pathSegments.length == 2 && !ImplUtils.isNullOrEmpty(pathSegments[1])) { + this.queueName = pathSegments[1]; + } + + // Attempt to get the SAS token from the URL passed + SASTokenCredential credential = SASTokenCredential.fromQuery(fullURL.getQuery()); + if (credential != null) { + this.sasTokenCredential = credential; + } + } catch (MalformedURLException ex) { + throw new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed."); + } + + return this; + } + + /** + * Sets the name of the queue that the client will interact with. + * + * @param queueName Name of the queue + * @return the updated QueueClientBuilder object + * @throws NullPointerException If {@code queueName} is {@code null}. + */ + public QueueClientBuilder queueName(String queueName) { + this.queueName = Objects.requireNonNull(queueName); + return this; + } + + /** + * Sets the {@link SASTokenCredential} used to authenticate requests sent to the Queue service. + * + * @param credential SAS token credential generated from the Storage account that authorizes requests + * @return the updated QueueClientBuilder object + * @throws NullPointerException If {@code credential} is {@code null}. + */ + public QueueClientBuilder credential(SASTokenCredential credential) { + this.sasTokenCredential = Objects.requireNonNull(credential); + return this; + } + + /** + * Creates a {@link SharedKeyCredential} from the {@code connectionString} used to authenticate requests sent to the + * Queue service. + * + * @param connectionString Connection string from the Access Keys section in the Storage account + * @return the updated QueueClientBuilder object + * @throws NullPointerException If {@code connectionString} is {@code null}. + */ + public QueueClientBuilder connectionString(String connectionString) { + Objects.requireNonNull(connectionString); + this.sharedKeyCredential = SharedKeyCredential.fromConnectionString(connectionString); + Objects.requireNonNull(connectionString); + this.sharedKeyCredential = SharedKeyCredential.fromConnectionString(connectionString); + getEndPointFromConnectionString(connectionString); + return this; + } + + private void getEndPointFromConnectionString(String connectionString) { + HashMap connectionStringPieces = new HashMap<>(); + for (String connectionStringPiece : connectionString.split(";")) { + String[] kvp = connectionStringPiece.split("=", 2); + connectionStringPieces.put(kvp[0].toLowerCase(), kvp[1]); + } + String accountName = connectionStringPieces.get(ACCOUNT_NAME); + try { + this.endpoint = new URL(String.format("https://%s.queue.core.windows.net", accountName)); + } catch (MalformedURLException e) { + throw new IllegalArgumentException(String.format("There is no valid endpoint for the connection string. " + + "Connection String: %s", connectionString)); + } + } + /** + * Sets the HTTP client to use for sending and receiving requests to and from the service. + * + * @param httpClient The HTTP client to use for requests. + * @return The updated QueueClientBuilder object. + * @throws NullPointerException If {@code httpClient} is {@code null}. + */ + public QueueClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient); + return this; + } + + /** + * Adds a policy to the set of existing policies that are executed after the {@link RetryPolicy}. + * + * @param pipelinePolicy The retry policy for service requests. + * @return The updated QueueClientBuilder object. + * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. + */ + public QueueClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { + Objects.requireNonNull(pipelinePolicy); + this.policies.add(pipelinePolicy); + return this; + } + + /** + * Sets the logging level for HTTP requests and responses. + * + * @param logLevel The amount of logging output when sending and receiving HTTP requests/responses. + * @return The updated QueueClientBuilder object. + */ + public QueueClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel) { + this.logLevel = logLevel; + return this; + } + + /** + * Sets the HTTP pipeline to use for the service client. + * + * If {@code pipeline} is set, all other settings are ignored, aside from {@link QueueClientBuilder#endpoint(String) endpoint} + * and {@link QueueClientBuilder#queueName(String) queueName} when building clients. + * + * @param pipeline The HTTP pipeline to use for sending service requests and receiving responses. + * @return The updated QueueClientBuilder object. + * @throws NullPointerException If {@code pipeline} is {@code null}. + */ + public QueueClientBuilder pipeline(HttpPipeline pipeline) { + Objects.requireNonNull(pipeline); + this.pipeline = pipeline; + return this; + } + + /** + * Sets the configuration store that is used during construction of the service client. + * + * The default configuration store is a clone of the {@link ConfigurationManager#getConfiguration() global + * configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction. + * + * @param configuration The configuration store used to + * @return The updated QueueClientBuilder object. + */ + public QueueClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueConfiguration.java b/storage/client/src/main/java/com/azure/storage/queue/QueueConfiguration.java new file mode 100644 index 0000000000000..1de39c548c262 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueConfiguration.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +/* + * Gets the SDK information for this library component. + */ +class QueueConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + static final String NAME = "storage-queue"; + static final String VERSION = "1.0.0-SNAPSHOT"; +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java new file mode 100644 index 0000000000000..c43903dd141aa --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java @@ -0,0 +1,350 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.http.rest.VoidResponse; +import com.azure.core.util.Context; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.queue.implementation.AzureQueueStorageBuilder; +import com.azure.storage.queue.implementation.AzureQueueStorageImpl; +import com.azure.storage.queue.models.CorsRule; +import com.azure.storage.queue.models.ListQueuesIncludeType; +import com.azure.storage.queue.models.ListQueuesSegmentResponse; +import com.azure.storage.queue.models.QueueItem; +import com.azure.storage.queue.models.QueuesSegmentOptions; +import com.azure.storage.queue.models.ServicesListQueuesSegmentResponse; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.StorageServiceProperties; +import com.azure.storage.queue.models.StorageServiceStats; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * This class provides a client that contains all the operations for interacting with a queue account in Azure Storage. + * Operations allowed by the client are creating, listing, and deleting queues, retrieving and updating properties of the account, + * and retrieving statistics of the account. + * + *

Instantiating an Asynchronous Queue Service Client

+ * + *
+ * QueueServiceAsyncClient client = QueueServiceAsyncClient.builder()
+ *     .connectionString(connectionString)
+ *     .endpoint(endpoint)
+ *     .buildAsync();
+ * 
+ * + *

View {@link QueueServiceClientBuilder this} for additional ways to construct the client.

+ * + * @see QueueServiceClientBuilder + * @see QueueServiceClient + * @see SharedKeyCredential + * @see SASTokenCredential + */ +public final class QueueServiceAsyncClient { + private final AzureQueueStorageImpl client; + + /** + * Creates a QueueServiceAsyncClient that sends requests to the storage account at {@code endpoint}. + * Each service call goes through the {@code httpPipeline}. + * + * @param endpoint URL for the Storage Queue service + * @param httpPipeline HttpPipeline that the HTTP requests and response flow through + */ + QueueServiceAsyncClient(URL endpoint, HttpPipeline httpPipeline) { + this.client = new AzureQueueStorageBuilder().pipeline(httpPipeline) + .url(endpoint.toString()) + .build(); + } + + /** + * Creates a builder that can configure options for the QueueServiceAsyncClient before creating an instance of it. + * + * @return A new {@link QueueServiceClientBuilder} used create QueueServiceAsyncClient instances. + */ + public static QueueServiceClientBuilder builder() { + return new QueueServiceClientBuilder(); + } + + /** + * @return the URL of the storage queue + */ + public URL getQueueServiceUrl() { + try { + return new URL(client.url()); + } catch (MalformedURLException ex) { + throw new IllegalStateException("Storage account URL is malformed"); + } + } + + /** + * Constructs a QueueAsyncClient that interacts with the specified queue. + * + * This will not create the queue in the storage account if it doesn't exist. + * + * @param queueName Name of the queue + * @return QueueAsyncClient that interacts with the specified queue + */ + public QueueAsyncClient getQueueAsyncClient(String queueName) { + return new QueueAsyncClient(client, queueName); + } + + /** + * Creates a queue in the storage account with the specified name and returns a QueueAsyncClient to interact + * with it. + * + *

Code Samples

+ * + *

Create the queue "test"

+ * + * @codesnippet com.azure.storage.queue.queueServiceAsyncClient.createQueue#string + * + * @param queueName Name of the queue + * @return A response containing the QueueAsyncClient and the status of creating the queue + * @throws StorageErrorException If a queue with the same name and different metadata already exists + */ + public Mono> createQueue(String queueName) { + return createQueue(queueName, null); + } + + /** + * Creates a queue in the storage account with the specified name and metadata and returns a QueueAsyncClient to + * interact with it. + * + *

Code Samples

+ * + *

Create the queue "test" with metadata "queue:metadata"

+ * + *
+     * client.createQueue("test", Collections.singletonMap("queue", "metadata"))
+     *     .subscribe(response -> System.out.printf("Creating the queue completed with status code %d", response.statusCode()));
+     * 
+ * + * @param queueName Name of the queue + * @param metadata Metadata to associate with the queue + * @return A response containing the QueueAsyncClient and the status of creating the queue + * @throws StorageErrorException If a queue with the same name and different metadata already exists + */ + public Mono> createQueue(String queueName, Map metadata) { + QueueAsyncClient queueAsyncClient = new QueueAsyncClient(client, queueName); + + return queueAsyncClient.create(metadata) + .map(response -> new SimpleResponse<>(response, queueAsyncClient)); + } + + /** + * Deletes a queue in the storage account + * + *

Code Samples

+ * + *

Delete the queue "test"

+ * + * @codesnippet com.azure.storage.queue.queueServiceAsyncClient.deleteQueue#string + * + * @param queueName Name of the queue + * @return A response that only contains headers and response status code + * @throws StorageErrorException If the queue doesn't exist + */ + public Mono deleteQueue(String queueName) { + return new QueueAsyncClient(client, queueName).delete(); + } + + /** + * Lists all queues in the storage account without their metadata. + * + *

Code Samples

+ * + *

List all queues in the account

+ * + * @codesnippet com.azure.storage.queue.queueServiceAsyncClient.listQueues + * + * @return {@link QueueItem Queues} in the storage account + */ + public Flux listQueues() { + return listQueues(null, null); + } + + /** + * Lists the queues in the storage account that pass the filter. + * + * Pass true to {@link QueuesSegmentOptions#includeMetadata(boolean) includeMetadata} to have metadata returned for + * the queues. + * + *

Code Samples

+ * + *

List all queues and their metadata in the account

+ * + *
+     * client.listQueues(new QueuesSegmentOptions().includeMetadata(true))
+     *     .subscribe(result -> System.out.printf("Queue %s exists in the account and has metadata %s", result.name(), result.metadata()));
+     * 
+ * + *

List all queues that begin with "azure"

+ * + *
+     * client.listQueues(new QueuesSegmentOptions().prefix("azure"))
+     *     .subscribe(result -> System.out.printf("Queue %s exists in the account", result.name()));
+     * 
+ * + * @param options Options for listing queues + * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements + */ + public Flux listQueues(QueuesSegmentOptions options) { + return listQueues(null, options); + } + + /** + * Lists the queues in the storage account that pass the filter starting at the specified marker. + * + * Pass true to {@link QueuesSegmentOptions#includeMetadata(boolean) includeMetadata} to have metadata returned for + * the queues. + * + * @param marker Starting point to list the queues + * @param options Options for listing queues + * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements + */ + Flux listQueues(String marker, QueuesSegmentOptions options) { + String prefix = null; + Integer maxResults = null; + final List include = new ArrayList<>(); + + if (options != null) { + prefix = options.prefix(); + maxResults = options.maxResults(); + if (options.includeMetadata()) { + include.add(ListQueuesIncludeType.fromString(ListQueuesIncludeType.METADATA.toString())); + } + } + + Mono result = client.services() + .listQueuesSegmentWithRestResponseAsync(prefix, marker, maxResults, include, null, null, Context.NONE); + + return result.flatMapMany(response -> extractAndFetchQueues(response, include, Context.NONE)); + } + + /* + * Helper function used to auto-enumerate through paged responses + */ + private Flux listQueues(ServicesListQueuesSegmentResponse response, List include, Context context) { + ListQueuesSegmentResponse value = response.value(); + Mono result = client.services() + .listQueuesSegmentWithRestResponseAsync(value.prefix(), value.marker(), value.maxResults(), include, null, null, context); + + return result.flatMapMany(r -> extractAndFetchQueues(r, include, context)); + } + + /* + * Helper function used to auto-enumerate though paged responses + */ + private Publisher extractAndFetchQueues(ServicesListQueuesSegmentResponse response, List include, Context context) { + String nextPageLink = response.value().nextMarker(); + if (nextPageLink == null) { + return Flux.fromIterable(response.value().queueItems()); + } + + return Flux.fromIterable(response.value().queueItems()).concatWith(listQueues(response, include, context)); + } + + /** + * Retrieves the properties of the storage account's Queue service. The properties range from storage analytics and + * metric to CORS (Cross-Origin Resource Sharing). + * + *

Code Samples

+ * + *

Retrieve Queue service properties

+ * + *
+     * client.getProperties()
+     *     .subscribe(response -> {
+     *         StorageServiceProperties properties = response.value();
+     *         System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b", properties.hourMetrics().enabled(), properties.minuteMetrics().enabled());
+     *     });
+     * 
+ * + * @return Storage account Queue service properties + */ + public Mono> getProperties() { + return client.services().getPropertiesWithRestResponseAsync(Context.NONE) + .map(response -> new SimpleResponse<>(response, response.value())); + } + + /** + * Sets the properties for the storage account's Queue service. The properties range from storage analytics and + * metric to CORS (Cross-Origin Resource Sharing). + * + * To maintain the CORS in the Queue service pass a {@code null} value for {@link StorageServiceProperties#cors() CORS}. + * To disable all CORS in the Queue service pass an empty list for {@link StorageServiceProperties#cors() CORS}. + * + *

Code Sample

+ * + *

Clear CORS in the Queue service

+ * + *
+     * StorageServiceProperties properties = client.getProperties().block().value();
+     * properties.cors(Collections.emptyList());
+     *
+     * client.setProperties(properties)
+     *     .subscribe(response -> System.out.printf("Setting Queue service properties completed with status code %d", response.statusCode()));
+     * 
+ * + *

Enable Minute and Hour Metrics

+ * + *
+     * StorageServiceProperties properties = client.getProperties().block().value();
+     * properties.minuteMetrics().enabled(true);
+     * properties.hourMetrics().enabled(true);
+     *
+     * client.setProperties(properties)
+     *     .subscribe(response -> System.out.printf("Setting Queue service properties completed with status code %d", response.statusCode()));
+     * 
+ * + * @param properties Storage account Queue service properties + * @return A response that only contains headers and response status code + * @throws StorageErrorException When one of the following is true + *
    + *
  • A CORS rule is missing one of its fields
  • + *
  • More than five CORS rules will exist for the Queue service
  • + *
  • Size of all CORS rules exceeds 2KB
  • + *
  • + * Length of {@link CorsRule#allowedHeaders() allowed headers}, {@link CorsRule#exposedHeaders() exposed headers}, + * or {@link CorsRule#allowedOrigins() allowed origins} exceeds 256 characters. + *
  • + *
  • {@link CorsRule#allowedMethods() Allowed methods} isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or PUT
  • + *
+ */ + public Mono setProperties(StorageServiceProperties properties) { + return client.services().setPropertiesWithRestResponseAsync(properties, Context.NONE) + .map(VoidResponse::new); + } + + /** + * Retrieves the geo replication information about the Queue service. + * + *

Code Samples

+ * + *

Retrieve the geo replication information

+ * + *
+     * client.getStatistics()
+     *     .subscribe(response -> {
+     *         StorageServiceStats stats = response.value();
+     *         System.out.printf("Geo replication status: %s, Last synced: %s", stats.geoReplication.status(), stats.geoReplication().lastSyncTime());
+     *     });
+     * 
+ * + * @return The geo replication information about the Queue service + */ + public Mono> getStatistics() { + return client.services().getStatisticsWithRestResponseAsync(Context.NONE) + .map(response -> new SimpleResponse<>(response, response.value())); + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClient.java b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClient.java new file mode 100644 index 0000000000000..796624730f073 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClient.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.http.rest.VoidResponse; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.queue.models.CorsRule; +import com.azure.storage.queue.models.QueueItem; +import com.azure.storage.queue.models.QueuesSegmentOptions; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.StorageServiceProperties; +import com.azure.storage.queue.models.StorageServiceStats; +import java.net.URL; +import java.util.Map; + +/** + * This class provides a client that contains all the operations for interacting with a queue account in Azure Storage. + * Operations allowed by the client are creating, listing, and deleting queues, retrieving and updating properties of the account, + * and retrieving statistics of the account. + * + *

Instantiating an Synchronous Queue Service Client

+ * + *
+ * QueueServiceClient client = QueueServiceClient.builder()
+ *     .connectionString(connectionString)
+ *     .endpoint(endpoint)
+ *     .build();
+ * 
+ * + *

View {@link QueueServiceClientBuilder this} for additional ways to construct the client.

+ * + * @see QueueServiceClientBuilder + * @see QueueServiceAsyncClient + * @see SharedKeyCredential + * @see SASTokenCredential + */ +public final class QueueServiceClient { + private final QueueServiceAsyncClient client; + + /** + * Creates a QueueServiceClient that wraps a QueueServiceAsyncClient and blocks requests. + * + * @param client QueueServiceAsyncClient that is used to send requests + */ + QueueServiceClient(QueueServiceAsyncClient client) { + this.client = client; + } + + /** + * Creates a builder that can configure options for the QueueServiceClient before creating an instance of it. + * + * @return A new {@link QueueServiceClientBuilder} used create QueueServiceClient instances. + */ + public static QueueServiceClientBuilder builder() { + return new QueueServiceClientBuilder(); + } + + /** + * @return the URL of the storage queue + */ + public URL getQueueServiceUrl() { + return client.getQueueServiceUrl(); + } + + /** + * Constructs a QueueClient that interacts with the specified queue. + * + * This will not create the queue in the storage account if it doesn't exist. + * + * @param queueName Name of the queue + * @return QueueClient that interacts with the specified queue + */ + public QueueClient getQueueClient(String queueName) { + return new QueueClient(client.getQueueAsyncClient(queueName)); + } + + /** + * Creates a queue in the storage account with the specified name and returns a QueueClient to interact with it. + * + *

Code Samples

+ * + *

Create the queue "test"

+ * + * @codesnippet com.azure.storage.queue.queueServiceClient.createQueue#string + * + * @param queueName Name of the queue + * @return A response containing the QueueClient and the status of creating the queue + * @throws StorageErrorException If a queue with the same name and different metadata already exists + */ + public Response createQueue(String queueName) { + return createQueue(queueName, null); + } + + /** + * Creates a queue in the storage account with the specified name and metadata and returns a QueueClient to + * interact with it. + * + *

Code Samples

+ * + *

Create the queue "test" with metadata "queue:metadata"

+ * + *
+     * Response<QueueClient> = client.createQueue("test", Collections.singletonMap("queue", "metadata"));
+     * System.out.printf("Creating the queue completed with status code %d", response.statusCode());
+     * 
+ * + * @param queueName Name of the queue + * @param metadata Metadata to associate with the queue + * @return A response containing the QueueClient and the status of creating the queue + * @throws StorageErrorException If a queue with the same name and different metadata already exists + */ + public Response createQueue(String queueName, Map metadata) { + Response response = client.createQueue(queueName, metadata).block(); + + return new SimpleResponse<>(response, new QueueClient(response.value())); + } + + /** + * Deletes a queue in the storage account + * + *

Code Samples

+ * + *

Delete the queue "test"

+ * + * @codesnippet com.azure.storage.queue.queueServiceClient.deleteQueue#string + * + * @param queueName Name of the queue + * @return A response containing the status of deleting the queue + * @throws StorageErrorException If the queue doesn't exist + */ + public VoidResponse deleteQueue(String queueName) { + return client.deleteQueue(queueName).block(); + } + + /** + * Lists all queues in the storage account without their metadata. + * + *

Code Samples

+ * + *

List all queues in the account

+ * + * @codesnippet com.azure.storage.queue.queueServiceClient.listQueues + * + * @return {@link QueueItem Queues} in the storage account + */ + public Iterable listQueues() { + return listQueues(null, null); + } + + /** + * Lists the queues in the storage account that pass the filter. + * + * Pass true to {@link QueuesSegmentOptions#includeMetadata(boolean) includeMetadata} to have metadata returned for + * the queues. + * + *

Code Samples

+ * + *

List all queues and their metadata in the account

+ * + *
+     * for (QueueItem queue : client.listQueues(new QueuesSegmentOptions().includeMetadata(true))) {
+     *     System.out.printf("Queue %s exists in the account and has metadata %s", queue.name(), queue.metadata());
+     * }
+     * 
+ * + *

List all queues that begin with "azure"

+ * + *
+     * for (QueueItem queue : client.listQueues(new QueuesSegmentOptions().prefix("azure"))) {
+     *     System.out.printf("Queue %s exists in the account", queue.name());
+     * }
+     * 
+ * + * @param options Options for listing queues + * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements + */ + public Iterable listQueues(QueuesSegmentOptions options) { + return listQueues(null, options); + } + + /** + * Lists the queues in the storage account that pass the filter starting at the specified marker. + * + * Pass true to {@link QueuesSegmentOptions#includeMetadata(boolean) includeMetadata} to have metadata returned for + * the queues. + * + * @param marker Starting point to list the queues + * @param options Options for listing queues + * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements + */ + Iterable listQueues(String marker, QueuesSegmentOptions options) { + return client.listQueues(marker, options).toIterable(); + } + + /** + * Retrieves the properties of the storage account's Queue service. The properties range from storage analytics and + * metric to CORS (Cross-Origin Resource Sharing). + * + *

Code Samples

+ * + *

Retrieve Queue service properties

+ * + *
+     * StorageServiceProperties properties = client.getProperties().value();
+     * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b", properties.hourMetrics().enabled(), properties.minuteMetrics().enabled());
+     * 
+ * + * @return Storage account Queue service properties + */ + public Response getProperties() { + return client.getProperties().block(); + } + + /** + * Sets the properties for the storage account's Queue service. The properties range from storage analytics and + * metric to CORS (Cross-Origin Resource Sharing). + * + * To maintain the CORS in the Queue service pass a {@code null} value for {@link StorageServiceProperties#cors() CORS}. + * To disable all CORS in the Queue service pass an empty list for {@link StorageServiceProperties#cors() CORS}. + * + *

Code Sample

+ * + *

Clear CORS in the Queue service

+ * + *
+     * StorageServiceProperties properties = client.getProperties().value();
+     * properties.cors(Collections.emptyList());
+     *
+     * VoidResponse response = client.setProperties(properties);
+     * System.out.printf("Setting Queue service properties completed with status code %d", response.statusCode());
+     * 
+ * + *

Enable Minute and Hour Metrics

+ * + *
+     * StorageServiceProperties properties = client.getProperties().value();
+     * properties.minuteMetrics().enabled(true);
+     * properties.hourMetrics().enabled(true);
+     *
+     * VoidResponse response = client.setProperties(properties);
+     * System.out.printf("Setting Queue service properties completed with status code %d", response.statusCode());
+     * 
+ * + * @param properties Storage account Queue service properties + * @return A response that only contains headers and response status code + * @throws StorageErrorException When one of the following is true + *
    + *
  • A CORS rule is missing one of its fields
  • + *
  • More than five CORS rules will exist for the Queue service
  • + *
  • Size of all CORS rules exceeds 2KB
  • + *
  • + * Length of {@link CorsRule#allowedHeaders() allowed headers}, {@link CorsRule#exposedHeaders() exposed headers}, + * or {@link CorsRule#allowedOrigins() allowed origins} exceeds 256 characters. + *
  • + *
  • {@link CorsRule#allowedMethods() Allowed methods} isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or PUT
  • + *
+ */ + public VoidResponse setProperties(StorageServiceProperties properties) { + return client.setProperties(properties).block(); + } + + /** + * Retrieves the geo replication information about the Queue service. + * + *

Code Samples

+ * + *

Retrieve the geo replication information

+ * + *
+     * StorageServiceStats stats = client.getStatistics().value();
+     * System.out.printf("Geo replication status: %s, Last synced: %s", stats.geoReplication.status(), stats.geoReplication().lastSyncTime());
+     * 
+ * + * @return The geo replication information about the Queue service + */ + public Response getStatistics() { + return client.getStatistics().block(); + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java new file mode 100644 index 0000000000000..394530c4684c3 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.implementation.http.policy.spi.HttpPolicyProviders; +import com.azure.core.util.configuration.Configuration; +import com.azure.core.util.configuration.ConfigurationManager; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.common.policy.SASTokenCredentialPolicy; +import com.azure.storage.common.policy.SharedKeyCredentialPolicy; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * This class provides a fluent builder API to help aid the configuration and instantiation of the {@link QueueServiceClient queueServiceClients} + * and {@link QueueServiceAsyncClient queueServiceAsyncClients}, calling {@link QueueServiceClientBuilder#build() build} + * constructs an instance of QueueServiceClient and calling {@link QueueServiceClientBuilder#buildAsync() buildAsync} + * constructs an instance of QueueServiceAsyncClient. + * + *

The client needs the endpoint of the Azure Storage Queue service, name of the share, and authorization credential. + * {@link QueueServiceClientBuilder#endpoint(String) endpoint} gives the builder the endpoint and may give the builder the + * A {@link SASTokenCredential} that authorizes the client.

+ * + *

Instantiating a synchronous Queue Service Client with SAS token

+ * @codesnippet com.azure.storage.queue.queueServiceClient.instantiation.sastoken + * + *

Instantiating an Asynchronous Queue Service Client with SAS token

+ * @codesnippet com.azure.storage.queue.queueServiceAsyncClient.instantiation.sastoken + * + *
+ * QueueServiceClient client = QueueServiceClient.builder()
+ *     .endpoint(endpointWithSASTokenQueryParams)
+ *     .build();
+ * 
+ * + *
+ * QueueServiceAsyncClient client = QueueServiceAsyncClient.builder()
+ *     .endpoint(endpointWithSASTokenQueryParams)
+ *     .buildAsync();
+ * 
+ * + *

If the {@code endpoint} doesn't contain the query parameters to construct a {@code SASTokenCredential} they may + * be set using {@link QueueServiceClientBuilder#credential(SASTokenCredential) credential}.

+ * + *

Another way to authenticate the client is using a {@link SharedKeyCredential}. To create a SharedKeyCredential + * a connection string from the Storage Queue service must be used. Set the SharedKeyCredential with + * {@link QueueServiceClientBuilder#connectionString(String) connectionString}. If the builder has both a SASTokenCredential and + * SharedKeyCredential the SharedKeyCredential will be preferred when authorizing requests sent to the service.

+ * + *

Instantiating a synchronous Queue Service Client with connection string.

+ * @codesnippet com.azure.storage.queue.queueServiceClient.instantiation.connectionstring + * + *

Instantiating an Asynchronous Queue Service Client with connection string.

+ * @codesnippet com.azure.storage.queue.queueServiceAsyncClient.instantiation.connectionstring + * + * @see QueueServiceClient + * @see QueueServiceAsyncClient + * @see SASTokenCredential + * @see SharedKeyCredential + */ +public final class QueueServiceClientBuilder { + private final List policies; + + private URL endpoint; + private SASTokenCredential sasTokenCredential; + private SharedKeyCredential sharedKeyCredential; + private HttpClient httpClient; + private HttpPipeline pipeline; + private HttpLogDetailLevel logLevel; + private RetryPolicy retryPolicy; + private Configuration configuration; + + QueueServiceClientBuilder() { + retryPolicy = new RetryPolicy(); + logLevel = HttpLogDetailLevel.NONE; + policies = new ArrayList<>(); + configuration = ConfigurationManager.getConfiguration(); + retryPolicy = new RetryPolicy(); + logLevel = HttpLogDetailLevel.NONE; + configuration = ConfigurationManager.getConfiguration(); + } + + /** + * Creates a {@link QueueServiceAsyncClient} based on options set in the builder. Every time {@code buildAsync()} is + * called a new instance of {@link QueueServiceAsyncClient} is created. + * + *

+ * If {@link QueueServiceClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and + * {@link QueueServiceClientBuilder#endpoint(String) endpoint} are used to create the + * {@link QueueServiceAsyncClient client}. All other builder settings are ignored. + *

+ * + * @return A QueueServiceAsyncClient with the options set from the builder. + * @throws NullPointerException If {@code endpoint} or {@code queueName} have not been set. + * @throws IllegalStateException If neither a {@link SharedKeyCredential} or {@link SASTokenCredential} has been set. + */ + public QueueServiceAsyncClient buildAsync() { + Objects.requireNonNull(endpoint); + + if (sasTokenCredential == null && sharedKeyCredential == null) { + throw new IllegalArgumentException("Credentials are required for authorization"); + } + + // Closest to API goes first, closest to wire goes last. + final List policies = new ArrayList<>(); + + policies.add(new UserAgentPolicy(QueueConfiguration.NAME, QueueConfiguration.VERSION, configuration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddDatePolicy()); + + if (sharedKeyCredential != null) { + policies.add(new SharedKeyCredentialPolicy(sharedKeyCredential)); + } else { + policies.add(new SASTokenCredentialPolicy(sasTokenCredential)); + } + + HttpPolicyProviders.addBeforeRetryPolicies(policies); + + policies.add(retryPolicy); + + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(logLevel)); + + HttpPipeline pipeline = HttpPipeline.builder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .build(); + + return new QueueServiceAsyncClient(endpoint, pipeline); + } + + /** + * Creates a {@link QueueServiceClient} based on options set in the builder. Every time {@code build()} is + * called a new instance of {@link QueueServiceClient} is created. + * + *

+ * If {@link QueueServiceClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and + * {@link QueueServiceClientBuilder#endpoint(String) endpoint} are used to create the + * {@link QueueServiceClient client}. All other builder settings are ignored. + *

+ * + * @return A QueueServiceClient with the options set from the builder. + * @throws NullPointerException If {@code endpoint} or {@code queueName} have not been set. + * @throws IllegalStateException If neither a {@link SharedKeyCredential} or {@link SASTokenCredential} has been set. + */ + public QueueServiceClient build() { + return new QueueServiceClient(buildAsync()); + } + + + /** + * Sets the endpoint for the Azure Storage Queue instance that the client will interact with. + * + *

Query parameters of the endpoint will be parsed using {@link SASTokenCredential#fromQuery(String) fromQuery} in an + * attempt to generate a {@link SASTokenCredential} to authenticate requests sent to the service.

+ * + * @param endpoint The URL of the Azure Storage Queue instance to send service requests to and receive responses from. + * @return the updated QueueServiceClientBuilder object + * @throws IllegalArgumentException If {@code endpoint} isn't a proper URL + */ + public QueueServiceClientBuilder endpoint(String endpoint) { + Objects.requireNonNull(endpoint); + try { + URL fullURL = new URL(endpoint); + this.endpoint = new URL(fullURL.getProtocol() + "://" + fullURL.getHost()); + + // Attempt to get the SAS token from the URL passed + SASTokenCredential credential = SASTokenCredential.fromQuery(fullURL.getQuery()); + if (credential != null) { + this.sasTokenCredential = credential; + } + } catch (MalformedURLException ex) { + throw new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed."); + } + + return this; + } + + /** + * Sets the {@link SASTokenCredential} used to authenticate requests sent to the Queue service. + * + * @param credential SAS token credential generated from the Storage account that authorizes requests + * @return the updated QueueServiceClientBuilder object + * @throws NullPointerException If {@code credential} is {@code null}. + */ + public QueueServiceClientBuilder credential(SASTokenCredential credential) { + this.sasTokenCredential = credential; + return this; + } + + /** + * Creates a {@link SharedKeyCredential} from the {@code connectionString} used to authenticate requests sent to the + * Queue service. + * + * @param connectionString Connection string from the Access Keys section in the Storage account + * @return the updated QueueServiceClientBuilder object + * @throws NullPointerException If {@code connectionString} is {@code null}. + */ + public QueueServiceClientBuilder connectionString(String connectionString) { + Objects.requireNonNull(connectionString); + this.sharedKeyCredential = SharedKeyCredential.fromConnectionString(connectionString); + return this; + } + + /** + * Sets the HTTP client to use for sending and receiving requests to and from the service. + * + * @param httpClient The HTTP client to use for requests. + * @return The updated QueueServiceClientBuilder object. + * @throws NullPointerException If {@code httpClient} is {@code null}. + */ + public QueueServiceClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Adds a policy to the set of existing policies that are executed after the {@link RetryPolicy}. + * + * @param pipelinePolicy The retry policy for service requests. + * @return The updated QueueServiceClientBuilder object. + * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. + */ + public QueueServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { + this.policies.add(pipelinePolicy); + return this; + } + + /** + * Sets the logging level for HTTP requests and responses. + * + * @param logLevel The amount of logging output when sending and receiving HTTP requests/responses. + * @return The updated QueueServiceClientBuilder object. + */ + public QueueServiceClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel) { + this.logLevel = logLevel; + return this; + } + + /** + * Sets the HTTP pipeline to use for the service client. + * + * If {@code pipeline} is set, all other settings are ignored, aside from {@link QueueServiceClientBuilder#endpoint(String) endpoint} + * when building clients. + * + * @param pipeline The HTTP pipeline to use for sending service requests and receiving responses. + * @return The updated QueueServiceClientBuilder object. + * @throws NullPointerException If {@code pipeline} is {@code null}. + */ + public QueueServiceClientBuilder pipeline(HttpPipeline pipeline) { + Objects.requireNonNull(pipeline); + this.pipeline = pipeline; + return this; + } + + /** + * Sets the configuration store that is used during construction of the service client. + * + * The default configuration store is a clone of the {@link ConfigurationManager#getConfiguration() global + * configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction. + * + * @param configuration The configuration store used to + * @return The updated QueueServiceClientBuilder object. + */ + public QueueServiceClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } +} diff --git a/storage/client/README.md b/storage/client/src/main/java/com/azure/storage/queue/README.md similarity index 99% rename from storage/client/README.md rename to storage/client/src/main/java/com/azure/storage/queue/README.md index 7b4dbbf1afadd..86ffe940daf0c 100644 --- a/storage/client/README.md +++ b/storage/client/src/main/java/com/azure/storage/queue/README.md @@ -52,7 +52,7 @@ az storage queue generate-sas ```Powershell CONNECTION_STRING= -#usage example + az storage queue generate-sas --name javasdksas --expiry 2019-06-05 diff --git a/storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessageItem.java b/storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessage.java similarity index 85% rename from storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessageItem.java rename to storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessage.java index 7febd2c02758d..65e6e941c717a 100644 --- a/storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessageItem.java +++ b/storage/client/src/main/java/com/azure/storage/queue/models/DequeuedMessage.java @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.storage.queue.models; @@ -14,7 +13,7 @@ * on a Queue. */ @JacksonXmlRootElement(localName = "QueueMessage") -public final class DequeuedMessageItem { +public final class DequeuedMessage { /* * The Id of the Message. */ @@ -71,9 +70,9 @@ public String messageId() { * Set the messageId property: The Id of the Message. * * @param messageId the messageId value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem messageId(String messageId) { + public DequeuedMessage messageId(String messageId) { this.messageId = messageId; return this; } @@ -96,9 +95,9 @@ public OffsetDateTime insertionTime() { * the Queue. * * @param insertionTime the insertionTime value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem insertionTime(OffsetDateTime insertionTime) { + public DequeuedMessage insertionTime(OffsetDateTime insertionTime) { if (insertionTime == null) { this.insertionTime = null; } else { @@ -125,9 +124,9 @@ public OffsetDateTime expirationTime() { * and be automatically deleted. * * @param expirationTime the expirationTime value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem expirationTime(OffsetDateTime expirationTime) { + public DequeuedMessage expirationTime(OffsetDateTime expirationTime) { if (expirationTime == null) { this.expirationTime = null; } else { @@ -153,9 +152,9 @@ public String popReceipt() { * been dequeued by another client. * * @param popReceipt the popReceipt value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem popReceipt(String popReceipt) { + public DequeuedMessage popReceipt(String popReceipt) { this.popReceipt = popReceipt; return this; } @@ -178,9 +177,9 @@ public OffsetDateTime timeNextVisible() { * become visible in the Queue. * * @param timeNextVisible the timeNextVisible value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem timeNextVisible(OffsetDateTime timeNextVisible) { + public DequeuedMessage timeNextVisible(OffsetDateTime timeNextVisible) { if (timeNextVisible == null) { this.timeNextVisible = null; } else { @@ -204,9 +203,9 @@ public long dequeueCount() { * dequeued. * * @param dequeueCount the dequeueCount value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem dequeueCount(long dequeueCount) { + public DequeuedMessage dequeueCount(long dequeueCount) { this.dequeueCount = dequeueCount; return this; } @@ -224,9 +223,9 @@ public String messageText() { * Set the messageText property: The content of the Message. * * @param messageText the messageText value to set. - * @return the DequeuedMessageItem object itself. + * @return the DequeuedMessage object itself. */ - public DequeuedMessageItem messageText(String messageText) { + public DequeuedMessage messageText(String messageText) { this.messageText = messageText; return this; } diff --git a/storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessageItem.java b/storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessage.java similarity index 85% rename from storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessageItem.java rename to storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessage.java index d86bdab8c2305..edc9960d2d747 100644 --- a/storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessageItem.java +++ b/storage/client/src/main/java/com/azure/storage/queue/models/PeekedMessage.java @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.storage.queue.models; @@ -14,7 +13,7 @@ * on a Queue. */ @JacksonXmlRootElement(localName = "QueueMessage") -public final class PeekedMessageItem { +public final class PeekedMessage { /* * The Id of the Message. */ @@ -58,9 +57,9 @@ public String messageId() { * Set the messageId property: The Id of the Message. * * @param messageId the messageId value to set. - * @return the PeekedMessageItem object itself. + * @return the PeekedMessage object itself. */ - public PeekedMessageItem messageId(String messageId) { + public PeekedMessage messageId(String messageId) { this.messageId = messageId; return this; } @@ -83,9 +82,9 @@ public OffsetDateTime insertionTime() { * the Queue. * * @param insertionTime the insertionTime value to set. - * @return the PeekedMessageItem object itself. + * @return the PeekedMessage object itself. */ - public PeekedMessageItem insertionTime(OffsetDateTime insertionTime) { + public PeekedMessage insertionTime(OffsetDateTime insertionTime) { if (insertionTime == null) { this.insertionTime = null; } else { @@ -112,9 +111,9 @@ public OffsetDateTime expirationTime() { * and be automatically deleted. * * @param expirationTime the expirationTime value to set. - * @return the PeekedMessageItem object itself. + * @return the PeekedMessage object itself. */ - public PeekedMessageItem expirationTime(OffsetDateTime expirationTime) { + public PeekedMessage expirationTime(OffsetDateTime expirationTime) { if (expirationTime == null) { this.expirationTime = null; } else { @@ -138,9 +137,9 @@ public long dequeueCount() { * dequeued. * * @param dequeueCount the dequeueCount value to set. - * @return the PeekedMessageItem object itself. + * @return the PeekedMessage object itself. */ - public PeekedMessageItem dequeueCount(long dequeueCount) { + public PeekedMessage dequeueCount(long dequeueCount) { this.dequeueCount = dequeueCount; return this; } @@ -158,9 +157,9 @@ public String messageText() { * Set the messageText property: The content of the Message. * * @param messageText the messageText value to set. - * @return the PeekedMessageItem object itself. + * @return the PeekedMessage object itself. */ - public PeekedMessageItem messageText(String messageText) { + public PeekedMessage messageText(String messageText) { this.messageText = messageText; return this; } diff --git a/storage/client/src/main/java/com/azure/storage/queue/models/QueueProperties.java b/storage/client/src/main/java/com/azure/storage/queue/models/QueueProperties.java new file mode 100644 index 0000000000000..bb343ea96bd24 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/models/QueueProperties.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue.models; + +import java.util.Map; + +/** + * Model class containing properties of a specific queue in the storage Queue service. + */ +public final class QueueProperties { + private final Map metadata; + private final int approximateMessagesCount; + + /** + * Creates an instance that contains properties of a queue. + * + * @param metadata Metadata associated with the queue + * @param approximateMessagesCount Approximate number of messages contained in the queue + */ + public QueueProperties(Map metadata, int approximateMessagesCount) { + this.metadata = metadata; + this.approximateMessagesCount = approximateMessagesCount; + } + + /** + * @return the user-defined metadata associated with the queue + */ + public Map metadata() { + return this.metadata; + } + + /** + * @return the approximate number of messages contained in the queue at the time of properties retrieval + */ + public int approximateMessagesCount() { + return approximateMessagesCount; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/models/QueuesSegmentOptions.java b/storage/client/src/main/java/com/azure/storage/queue/models/QueuesSegmentOptions.java new file mode 100644 index 0000000000000..d58b2f71b8d05 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/models/QueuesSegmentOptions.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue.models; + +import com.azure.storage.queue.QueueServiceAsyncClient; +import com.azure.storage.queue.QueueServiceClient; + +/** + * A set of options for selecting queues from Storage Queue service. + * + *
    + *
  • + * Providing {@link QueuesSegmentOptions#prefix() prefix} will filter {@link QueueItem queues} that begin + * with the prefix. + *
  • + *
  • + * Providing {@link QueuesSegmentOptions#maxResults() maxResults} will limit the number of {@link QueueItem queues} + * returned in a single page. + *
  • + *
  • + * Setting {@link QueuesSegmentOptions#includeMetadata() includeMetadata} to true will include the metadata of + * each {@link QueueItem queue}, if false {@link QueueItem#metadata() metadata} for each queue will be {@code null}. + *
  • + *
+ * + * @see QueueServiceClient + * @see QueueServiceAsyncClient + */ +public final class QueuesSegmentOptions { + private boolean includeMetadata; + + private String prefix; + + private Integer maxResults; + + /** + * @return the status of including metadata when listing queues + */ + public boolean includeMetadata() { + return includeMetadata; + } + + /** + * Sets the status of including queue metadata when listing queues + * + * @param includeMetadata Flag indicating if metadata should be included in the listing + * @return An updated QueuesSegmentOptions object + */ + public QueuesSegmentOptions includeMetadata(boolean includeMetadata) { + this.includeMetadata = includeMetadata; + return this; + } + + /** + * @return the prefix the queue name must match to be included in the listing + */ + public String prefix() { + return prefix; + } + + /** + * Sets the prefix that a queue must match to be included in the listing + * + * @param prefix The prefix that queues must start with to pass the filter + * @return An updated QueuesSegmentOptions object + */ + public QueuesSegmentOptions prefix(String prefix) { + this.prefix = prefix; + return this; + } + + /** + * @return the maximum number of queues to include in a single response + */ + public Integer maxResults() { + return maxResults; + } + + /** + * Sets the maximum number of queues to include in a single response + * + * @param maxResults Maximum number of results to include in a single response + * @return An updated QueuesSegmentOptions object + */ + public QueuesSegmentOptions maxResults(Integer maxResults) { + this.maxResults = maxResults; + return this; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/models/UpdatedMessage.java b/storage/client/src/main/java/com/azure/storage/queue/models/UpdatedMessage.java new file mode 100644 index 0000000000000..fa6a4d5970153 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/models/UpdatedMessage.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue.models; + +import java.time.OffsetDateTime; + +/** + * Response from the service when updating a message. Contains the information needed to continue working with + * the specific message. + */ +public final class UpdatedMessage { + private final String popReceipt; + private final OffsetDateTime timeNextVisible; + + /** + * Creates an instance of updated message information. + * + * @param popReceipt Unique identifier that verifies the operation on a message is valid + * @param timeNextVisible The next time the message will be visible to other operations in the queue + */ + public UpdatedMessage(String popReceipt, OffsetDateTime timeNextVisible) { + this.popReceipt = popReceipt; + this.timeNextVisible = timeNextVisible; + } + + /** + * @return the unique identifier used to verify that the operation is allowed on the message + */ + public String popReceipt() { + return popReceipt; + } + + /** + * @return the next time the message will be visible to other operations in the queue + */ + public OffsetDateTime timeNextVisible() { + return timeNextVisible; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/package-info.java b/storage/client/src/main/java/com/azure/storage/queue/package-info.java new file mode 100644 index 0000000000000..e6671d8292fac --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * This package contains the classes to perform actions on Azure Storage Queue. + */ +package com.azure.storage.queue; diff --git a/storage/client/src/samples/java/com/azure/storage/queue/AsyncSamples.java b/storage/client/src/samples/java/com/azure/storage/queue/AsyncSamples.java new file mode 100644 index 0000000000000..2540625317bd8 --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/AsyncSamples.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.queue; + +import java.util.UUID; + +/* + * This example mimics some arbitrary number of clients continuously sending messages up to a queue in a parallel and + * a server dequeuing the messages and processing them. + */ +public class AsyncSamples { + private static final String accountName = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String sasToken = System.getenv("PRIMARY_SAS_TOKEN"); + private static final String queueName = generateRandomName("async-call", 16); + + public static void main(String[] args) { + // Create an async queue client. + String queueURL = String.format("https://%s.queue.core.windows.net/%s%s", accountName, queueName, sasToken); + QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsync(); + + // Create a queue, enqueue two messages. + queueAsyncClient.create() + .flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1")) + .flatMap(response -> queueAsyncClient.enqueueMessage("This is message 2")) + .subscribe( + response -> { + System.out.println("Message successfully equeueed by queueAsyncClient. Message id:" + response.value().messageId()); + }, + err -> { + System.out.println("Error thrown when enqueue the message. Error message: " + err.getMessage()); + }, + () -> { + System.out.println("The enqueue has been completed."); + } + ); + } + + private static String generateRandomName(String prefix, int length) { + int len = length > prefix.length() ? length - prefix.length() : 0; + return prefix + UUID.randomUUID().toString().substring(0, len); + } +} diff --git a/storage/client/src/samples/java/com/azure/storage/queue/MessageSample.java b/storage/client/src/samples/java/com/azure/storage/queue/MessageSample.java new file mode 100644 index 0000000000000..8fb8e63265e35 --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/MessageSample.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.queue; + +import com.azure.core.http.rest.Response; +import com.azure.storage.queue.QueueClient; +import com.azure.storage.queue.QueueServiceClient; +import com.azure.storage.queue.models.DequeuedMessage; + +import java.time.Duration; +import java.util.UUID; + +public class MessageSample { + private static final String accountName = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String sasToken = System.getenv("PRIMARY_SAS_TOKEN"); + + public static void main(String[] args) throws Exception { + // Build Queue Client using SAS Token + String queueServiceURL = String.format("https://%s.queue.core.windows.net/%s", accountName, sasToken); + QueueServiceClient queueServiceClient = QueueServiceClient.builder().endpoint(queueServiceURL).build(); + + // Create a queue client + Response queueClientResponse = queueServiceClient.createQueue(generateRandomName("enqueue", 16)); + QueueClient queueClient = queueClientResponse.value(); + // Using queue client to enqueue several "Hello World" messages into queue. + for (int i = 0; i < 3; i++) { + queueClient.enqueueMessage("Hello World"); + } + + // Enqueue json file into message. + // TODO + + // Get the total count of msg in the queue + int count = queueClient.getProperties().value().approximateMessagesCount(); + + // Peek all messages in queue. It is supposed to print "Hello World" 3 times. + queueClient.peekMessages(count).forEach( + peekedMessage -> { + System.out.println("Here is the msg: " + peekedMessage.messageText()); + } + ); + + // Dequeue all messages in queue and update the message "Hello World" to Hello, world!" + queueClient.dequeueMessages(count, Duration.ZERO).forEach( + queueMessage -> { + String msgToReplace = String.format("Hello, world!"); + queueClient.updateMessage(queueMessage.messageId(), msgToReplace, queueMessage.popReceipt(), Duration.ZERO); + } + ); + + // Delete the first available msg. + // Since there is no invisible time for above dequeue, the following if condition should be true. + if (queueClient.dequeueMessages().iterator().hasNext()) { + DequeuedMessage queueMessage = queueClient.dequeueMessages().iterator().next(); + queueClient.deleteMessage(queueMessage.messageId(), queueMessage.popReceipt()); + } else { + System.out.println("OOps, the messages disappear!"); + } + + // Clear all messages in the queue + // Sleep to guarantee we skip the default invisible time. + Thread.sleep(500); + queueClient.clearMessages(); + + // Finally, we delete the queue. + queueClient.delete(); + } + + private static String generateRandomName(String prefix, int length) { + int len = length > prefix.length() ? length - prefix.length() : 0; + return prefix + UUID.randomUUID().toString().substring(0, len); + } +} diff --git a/storage/client/src/samples/java/com/azure/storage/queue/QueueExceptionSamples.java b/storage/client/src/samples/java/com/azure/storage/queue/QueueExceptionSamples.java new file mode 100644 index 0000000000000..e04fcfb8de6d9 --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/QueueExceptionSamples.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.queue; + +import com.azure.core.http.rest.Response; +import com.azure.storage.queue.models.StorageErrorCode; +import com.azure.storage.queue.models.StorageErrorException; + +import java.util.UUID; + +public class QueueExceptionSamples { + private static final String accountName = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String sasToken = System.getenv("PRIMARY_SAS_TOKEN"); + + public static void main(String[] args) { + // Create a queue service client. + String queueServiceURL = String.format("https://%s.queue.core.windows.net/%s", accountName, sasToken); + QueueServiceClient queueServiceClient = QueueServiceClient.builder().endpoint(queueServiceURL).build(); + + // Create queue client. + Response queueClientResponse = null; + try { + queueClientResponse = queueServiceClient.createQueue(generateRandomName("delete-not-exist", 16)); + System.out.println("Successfully create the queue! Status code: " + String.valueOf(queueClientResponse.statusCode())); + } catch (StorageErrorException e) { + System.out.println(String.format("Error creating a queue. Error message: %s", e.value().message())); + } + QueueClient queueClient = queueClientResponse.value(); + queueClient.enqueueMessage("Hello, message 1!"); + queueClient.enqueueMessage("Hello, message 2!"); + + // Delete message with wrong message id. + try { + queueClientResponse.value().dequeueMessages().forEach( + msg -> { + queueClient.deleteMessage("wrong id", msg.popReceipt()); + } + ); + } catch (StorageErrorException e) { + if (e.getMessage().contains(StorageErrorCode.MESSAGE_NOT_FOUND.toString())) { + System.out.println("This is the error expected to throw"); + } else { + System.out.println("This is not the error we expect!"); + } + } + + // Delete message with wrong pop receipt. + try { + queueClient.dequeueMessages().forEach( + msg -> { + queueClient.deleteMessage(msg.messageId(), "Wrong Pop Receipt"); + } + ); + } catch (StorageErrorException e) { + if (e.getMessage().contains(StorageErrorCode.INVALID_QUERY_PARAMETER_VALUE.toString())) { + System.out.println("This is the error expected to throw"); + } else { + System.out.println("This is not the error we expect!"); + } + } + } + + private static String generateRandomName(String prefix, int length) { + int len = length > prefix.length() ? length - prefix.length() : 0; + return prefix + UUID.randomUUID().toString().substring(0, len); + } +} diff --git a/storage/client/src/samples/java/com/azure/storage/queue/QueueServiceSample.java b/storage/client/src/samples/java/com/azure/storage/queue/QueueServiceSample.java new file mode 100644 index 0000000000000..27400dbde0bed --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/QueueServiceSample.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.queue; + +import com.azure.storage.queue.QueueServiceClient; + +import java.util.UUID; + +public class QueueServiceSample { + private static final String accountName = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String sasToken = System.getenv("PRIMARY_SAS_TOKEN"); + + public static void main(String[] args) { + // Build Queue Service Client using SAS Token + String queueServiceURL = String.format("https://%s.queue.core.windows.net/%s", accountName, sasToken); + QueueServiceClient queueServiceClient = QueueServiceClient.builder().endpoint(queueServiceURL).build(); + queueServiceClient.createQueue(generateRandomName("create-queue", 16)); + + // Create another queue and list all queues, print the name and then delete the queue. + queueServiceClient.createQueue(generateRandomName("create-extra" , 16)); + queueServiceClient.listQueues().forEach( + queueItem -> { + System.out.println("The queue name is: " + queueItem.name()); + queueServiceClient.deleteQueue(queueItem.name()); + } + ); + } + + private static String generateRandomName(String prefix, int length) { + int len = length > prefix.length() ? length - prefix.length() : 0; + return prefix + UUID.randomUUID().toString().substring(0, len); + } + +} diff --git a/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueJavaDocCodeSamples.java b/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueJavaDocCodeSamples.java new file mode 100644 index 0000000000000..d1cc204ad0a61 --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueJavaDocCodeSamples.java @@ -0,0 +1,278 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue.javadoc; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.VoidResponse; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.queue.QueueAsyncClient; +import com.azure.storage.queue.QueueClient; +import com.azure.storage.queue.models.EnqueuedMessage; +import com.azure.storage.queue.models.UpdatedMessage; +import java.time.Duration; + +/** + * Contains code snippets when generating javadocs through doclets for {@link QueueClient} and {@link QueueAsyncClient}. + */ + +public class QueueJavaDocCodeSamples { + /** + * Generates code sample for creating a {@link QueueClient} with {@link QueueClient} + * @return An instance of {@link QueueClient} + */ + public QueueClient createClientWithSASToken() { + // BEGIN: com.azure.storage.queue.queueClient.instantiation.sastoken + QueueClient queueClient = QueueClient.builder() + .endpoint("https://${accountName}.queue.core.windows.net?${SASToken}") + .build(); + // END: com.azure.storage.file.queueClient.instantiation.sastoken + return queueClient; + } + + /** + * Generates code sample for creating a {@link QueueAsyncClient} with {@link SASTokenCredential} + * @return An instance of {@link QueueAsyncClient} + */ + public QueueAsyncClient createAsyncClientWithSASToken() { + // BEGIN: com.azure.storage.queue.queueAsyncClient.instantiation.sastoken + QueueAsyncClient queueAsyncClient = QueueAsyncClient.builder() + .endpoint("https://{accountName}.queue.core.windows.net?{SASToken}") + .buildAsync(); + // END: com.azure.storage.file.queueAsyncClient.instantiation.sastoken + return queueAsyncClient; + } + + /** + * Generates code sample for creating a {@link QueueClient} with {@code connectionString} which turns into {@link SharedKeyCredential} + * @return An instance of {@link QueueClient} + */ + public QueueClient createClientWithConnectionString() { + // BEGIN: com.azure.storage.queue.queueClient.instantiation.connectionstring + String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};EndpointSuffix={core.windows.net}"; + QueueClient queueClient = QueueClient.builder() + .connectionString(connectionString) + .build(); + // END: com.azure.storage.queue.queueClient.instantiation.connectionstring + return queueClient; + } + + /** + * Generates code sample for creating a {@link QueueAsyncClient} with {@code connectionString} which turns into {@link SharedKeyCredential} + * @return An instance of {@link QueueAsyncClient} + */ + public QueueAsyncClient createAsyncClientWithConnectionString() { + // BEGIN: com.azure.storage.queue.queueAsyncClient.instantiation.connectionstring + String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};EndpointSuffix={core.windows.net}"; + QueueAsyncClient queueAsyncClient = QueueAsyncClient.builder() + .connectionString(connectionString) + .buildAsync(); + // END: com.azure.storage.queue.queueAsyncClient.instantiation.connectionstring + return queueAsyncClient; + } + + /** + * Generates a code sample for using {@link QueueClient#create()} + */ + public void createQueue() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.create + VoidResponse response = queueClient.create(); + System.out.println("Complete creating queue with status code: " + response.statusCode()); + // END: com.azure.storage.queue.queueClient.create + } + + /** + * Generates a code sample for using {@link QueueAsyncClient#create()} + */ + public void createQueueAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.create + queueAsyncClient.create().subscribe( + response -> {}, + error -> System.err.print(error.toString()), + () -> System.out.println("Complete creating the queue!") + ); + // END: com.azure.storage.queue.queueAsyncClient.create + } + + + /** + * Generates a code sample for using {@link QueueClient#enqueueMessage(String)} + */ + public void enqueueMessage() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.enqueueMessage#string + Response response = queueClient.enqueueMessage("hello msg"); + System.out.println("Complete enqueuing the message with status code: " + response.statusCode()); + // END: com.azure.storage.queue.queueClient.enqueueMessage#string + } + + /** + * Generates a code sample for using {@link QueueAsyncClient#enqueueMessage(String)} + */ + public void enqueueMessageAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.enqueueMessage#string + queueAsyncClient.enqueueMessage("hello msg").subscribe( + response -> {}, + error -> System.err.print(error.toString()), + () -> System.out.println("Complete enqueuing the message!") + ); + // END: com.azure.storage.queue.queueAsyncClient.enqueueMessage#string + } + + /** + * Generates a code sample for using {@link QueueClient#dequeueMessages()} + */ + public void dequeueMessage() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.dequeueMessages + queueClient.dequeueMessages().forEach( + dequeuedMessage -> { + System.out.println("Complete dequeuing the message: " + dequeuedMessage.messageText()); + } + ); + // END: com.azure.storage.queue.queueClient.dequeueMessages + } + + + /** + * Generates a code sample for using {@link QueueAsyncClient#dequeueMessages()} + */ + public void dequeueMessageAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.dequeueMessages + queueAsyncClient.dequeueMessages().subscribe( + dequeuedMessage -> System.out.println("The message got from dequeue operation: " + dequeuedMessage.messageText()), + error -> System.err.print(error.toString()), + () -> System.out.println("Complete dequeuing the message!") + ); + // END: com.azure.storage.queue.queueAsyncClient.dequeueMessages + } + + /** + * Generates a code sample for using {@link QueueClient#peekMessages()} + */ + public void peekMessage() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.peekMessages + queueClient.peekMessages().forEach( + peekedMessage -> { + System.out.println("Complete peeking the message: " + peekedMessage.messageText()); + } + ); + // END: com.azure.storage.queue.queueClient.peekMessages + } + + + /** + * Generates a code sample for using {@link QueueAsyncClient#peekMessages()} + */ + public void peekMessageAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.peekMessages + queueAsyncClient.peekMessages().subscribe( + peekMessages -> System.out.println("The message got from peek operation: " + peekMessages.messageText()), + error -> System.err.print(error.toString()), + () -> System.out.println("Complete peeking the message!") + ); + // END: com.azure.storage.queue.queueAsyncClient.peekMessages + } + + /** + * Generates a code sample for using {@link QueueClient#updateMessage(String, String, String, Duration)} + */ + public void updateMessage() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.updateMessage + queueClient.dequeueMessages().forEach( + dequeuedMessage -> { + Response response = queueClient.updateMessage("newText", dequeuedMessage.messageId(), dequeuedMessage.popReceipt(), null); + System.out.println("Complete updating the message with status code " + response.statusCode()); + } + ); + // END: com.azure.storage.queue.queueClient.updateMessage + } + + + /** + * Generates a code sample for using {@link QueueAsyncClient#updateMessage(String, String, String, Duration)} + */ + public void updateMessageAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.updateMessage + queueAsyncClient.dequeueMessages().subscribe( + dequeuedMessage -> { + queueAsyncClient.updateMessage("newText", dequeuedMessage.messageId(), dequeuedMessage.popReceipt(), null).subscribe( + response -> {}, + updateError -> System.err.print(updateError.toString()), + () -> System.out.println("Complete updating the message!") + ); + }, + dequeueError -> System.err.print(dequeueError.toString()), + () -> System.out.println("Complete dequeueing the message!") + ); + // END: com.azure.storage.queue.queueAsyncClient.updateMessage + } + + /** + * Generates a code sample for using {@link QueueClient#deleteMessage(String, String)} + */ + public void deleteMessage() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.deleteMessage + queueClient.dequeueMessages().forEach( + dequeuedMessage -> { + VoidResponse response = queueClient.deleteMessage(dequeuedMessage.messageId(), dequeuedMessage.popReceipt()); + System.out.println("Complete deleting the message with status code " + response.statusCode()); + } + ); + // END: com.azure.storage.queue.queueClient.deleteMessage + } + + + /** + * Generates a code sample for using {@link QueueAsyncClient#deleteMessage(String, String)} + */ + public void deleteMessageAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.deleteMessage + queueAsyncClient.dequeueMessages().subscribe( + dequeuedMessage -> { + queueAsyncClient.deleteMessage(dequeuedMessage.messageId(), dequeuedMessage.popReceipt()).subscribe( + response -> {}, + deleteError -> System.err.print(deleteError.toString()), + () -> System.out.println("Complete deleting the message!") + ); + }, + dequeueError -> System.err.print(dequeueError.toString()), + () -> System.out.println("Complete dequeueing the message!") + ); + // END: com.azure.storage.queue.queueAsyncClient.deleteMessage + } + + /** + * Generates a code sample for using {@link QueueClient#delete()} + */ + public void deleteQueue() { + QueueClient queueClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueClient.delete + VoidResponse response = queueClient.delete(); + System.out.println("Complete deleting the queue with status code: " + response.statusCode()); + // END: com.azure.storage.queue.queueClient.delete + } + + + /** + * Generates a code sample for using {@link QueueAsyncClient#delete()} + */ + public void deleteQueueAsync() { + QueueAsyncClient queueAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueAsyncClient.delete + queueAsyncClient.delete().subscribe( + response -> System.out.println("Deleting the queue completed with status code: " + response.statusCode()) + ); + // END: com.azure.storage.queue.queueAsyncClient.delete + } +} diff --git a/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueServiceJavaDocCodeSamples.java b/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueServiceJavaDocCodeSamples.java new file mode 100644 index 0000000000000..2997291200145 --- /dev/null +++ b/storage/client/src/samples/java/com/azure/storage/queue/javadoc/QueueServiceJavaDocCodeSamples.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue.javadoc; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.VoidResponse; +import com.azure.storage.common.credentials.SASTokenCredential; +import com.azure.storage.common.credentials.SharedKeyCredential; +import com.azure.storage.queue.QueueClient; +import com.azure.storage.queue.QueueServiceAsyncClient; +import com.azure.storage.queue.QueueServiceClient; + +/** + * Contains code snippets when generating javadocs through doclets for {@link QueueServiceClient} and {@link QueueServiceAsyncClient}. + */ +public class QueueServiceJavaDocCodeSamples { + /** + * Generates code sample for creating a {@link QueueServiceClient} with {@link QueueServiceClient} + * @return An instance of {@link QueueServiceClient} + */ + public QueueServiceClient createClientWithSASToken() { + // BEGIN: com.azure.storage.queue.queueServiceClient.instantiation.sastoken + QueueServiceClient queueServiceClient = QueueServiceClient.builder() + .endpoint("https://${accountName}.queue.core.windows.net?${SASToken}") + .build(); + // END: com.azure.storage.queue.queueServiceClient.instantiation.sastoken + return queueServiceClient; + } + + /** + * Generates code sample for creating a {@link QueueServiceAsyncClient} with {@link SASTokenCredential} + * @return An instance of {@link QueueServiceAsyncClient} + */ + public QueueServiceAsyncClient createAsyncClientWithSASToken() { + // BEGIN: com.azure.storage.queue.queueServiceAsyncClient.instantiation.sastoken + QueueServiceAsyncClient queueServiceAsyncClient = QueueServiceAsyncClient.builder() + .endpoint("https://{accountName}.queue.core.windows.net?{SASToken}") + .buildAsync(); + // END: com.azure.storage.file.queueServiceAsyncClient.instantiation.sastoken + return queueServiceAsyncClient; + } + + /** + * Generates code sample for creating a {@link QueueServiceClient} with {@code connectionString} which turns into {@link SharedKeyCredential} + * @return An instance of {@link QueueServiceClient} + */ + public QueueServiceClient createClientWithConnectionString() { + // BEGIN: com.azure.storage.queue.queueServiceClient.instantiation.connectionstring + String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};EndpointSuffix={core.windows.net}"; + QueueServiceClient queueServiceClient = QueueServiceClient.builder() + .connectionString(connectionString) + .build(); + // END: com.azure.storage.queue.queueServiceClient.instantiation.connectionstring + return queueServiceClient; + } + + /** + * Generates code sample for creating a {@link QueueServiceAsyncClient} with {@code connectionString} which turns into {@link SharedKeyCredential} + * @return An instance of {@link QueueServiceAsyncClient} + */ + public QueueServiceAsyncClient createAsyncClientWithConnectionString() { + // BEGIN: com.azure.storage.queue.queueServiceAsyncClient.instantiation.connectionstring + String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};EndpointSuffix={core.windows.net}"; + QueueServiceAsyncClient queueServiceAsyncClient = QueueServiceAsyncClient.builder() + .connectionString(connectionString) + .buildAsync(); + // END: com.azure.storage.queue.queueServiceAsyncClient.instantiation.connectionstring + return queueServiceAsyncClient; + } + + /** + * Generates a code sample for using {@link QueueServiceClient#createQueue(String)} + */ + public void createQueue() { + QueueServiceClient queueServiceClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceClient.createQueue#string + Response response = queueServiceClient.createQueue("myqueue"); + System.out.println("Complete creating queue with status code: " + response.statusCode()); + // END: com.azure.storage.queue.queueServiceClient.createQueue#string + } + + /** + * Generates a code sample for using {@link QueueServiceAsyncClient#createQueue(String)} + */ + public void createQueueAsync() { + QueueServiceAsyncClient queueServiceAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceAsyncClient.createQueue#string + queueServiceAsyncClient.createQueue("myqueue").subscribe( + response -> {}, + error -> System.err.print(error.toString()), + () -> System.out.println("Complete creating the queue!") + ); + // END: com.azure.storage.queue.queueServiceAsyncClient.createQueue#string + } + + + /** + * Generates a code sample for using {@link QueueServiceClient#listQueues()} + */ + public void listQueues() { + QueueServiceClient queueServiceClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceClient.listQueues + queueServiceClient.listQueues().forEach( + queueItem -> System.out.printf("Queue %s exists in the account", queueItem.name()) + ); + // END: com.azure.storage.queue.queueServiceClient.listQueues + } + + /** + * Generates a code sample for using {@link QueueServiceAsyncClient#listQueues()} + */ + public void listQueuesAsync() { + QueueServiceAsyncClient queueServiceAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceAsyncClient.listQueues + queueServiceAsyncClient.listQueues().subscribe( + queueItem -> System.out.printf("Queue %s exists in the account", queueItem.name()), + error -> System.err.print(error.toString()), + () -> System.out.println("Complete listing the queues!") + ); + // END: com.azure.storage.queue.queueServiceAsyncClient.listQueues + } + + /** + * Generates a code sample for using {@link QueueServiceClient#deleteQueue(String)} + */ + public void deleteQueue() { + QueueServiceClient queueServiceClient = createClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceClient.deleteQueue#string + VoidResponse response = queueServiceClient.deleteQueue("myqueue"); + System.out.println("Complete deleting the queue with status code: " + response.statusCode()); + // END: com.azure.storage.queue.queueServiceClient.deleteQueue#string + } + + + /** + * Generates a code sample for using {@link QueueServiceAsyncClient#deleteQueue(String)} + */ + public void deleteQueueAsync() { + QueueServiceAsyncClient queueServiceAsyncClient = createAsyncClientWithSASToken(); + // BEGIN: com.azure.storage.queue.queueServiceAsyncClient.deleteQueue#string + queueServiceAsyncClient.deleteQueue("myshare").subscribe( + response -> System.out.println("Deleting the queue completed with status code: " + response.statusCode()) + ); + // END: com.azure.storage.queue.queueServiceAsyncClient.deleteQueue#string + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueAsyncClientTests.java b/storage/client/src/test/java/com/azure/storage/queue/QueueAsyncClientTests.java new file mode 100644 index 0000000000000..7da45fec8bcda --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueAsyncClientTests.java @@ -0,0 +1,695 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.queue.models.AccessPolicy; +import com.azure.storage.queue.models.DequeuedMessage; +import com.azure.storage.queue.models.SignedIdentifier; +import com.azure.storage.queue.models.StorageErrorException; +import reactor.test.StepVerifier; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class QueueAsyncClientTests extends QueueClientTestsBase { + private final ClientLogger logger = new ClientLogger(QueueAsyncClientTests.class); + + private QueueAsyncClient client; + + @Override + protected void beforeTest() { + queueName = getQueueName(); + helper = new TestHelpers(); + + if (interceptorManager.isPlaybackMode()) { + client = helper.setupClient((connectionString, endpoint) -> QueueAsyncClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .queueName(queueName) + .httpClient(interceptorManager.getPlaybackClient()) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .buildAsync(), true, logger); + } else { + client = helper.setupClient((connectionString, endpoint) -> QueueAsyncClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .queueName(queueName) + .httpClient(HttpClient.createDefault().wiretap(true)) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .addPolicy(interceptorManager.getRecordPolicy()) + .buildAsync(), false, logger); + } + } + + @Override + protected void afterTest() { + try { + client.clearMessages().block(); + client.delete().block(); + } catch (StorageErrorException ex) { + // Queue already delete, that's what we wanted anyways. + } + } + + @Override + public void createWithSharedKey() { + + } + + @Override + public void createWithSASToken() { + // Need to find a way to get SAS tokens from the storage account + } + + @Override + public void createWithMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + }) + .verifyComplete(); + } + + @Override + public void createTwiceSameMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.create(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + } + + @Override + public void createTwiceDifferentMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.create(metadata)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 409)); + } + + @Override + public void deleteExisting() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.enqueueMessage("This queue will be deleted")) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.delete()) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + helper.sleep(Duration.ofSeconds(30)); + + StepVerifier.create(client.enqueueMessage("This should fail")) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void deleteNonExistent() { + StepVerifier.create(client.delete()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void getProperties() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + }) + .verifyComplete(); + } + + @Override + public void getPropertiesQueueDoesNotExist() { + StepVerifier.create(client.getProperties()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void setMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.setMetadata(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + }) + .verifyComplete(); + } + + @Override + public void setMetadataQueueDoesNotExist() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.setMetadata(metadata)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void setInvalidMetadata() { + Map badMetadata = Collections.singletonMap("", "bad metadata"); + + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.setMetadata(badMetadata)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void deleteMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(client.create(metadata)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + }) + .verifyComplete(); + + StepVerifier.create(client.setMetadata(null)) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(Collections.EMPTY_MAP, response.value().metadata()); + }) + .verifyComplete(); + } + + @Override + public void getAccessPolicy() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.getAccessPolicy()) + .expectNextCount(0) + .verifyComplete(); + } + + @Override + public void getAccessPolicyQueueDoesNotExist() { + StepVerifier.create(client.getAccessPolicy()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void setAccessPolicy() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + AccessPolicy accessPolicy = new AccessPolicy() + .permission("raup") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + SignedIdentifier permission = new SignedIdentifier() + .id("testpermission") + .accessPolicy(accessPolicy); + + StepVerifier.create(client.setAccessPolicy(Collections.singletonList(permission))) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.getAccessPolicy()) + .assertNext(response -> helper.assertPermissionsAreEqual(permission, response)) + .verifyComplete(); + } + + @Override + public void setAccessPolicyQueueDoesNotExist() { + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.now()) + .expiry(OffsetDateTime.now()); + + SignedIdentifier permission = new SignedIdentifier() + .id("test-permission") + .accessPolicy(accessPolicy); + + StepVerifier.create(client.setAccessPolicy(Collections.singletonList(permission))) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void setInvalidAccessPolicy() { + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + SignedIdentifier permission = new SignedIdentifier() + .id("theidofthispermissionislongerthanwhatisallowedbytheserviceandshouldfail") + .accessPolicy(accessPolicy); + + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.setAccessPolicy(Collections.singletonList(permission))) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void setTooManyAccessPolicies() { + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + List permissions = new ArrayList<>(); + for (int i = 0; i < 6; i++) { + permissions.add(new SignedIdentifier() + .id("policy" + i) + .accessPolicy(accessPolicy)); + } + + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.setAccessPolicy(permissions)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void enqueueMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages()) + .assertNext(peekedMessage -> assertEquals(messageText, peekedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void enqueueEmptyMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = ""; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages()) + .assertNext(peekedMessage -> assertNull(peekedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void enqueueShortTimeToLiveMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText, Duration.ofSeconds(0), Duration.ofSeconds(2))) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages().delaySubscription(Duration.ofSeconds(5))) + .expectNextCount(0) + .verifyComplete(); + } + + @Override + public void enqueueQueueDoesNotExist() { + StepVerifier.create(client.enqueueMessage("this should fail")) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void dequeueMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.dequeueMessages()) + .assertNext(dequeuedMessage -> assertEquals(messageText, dequeuedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void dequeueMultipleMessages() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + String messageText2 = "test message 2"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.enqueueMessage(messageText2)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.dequeueMessages(2)) + .assertNext(dequeuedMessage -> assertEquals(messageText, dequeuedMessage.messageText())) + .assertNext(dequeuedMessage -> assertEquals(messageText2, dequeuedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void dequeueTooManyMessages() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.dequeueMessages(64)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void dequeueQueueDoesNotExist() { + StepVerifier.create(client.dequeueMessages()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void peekMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages()) + .assertNext(peekedMessage -> assertEquals(messageText, peekedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void peekMultipleMessages() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + String messageText2 = "test message 2"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.enqueueMessage(messageText2)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages(2)) + .assertNext(peekedMessage -> assertEquals(messageText, peekedMessage.messageText())) + .assertNext(peekedMessage -> assertEquals(messageText2, peekedMessage.messageText())) + .verifyComplete(); + } + + @Override + public void peekTooManyMessages() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages(64)) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void peekQueueDoesNotExist() { + StepVerifier.create(client.peekMessages()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void clearMessages() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.enqueueMessage("test message")) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + StepVerifier.create(client.enqueueMessage("test message")) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + StepVerifier.create(client.enqueueMessage("test message")) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(3, response.value().approximateMessagesCount()); + }) + .verifyComplete(); + + StepVerifier.create(client.clearMessages()) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + }) + .verifyComplete(); + } + + @Override + public void clearMessagesQueueDoesNotExist() { + StepVerifier.create(client.clearMessages()) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void deleteMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = client.dequeueMessages().blockFirst(); + assertEquals(messageText, dequeuedMessage.messageText()); + StepVerifier.create(client.deleteMessage(dequeuedMessage.messageId(), dequeuedMessage.popReceipt())) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + }) + .verifyComplete(); + } + + @Override + public void deleteMessageInvalidMessageId() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = new DequeuedMessage(); + StepVerifier.create(client.dequeueMessages()) + .assertNext(response -> { + assertEquals(messageText, response.messageText()); + dequeuedMessage.popReceipt(response.popReceipt()).messageId(response.messageId()); + }) + .verifyComplete(); + + StepVerifier.create(client.deleteMessage(dequeuedMessage.messageId() + "random", dequeuedMessage.popReceipt())) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void deleteMessageInvalidPopReceipt() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = new DequeuedMessage(); + StepVerifier.create(client.dequeueMessages()) + .assertNext(response -> { + assertEquals(messageText, response.messageText()); + dequeuedMessage.popReceipt(response.popReceipt()).messageId(response.messageId()); + }) + .verifyComplete(); + + StepVerifier.create(client.deleteMessage(dequeuedMessage.messageId(), dequeuedMessage.popReceipt() + "random")) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void deleteMessageQueueDoesNotExist() { + StepVerifier.create(client.deleteMessage("invalid", "call")) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void updateMessage() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = client.dequeueMessages().blockFirst(); + assertEquals(messageText, dequeuedMessage.messageText()); + + String updatedMessageText = "updated test message"; + StepVerifier.create(client.updateMessage(updatedMessageText, dequeuedMessage.messageId(), dequeuedMessage.popReceipt(), Duration.ofSeconds(1))) + .assertNext(response -> helper.assertResponseStatusCode(response, 204)) + .verifyComplete(); + + StepVerifier.create(client.peekMessages().delaySubscription(Duration.ofSeconds(2))) + .assertNext(response -> assertEquals(updatedMessageText, response.messageText())) + .verifyComplete(); + } + + @Override + public void updateMessageInvalidMessageId() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = client.dequeueMessages().blockFirst(); + assertEquals(messageText, dequeuedMessage.messageText()); + + String updatedMessageText = "updated test message"; + StepVerifier.create(client.updateMessage(updatedMessageText, dequeuedMessage.messageId() + "random", dequeuedMessage.popReceipt(), Duration.ofSeconds(1))) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 404)); + } + + @Override + public void updateMessageInvalidPopReceipt() { + StepVerifier.create(client.create()) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + String messageText = "test message"; + StepVerifier.create(client.enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + DequeuedMessage dequeuedMessage = client.dequeueMessages().blockFirst(); + assertEquals(messageText, dequeuedMessage.messageText()); + + String updatedMessageText = "updated test message"; + StepVerifier.create(client.updateMessage(updatedMessageText, dequeuedMessage.messageId(), dequeuedMessage.popReceipt() + "random", Duration.ofSeconds(1))) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } + + @Override + public void updateMessageQueueDoesNotExist() { + StepVerifier.create(client.updateMessage("queue", "doesn't", "exist", Duration.ofSeconds(5))) + .verifyErrorSatisfies(throwable -> helper.assertExceptionStatusCode(throwable, 400)); + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueClientTests.java b/storage/client/src/test/java/com/azure/storage/queue/QueueClientTests.java new file mode 100644 index 0000000000000..dd552e693f90e --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueClientTests.java @@ -0,0 +1,654 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.rest.Response; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.queue.models.AccessPolicy; +import com.azure.storage.queue.models.DequeuedMessage; +import com.azure.storage.queue.models.PeekedMessage; +import com.azure.storage.queue.models.QueueProperties; +import com.azure.storage.queue.models.SignedIdentifier; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.UpdatedMessage; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +public class QueueClientTests extends QueueClientTestsBase { + private final ClientLogger logger = new ClientLogger(QueueClientTests.class); + + private QueueClient client; + + @Override + protected void beforeTest() { + queueName = getQueueName(); + helper = new TestHelpers(); + + if (interceptorManager.isPlaybackMode()) { + client = helper.setupClient((connectionString, endpoint) -> QueueClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .queueName(queueName) + .httpClient(interceptorManager.getPlaybackClient()) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .build(), true, logger); + } else { + client = helper.setupClient((connectionString, endpoint) -> QueueClient.builder() + .endpoint(endpoint) + .queueName(queueName) + .httpClient(HttpClient.createDefault().wiretap(true)) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .addPolicy(interceptorManager.getRecordPolicy()) + .build(), false, logger); + } + } + + @Override + protected void afterTest() { + try { + client.clearMessages(); + client.delete(); + } catch (StorageErrorException ex) { + // Queue already delete, that's what we wanted anyways. + } + } + + @Override + public void createWithSharedKey() { + + } + + @Override + public void createWithSASToken() { + // Need to find a way to get SAS tokens from the storage account + } + + @Override + public void createWithMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(metadata), 201); + + QueueProperties properties = client.getProperties().value(); + assertEquals(metadata, properties.metadata()); + } + + @Override + public void createTwiceSameMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(metadata), 201); + helper.assertResponseStatusCode(client.create(metadata), 204); + } + + @Override + public void createTwiceDifferentMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(), 201); + + try { + client.create(metadata); + fail("Creating a queue twice with different metadata values should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 409); + } + } + + @Override + public void deleteExisting() { + helper.assertResponseStatusCode(client.create(), 201); + helper.assertResponseStatusCode(client.enqueueMessage("This queue will be deleted"), 201); + helper.assertResponseStatusCode(client.delete(), 204); + + helper.sleep(Duration.ofSeconds(30)); + + try { + client.enqueueMessage("This should fail"); + fail("Attempting to work with a queue that has been deleted should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void deleteNonExistent() { + try { + client.delete(); + fail("Attempting to delete a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void getProperties() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(metadata), 201); + + Response response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + } + + @Override + public void getPropertiesQueueDoesNotExist() { + try { + client.getProperties(); + fail("Attempting to get properties of a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void setMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(), 201); + + helper.assertResponseStatusCode(client.setMetadata(metadata), 204); + + Response response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + } + + @Override + public void setMetadataQueueDoesNotExist() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + try { + client.setMetadata(metadata); + fail("Attempting to set metadata on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void setInvalidMetadata() { + Map badMetadata = Collections.singletonMap("", "bad metadata"); + + helper.assertResponseStatusCode(client.create(), 201); + try { + client.setMetadata(badMetadata); + fail("Attempting to set invalid metadata on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void deleteMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + helper.assertResponseStatusCode(client.create(metadata), 201); + + Response response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(metadata, response.value().metadata()); + + helper.assertResponseStatusCode(client.setMetadata(null), 204); + + response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + assertEquals(Collections.EMPTY_MAP, response.value().metadata()); + } + + @Override + public void getAccessPolicy() { + helper.assertResponseStatusCode(client.create(), 201); + + Iterable accessPolicies = client.getAccessPolicy(); + assertFalse(accessPolicies.iterator().hasNext()); + } + + @Override + public void getAccessPolicyQueueDoesNotExist() { + try { + client.getAccessPolicy().iterator().hasNext(); + fail("Attempting to get access policies on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void setAccessPolicy() { + helper.assertResponseStatusCode(client.create(), 201); + + AccessPolicy accessPolicy = new AccessPolicy() + .permission("raup") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + SignedIdentifier permission = new SignedIdentifier() + .id("testpermission") + .accessPolicy(accessPolicy); + + helper.assertResponseStatusCode(client.setAccessPolicy(Collections.singletonList(permission)), 204); + + Iterator accessPolicies = client.getAccessPolicy().iterator(); + helper.assertPermissionsAreEqual(permission, accessPolicies.next()); + assertFalse(accessPolicies.hasNext()); + } + + @Override + public void setAccessPolicyQueueDoesNotExist() { + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.now()) + .expiry(OffsetDateTime.now()); + + SignedIdentifier permission = new SignedIdentifier() + .id("test-permission") + .accessPolicy(accessPolicy); + + try { + client.setAccessPolicy(Collections.singletonList(permission)); + fail("Attempting to set access policies on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void setInvalidAccessPolicy() { + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + SignedIdentifier permission = new SignedIdentifier() + .id("theidofthispermissionislongerthanwhatisallowedbytheserviceandshouldfail") + .accessPolicy(accessPolicy); + + helper.assertResponseStatusCode(client.create(), 201); + + try { + client.setAccessPolicy(Collections.singletonList(permission)); + fail("Attempting to set invalid access policies on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void setTooManyAccessPolicies() { + List permissions = new ArrayList<>(); + + AccessPolicy accessPolicy = new AccessPolicy() + .permission("r") + .start(OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 0, 0), ZoneOffset.UTC)) + .expiry(OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 0, 0), ZoneOffset.UTC)); + + for (int i = 0; i < 6; i++) { + permissions.add(new SignedIdentifier() + .id("policy" + i) + .accessPolicy(accessPolicy)); + } + + helper.assertResponseStatusCode(client.create(), 201); + + try { + client.setAccessPolicy(permissions); + fail("Attempting to set more than five access policies on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void enqueueMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.peekMessages().iterator(); + assertEquals(messageText, response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void enqueueEmptyMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = ""; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.peekMessages().iterator(); + assertNull(response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void enqueueShortTimeToLiveMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText, Duration.ofSeconds(0), Duration.ofSeconds(2)), 201); + + helper.sleep(Duration.ofSeconds(5)); + Iterator response = client.peekMessages().iterator(); + assertFalse(response.hasNext()); + } + + @Override + public void enqueueQueueDoesNotExist() { + try { + client.enqueueMessage("This should fail"); + fail("Attempting to enqueue a message on a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void dequeueMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + assertEquals(messageText, response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void dequeueMultipleMessages() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + String messageText2 = "test message 2"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + helper.assertResponseStatusCode(client.enqueueMessage(messageText2), 201); + + Iterator response = client.dequeueMessages(2).iterator(); + assertEquals(messageText, response.next().messageText()); + assertEquals(messageText2, response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void dequeueTooManyMessages() { + helper.assertResponseStatusCode(client.create(), 201); + + try { + client.dequeueMessages(64).iterator().hasNext(); + fail("Attempting to get more than 32 messages from a queue should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void dequeueQueueDoesNotExist() { + try { + client.dequeueMessages().iterator().hasNext(); + fail("Attempting to get messages from a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void peekMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.peekMessages().iterator(); + assertEquals(messageText, response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void peekMultipleMessages() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + String messageText2 = "test message 2"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + helper.assertResponseStatusCode(client.enqueueMessage(messageText2), 201); + + Iterator response = client.peekMessages(2).iterator(); + assertEquals(messageText, response.next().messageText()); + assertEquals(messageText2, response.next().messageText()); + assertFalse(response.hasNext()); + } + + @Override + public void peekTooManyMessages() { + helper.assertResponseStatusCode(client.create(), 201); + + try { + client.peekMessages(64).iterator().hasNext(); + fail("Attempting to peek more than 32 messages from a queue should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void peekQueueDoesNotExist() { + try { + client.peekMessages().iterator().hasNext(); + fail("Attempting to peek messages from a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void clearMessages() { + helper.assertResponseStatusCode(client.create(), 201); + + for (int i = 0; i < 3; i++) { + helper.assertResponseStatusCode(client.enqueueMessage("test message"), 201); + } + + Response response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(3, response.value().approximateMessagesCount()); + + helper.assertResponseStatusCode(client.clearMessages(), 204); + + response = client.getProperties(); + helper.assertResponseStatusCode(response, 200); + assertEquals(0, response.value().approximateMessagesCount()); + } + + @Override + public void clearMessagesQueueDoesNotExist() { + try { + client.clearMessages(); + fail("Attempting to clear messages of a queue that doesn't exist should throw an exception"); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void deleteMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertFalse(response.hasNext()); + assertEquals(messageText, message.messageText()); + + helper.assertResponseStatusCode(client.deleteMessage(message.messageId(), message.popReceipt()), 204); + + Response propertiesResponse = client.getProperties(); + helper.assertResponseStatusCode(propertiesResponse, 200); + assertEquals(0, propertiesResponse.value().approximateMessagesCount()); + } + + @Override + public void deleteMessageInvalidMessageId() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertFalse(response.hasNext()); + assertEquals(messageText, message.messageText()); + + try { + client.deleteMessage(message.messageId() + "random", message.popReceipt()); + fail("Attempting to delete a message with an invalid ID should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void deleteMessageInvalidPopReceipt() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertFalse(response.hasNext()); + assertEquals(messageText, message.messageText()); + + try { + client.deleteMessage(message.messageId(), message.popReceipt() + "random"); + fail("Attempting to delete a message with an invalid popReceipt should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void deleteMessageQueueDoesNotExist() { + try { + client.deleteMessage("invalid", "call"); + fail("Attempting to delete a message from a queue that doesn't exist should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void updateMessage() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertEquals(messageText, message.messageText()); + assertFalse(response.hasNext()); + + String updatedMessageText = "updated test message"; + Response updatedMessageResponse = client.updateMessage(updatedMessageText, message.messageId(), message.popReceipt(), Duration.ofSeconds(1)); + helper.assertResponseStatusCode(updatedMessageResponse, 204); + + helper.sleep(Duration.ofSeconds(2)); + + Iterator peekedMessageIterator = client.peekMessages().iterator(); + PeekedMessage peekedMessage = peekedMessageIterator.next(); + assertEquals(updatedMessageText, peekedMessage.messageText()); + assertFalse(peekedMessageIterator.hasNext()); + } + + @Override + public void updateMessageInvalidMessageId() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertEquals(messageText, message.messageText()); + assertFalse(response.hasNext()); + + String updatedMessageText = "updated test message"; + try { + client.updateMessage(updatedMessageText, message.messageId() + "random", message.popReceipt(), Duration.ofSeconds(1)); + fail("Attempting to update a message with an invalid ID should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void updateMessageInvalidPopReceipt() { + helper.assertResponseStatusCode(client.create(), 201); + + String messageText = "test message"; + helper.assertResponseStatusCode(client.enqueueMessage(messageText), 201); + + Iterator response = client.dequeueMessages().iterator(); + DequeuedMessage message = response.next(); + assertEquals(messageText, message.messageText()); + assertFalse(response.hasNext()); + + String updatedMessageText = "updated test message"; + try { + client.updateMessage(updatedMessageText, message.messageId(), message.popReceipt() + "random", Duration.ofSeconds(1)); + fail("Attempting to update a message with an invalid popReceipt should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } + + @Override + public void updateMessageQueueDoesNotExist() { + try { + client.updateMessage("queue", "doesn't", "exist", Duration.ofSeconds(5)); + fail("Attempting to update a message on a queue that doesn't exist should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 400); + } + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueClientTestsBase.java b/storage/client/src/test/java/com/azure/storage/queue/QueueClientTestsBase.java new file mode 100644 index 0000000000000..b83d9a1459bbc --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueClientTestsBase.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.test.TestBase; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public abstract class QueueClientTestsBase extends TestBase { + String queueName; + TestHelpers helper; + + @Rule + public TestName testName = new TestName(); + + @Override + public String testName() { + return testName.getMethodName(); + } + + String getQueueName() { + return testResourceNamer.randomName("queue", 16).toLowerCase(); + } + + @Test + public abstract void createWithSharedKey(); + + @Test + public abstract void createWithSASToken(); + + @Test + public abstract void createWithMetadata(); + + @Test + public abstract void createTwiceSameMetadata(); + + @Test + public abstract void createTwiceDifferentMetadata(); + + @Test + public abstract void deleteExisting(); + + @Test + public abstract void deleteNonExistent(); + + @Test + public abstract void getProperties(); + + @Test + public abstract void getPropertiesQueueDoesNotExist(); + + @Test + public abstract void setMetadata(); + + @Test + public abstract void setMetadataQueueDoesNotExist(); + + @Test + public abstract void setInvalidMetadata(); + + @Test + public abstract void deleteMetadata(); + + @Test + public abstract void getAccessPolicy(); + + @Test + public abstract void getAccessPolicyQueueDoesNotExist(); + + @Test + public abstract void setAccessPolicy(); + + @Test + public abstract void setAccessPolicyQueueDoesNotExist(); + + @Test + public abstract void setInvalidAccessPolicy(); + + @Test + public abstract void setTooManyAccessPolicies(); + + @Test + public abstract void enqueueMessage(); + + @Test + public abstract void enqueueEmptyMessage(); + + @Test + public abstract void enqueueShortTimeToLiveMessage(); + + @Test + public abstract void enqueueQueueDoesNotExist(); + + @Test + public abstract void dequeueMessage(); + + @Test + public abstract void dequeueMultipleMessages(); + + @Test + public abstract void dequeueTooManyMessages(); + + @Test + public abstract void dequeueQueueDoesNotExist(); + + @Test + public abstract void peekMessage(); + + @Test + public abstract void peekMultipleMessages(); + + @Test + public abstract void peekTooManyMessages(); + + @Test + public abstract void peekQueueDoesNotExist(); + + @Test + public abstract void clearMessages(); + + @Test + public abstract void clearMessagesQueueDoesNotExist(); + + @Test + public abstract void deleteMessage(); + + @Test + public abstract void deleteMessageInvalidMessageId(); + + @Test + public abstract void deleteMessageInvalidPopReceipt(); + + @Test + public abstract void deleteMessageQueueDoesNotExist(); + + @Test + public abstract void updateMessage(); + + @Test + public abstract void updateMessageInvalidMessageId(); + + @Test + public abstract void updateMessageInvalidPopReceipt(); + + @Test + public abstract void updateMessageQueueDoesNotExist(); +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueServiceAsyncClientTests.java b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceAsyncClientTests.java new file mode 100644 index 0000000000000..270ecaffbf3ac --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceAsyncClientTests.java @@ -0,0 +1,250 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.queue.models.Logging; +import com.azure.storage.queue.models.Metrics; +import com.azure.storage.queue.models.QueueItem; +import com.azure.storage.queue.models.QueuesSegmentOptions; +import com.azure.storage.queue.models.RetentionPolicy; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.StorageServiceProperties; +import reactor.test.StepVerifier; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class QueueServiceAsyncClientTests extends QueueServiceClientTestsBase { + private final ClientLogger logger = new ClientLogger(QueueServiceAsyncClientTests.class); + + private QueueServiceAsyncClient serviceClient; + + @Override + protected void beforeTest() { + queueName = getQueueName(); + helper = new TestHelpers(); + + if (interceptorManager.isPlaybackMode()) { + serviceClient = helper.setupClient((connectionString, endpoint) -> QueueServiceAsyncClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .httpClient(interceptorManager.getPlaybackClient()) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .buildAsync(), true, logger); + } else { + serviceClient = helper.setupClient((connectionString, endpoint) -> QueueServiceAsyncClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .httpClient(HttpClient.createDefault().wiretap(true)) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .addPolicy(interceptorManager.getRecordPolicy()) + .buildAsync(), false, logger); + } + } + + @Override + protected void afterTest() { + serviceClient.listQueues(new QueuesSegmentOptions().prefix(queueName)) + .collectList() + .block() + .forEach(queue -> { + QueueAsyncClient client = serviceClient.getQueueAsyncClient(queue.name()); + try { + client.clearMessages().then(client.delete()).block(); + } catch (StorageErrorException ex) { + // Queue already delete, that's what we wanted anyways. + } + }); + } + + @Override + public void getQueueDoesNotCreateAQueue() { + StepVerifier.create(serviceClient.getQueueAsyncClient(queueName).enqueueMessage("Expecting an exception")); + } + + @Override + public void createQueue() { + StepVerifier.create(serviceClient.createQueue(queueName).block().value().enqueueMessage("Testing service client creating a queue")) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + } + + @Override + public void createQueueWithMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + QueueAsyncClient client = serviceClient.createQueue(queueName, metadata).block().value(); + + StepVerifier.create(client.getProperties()) + .assertNext(response -> { + assertEquals(metadata, response.value().metadata()); + }) + .verifyComplete(); + } + + @Override + public void createQueueTwiceSameMetadata() { + final String messageText = "Testing service client creating the same queue twice does not modify the queue"; + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + StepVerifier.create(serviceClient.createQueue(queueName, metadata).block().value().enqueueMessage(messageText)) + .assertNext(response -> helper.assertResponseStatusCode(response, 201)) + .verifyComplete(); + + StepVerifier.create(serviceClient.createQueue(queueName, metadata).block().value().peekMessages()) + .assertNext(response -> assertEquals(messageText, response.messageText())) + .verifyComplete(); + } + + @Override + public void createQueueTwiceDifferentMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + try { + serviceClient.createQueue(queueName); + serviceClient.createQueue(queueName, metadata); + } catch (Exception exception) { + } + } + + @Override + public void deleteExistingQueue() { + QueueAsyncClient client = serviceClient.createQueue(queueName).block().value(); + serviceClient.deleteQueue(queueName).block(); + + StepVerifier.create(client.enqueueMessage("Expecting an exception")); + } + + @Override + public void deleteNonExistentQueue() { + try { + serviceClient.deleteQueue(queueName); + } catch (Exception exception) { + } + } + + @Override + public void listQueues() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()).block(); + } + + StepVerifier.create(serviceClient.listQueues(defaultSegmentOptions())) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .verifyComplete(); + } + + @Override + public void listQueuesIncludeMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + if (i % 2 == 0) { + queue.metadata(metadata); + } + + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()).block(); + } + + StepVerifier.create(serviceClient.listQueues(defaultSegmentOptions().includeMetadata(true))) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .verifyComplete(); + } + + @Override + public void listQueuesWithPrefix() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem(); + if (i % 2 == 0) { + queue.name(queueName + "prefix" + i); + testQueues.add(queue); + } else { + queue.name(queueName + i); + } + + serviceClient.createQueue(queue.name(), queue.metadata()).block(); + } + + StepVerifier.create(serviceClient.listQueues(defaultSegmentOptions().prefix(queueName + "prefix"))) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .assertNext(result -> helper.assertQueuesAreEqual(testQueues.pop(), result)) + .verifyComplete(); + } + + @Override + public void listQueuesWithLimit() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()).block(); + } + + StepVerifier.create(serviceClient.listQueues(defaultSegmentOptions().maxResults(2))) + .verifyComplete(); + } + + @Override + public void setProperties() { + StorageServiceProperties originalProperties = serviceClient.getProperties().block().value(); + + RetentionPolicy retentionPolicy = new RetentionPolicy().enabled(true) + .days(3); + + Logging logging = new Logging().version("1.0") + .delete(true) + .write(true) + .retentionPolicy(retentionPolicy); + + Metrics metrics = new Metrics().enabled(true) + .includeAPIs(false) + .retentionPolicy(retentionPolicy) + .version("1.0"); + + StorageServiceProperties updatedProperties = new StorageServiceProperties().logging(logging) + .hourMetrics(metrics) + .minuteMetrics(metrics) + .cors(new ArrayList<>()); + + StepVerifier.create(serviceClient.setProperties(updatedProperties)) + .assertNext(response -> helper.assertResponseStatusCode(response, 202)) + .verifyComplete(); + + StepVerifier.create(serviceClient.getProperties()) + .assertNext(response -> helper.assertQueueServicePropertiesAreEqual(updatedProperties, response.value())) + .verifyComplete(); + + StepVerifier.create(serviceClient.setProperties(originalProperties)) + .assertNext(response -> helper.assertResponseStatusCode(response, 202)) + .verifyComplete(); + + StepVerifier.create(serviceClient.getProperties()) + .assertNext(response -> helper.assertQueueServicePropertiesAreEqual(originalProperties, response.value())) + .verifyComplete(); + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTests.java b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTests.java new file mode 100644 index 0000000000000..cb4e034fc5f2b --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTests.java @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.VoidResponse; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.queue.models.EnqueuedMessage; +import com.azure.storage.queue.models.Logging; +import com.azure.storage.queue.models.Metrics; +import com.azure.storage.queue.models.PeekedMessage; +import com.azure.storage.queue.models.QueueItem; +import com.azure.storage.queue.models.QueueProperties; +import com.azure.storage.queue.models.QueuesSegmentOptions; +import com.azure.storage.queue.models.RetentionPolicy; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.StorageServiceProperties; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +public class QueueServiceClientTests extends QueueServiceClientTestsBase { + private final ClientLogger logger = new ClientLogger(QueueServiceClientTests.class); + + private QueueServiceClient serviceClient; + + @Override + protected void beforeTest() { + queueName = getQueueName(); + helper = new TestHelpers(); + + if (interceptorManager.isPlaybackMode()) { + serviceClient = helper.setupClient((connectionString, endpoint) -> QueueServiceClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .httpClient(interceptorManager.getPlaybackClient()) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .build(), true, logger); + } else { + serviceClient = helper.setupClient((connectionString, endpoint) -> QueueServiceClient.builder() + .connectionString(connectionString) + .endpoint(endpoint) + .httpClient(HttpClient.createDefault().wiretap(true)) + .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) + .addPolicy(interceptorManager.getRecordPolicy()) + .build(), false, logger); + } + } + + @Override + protected void afterTest() { + serviceClient.listQueues(new QueuesSegmentOptions().prefix(queueName)) + .forEach(queueToDelete -> { + try { + QueueClient client = serviceClient.getQueueClient(queueToDelete.name()); + client.clearMessages(); + client.delete(); + } catch (StorageErrorException ex) { + // Queue already delete, that's what we wanted anyways. + } + }); + } + + @Override + public void getQueueDoesNotCreateAQueue() { + try { + serviceClient.getQueueClient(queueName).enqueueMessage("Expecting an exception"); + fail("getQueueClient doesn't create a queue in Azure Storage."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void createQueue() { + QueueClient client = serviceClient.createQueue(queueName).value(); + Response response = client.enqueueMessage("Testing service client creating a queue"); + helper.assertResponseStatusCode(response, 201); + } + + @Override + public void createQueueWithMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + QueueClient client = serviceClient.createQueue(queueName, metadata).value(); + + Response propertiesResponse = client.getProperties(); + helper.assertResponseStatusCode(propertiesResponse, 200); + assertEquals(metadata, propertiesResponse.value().metadata()); + } + + @Override + public void createQueueTwiceSameMetadata() { + final String messageText = "Testing service client creating the same queue twice does not modify the queue"; + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + EnqueuedMessage enqueuedMessage = serviceClient.createQueue(queueName, metadata).value().enqueueMessage(messageText).value(); + assertNotNull(enqueuedMessage); + + PeekedMessage peekedMessage = serviceClient.createQueue(queueName, metadata).value().peekMessages().iterator().next(); + assertEquals(messageText, peekedMessage.messageText()); + } + + @Override + public void createQueueTwiceDifferentMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + try { + serviceClient.createQueue(queueName); + serviceClient.createQueue(queueName, metadata); + fail("Creating a queue twice with different metadata should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 409); + } + } + + @Override + public void deleteExistingQueue() { + QueueClient client = serviceClient.createQueue(queueName).value(); + serviceClient.deleteQueue(queueName); + + try { + client.enqueueMessage("Expecting an exception"); + fail("Attempting to enqueue a message on a client that has been delete should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void deleteNonExistentQueue() { + try { + serviceClient.deleteQueue(queueName); + fail("Attempting to delete a queue that doesn't exist should throw an exception."); + } catch (Exception exception) { + helper.assertExceptionStatusCode(exception, 404); + } + } + + @Override + public void listQueues() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()); + } + + for (QueueItem queue : serviceClient.listQueues(defaultSegmentOptions())) { + helper.assertQueuesAreEqual(testQueues.pop(), queue); + } + } + + @Override + public void listQueuesIncludeMetadata() { + Map metadata = new HashMap<>(); + metadata.put("metadata1", "value1"); + metadata.put("metadata2", "value2"); + + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + if (i % 2 == 0) { + queue.metadata(metadata); + } + + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()); + } + + for (QueueItem queue : serviceClient.listQueues(defaultSegmentOptions().includeMetadata(true))) { + helper.assertQueuesAreEqual(testQueues.pop(), queue); + } + } + + @Override + public void listQueuesWithPrefix() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem(); + if (i % 2 == 0) { + queue.name(queueName + "prefix" + i); + testQueues.add(queue); + } else { + queue.name(queueName + i); + } + + serviceClient.createQueue(queue.name(), queue.metadata()); + } + + for (QueueItem queue : serviceClient.listQueues(defaultSegmentOptions().prefix(queueName + "prefix"))) { + helper.assertQueuesAreEqual(testQueues.pop(), queue); + } + } + + @Override + public void listQueuesWithLimit() { + LinkedList testQueues = new LinkedList<>(); + for (int i = 0; i < 3; i++) { + QueueItem queue = new QueueItem().name(queueName + i); + testQueues.add(queue); + serviceClient.createQueue(queue.name(), queue.metadata()); + } + + for (QueueItem queue : serviceClient.listQueues(defaultSegmentOptions().maxResults(2))) { + helper.assertQueuesAreEqual(testQueues.pop(), queue); + } + } + + @Override + public void setProperties() { + StorageServiceProperties originalProperties = serviceClient.getProperties().value(); + + RetentionPolicy retentionPolicy = new RetentionPolicy().enabled(true) + .days(3); + + Logging logging = new Logging().version("1.0") + .delete(true) + .write(true) + .retentionPolicy(retentionPolicy); + + Metrics metrics = new Metrics().enabled(true) + .includeAPIs(false) + .retentionPolicy(retentionPolicy) + .version("1.0"); + + StorageServiceProperties updatedProperties = new StorageServiceProperties().logging(logging) + .hourMetrics(metrics) + .minuteMetrics(metrics) + .cors(new ArrayList<>()); + + VoidResponse setResponse = serviceClient.setProperties(updatedProperties); + helper.assertResponseStatusCode(setResponse, 202); + + Response getResponse = serviceClient.getProperties(); + helper.assertQueueServicePropertiesAreEqual(updatedProperties, getResponse.value()); + + setResponse = serviceClient.setProperties(originalProperties); + helper.assertResponseStatusCode(setResponse, 202); + + getResponse = serviceClient.getProperties(); + helper.assertQueueServicePropertiesAreEqual(originalProperties, getResponse.value()); + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTestsBase.java b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTestsBase.java new file mode 100644 index 0000000000000..3b86144d6f225 --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/QueueServiceClientTestsBase.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.test.TestBase; +import com.azure.storage.queue.models.QueuesSegmentOptions; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public abstract class QueueServiceClientTestsBase extends TestBase { + String queueName; + TestHelpers helper; + + @Rule + public TestName testName = new TestName(); + + @Override + public String testName() { + return testName.getMethodName(); + } + + String getQueueName() { + return testResourceNamer.randomName("queue", 16).toLowerCase(); + } + + @Test + public abstract void getQueueDoesNotCreateAQueue(); + + @Test + public abstract void createQueue(); + + @Test + public abstract void createQueueWithMetadata(); + + @Test + public abstract void createQueueTwiceSameMetadata(); + + @Test + public abstract void createQueueTwiceDifferentMetadata(); + + @Test + public abstract void deleteExistingQueue(); + + @Test + public abstract void deleteNonExistentQueue(); + + @Test + public abstract void listQueues(); + + @Test + public abstract void listQueuesIncludeMetadata(); + + @Test + public abstract void listQueuesWithPrefix(); + + // TODO (alzimmer): This test is off for now until we determine how to handle paging with limited results + //@Test + public abstract void listQueuesWithLimit(); + + @Test + public abstract void setProperties(); + + QueuesSegmentOptions defaultSegmentOptions() { + return new QueuesSegmentOptions().prefix(queueName); + } +} diff --git a/storage/client/src/test/java/com/azure/storage/queue/TestHelpers.java b/storage/client/src/test/java/com/azure/storage/queue/TestHelpers.java new file mode 100644 index 0000000000000..d414f13d194dc --- /dev/null +++ b/storage/client/src/test/java/com/azure/storage/queue/TestHelpers.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.queue; + +import com.azure.core.http.rest.Response; +import com.azure.core.implementation.util.ImplUtils; +import com.azure.core.util.configuration.ConfigurationManager; +import com.azure.core.util.logging.ClientLogger; +import com.azure.storage.queue.models.CorsRule; +import com.azure.storage.queue.models.Logging; +import com.azure.storage.queue.models.Metrics; +import com.azure.storage.queue.models.QueueItem; +import com.azure.storage.queue.models.RetentionPolicy; +import com.azure.storage.queue.models.SignedIdentifier; +import com.azure.storage.queue.models.StorageErrorException; +import com.azure.storage.queue.models.StorageServiceProperties; + +import java.time.Duration; +import java.util.List; +import java.util.function.BiFunction; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Contains helper methods for unit tests. + */ +class TestHelpers { + private final String azureStorageConnectionString = "AZURE_STORAGE_CONNECTION_STRING"; + private final String azureStorageQueueEndpoint = "AZURE_STORAGE_QUEUE_ENDPOINT"; + + T setupClient(BiFunction clientBuilder, boolean isPlaybackMode, ClientLogger logger) { + String connectionString = "DefaultEndpointsProtocol=https;AccountName=teststorage;AccountKey=atestaccountkey;EndpointSuffix=core.windows.net"; + String queueEndpoint = "https://teststorage.queue.core.windows.net/"; + + if (!isPlaybackMode) { + connectionString = ConfigurationManager.getConfiguration().get(azureStorageConnectionString); + queueEndpoint = ConfigurationManager.getConfiguration().get(azureStorageQueueEndpoint); + } + + if (ImplUtils.isNullOrEmpty(connectionString) && ImplUtils.isNullOrEmpty(queueEndpoint)) { + logger.asWarning().log("{} and {} must be set to build the testing client", azureStorageConnectionString, azureStorageQueueEndpoint); + fail(); + return null; + } + + return clientBuilder.apply(connectionString, queueEndpoint); + } + + void assertQueuesAreEqual(QueueItem expected, QueueItem actual) { + if (expected == null) { + assertNull(actual); + } else { + assertEquals(expected.name(), actual.name()); + + if (expected.metadata() != null && !ImplUtils.isNullOrEmpty(actual.metadata())) { + assertEquals(expected.metadata(), actual.metadata()); + } + } + } + + void assertQueueServicePropertiesAreEqual(StorageServiceProperties expected, StorageServiceProperties actual) { + if (expected == null) { + assertNull(actual); + } else { + assertMetricsAreEqual(expected.hourMetrics(), actual.hourMetrics()); + assertMetricsAreEqual(expected.minuteMetrics(), actual.minuteMetrics()); + assertLoggingAreEqual(expected.logging(), actual.logging()); + assertCorsAreEqual(expected.cors(), actual.cors()); + } + } + + private void assertMetricsAreEqual(Metrics expected, Metrics actual) { + if (expected == null) { + assertNull(actual); + } else { + assertEquals(expected.enabled(), actual.enabled()); + assertEquals(expected.includeAPIs(), actual.includeAPIs()); + assertEquals(expected.version(), actual.version()); + assertRetentionPoliciesAreEqual(expected.retentionPolicy(), actual.retentionPolicy()); + } + } + + private void assertLoggingAreEqual(Logging expected, Logging actual) { + if (expected == null) { + assertNull(actual); + } else { + assertEquals(expected.read(), actual.read()); + assertEquals(expected.write(), actual.write()); + assertEquals(expected.delete(), actual.delete()); + assertEquals(expected.version(), actual.version()); + assertRetentionPoliciesAreEqual(expected.retentionPolicy(), actual.retentionPolicy()); + } + } + + private void assertRetentionPoliciesAreEqual(RetentionPolicy expected, RetentionPolicy actual) { + if (expected == null) { + assertNull(actual); + } else { + assertEquals(expected.days(), actual.days()); + assertEquals(expected.enabled(), actual.enabled()); + } + } + + private void assertCorsAreEqual(List expected, List actual) { + if (expected == null) { + assertTrue(ImplUtils.isNullOrEmpty(actual)); + } else { + assertEquals(expected.size(), actual.size()); + for (int i = 0; i < expected.size(); i++) { + assertCorRulesAreEqual(expected.get(i), actual.get(i)); + } + } + } + + private void assertCorRulesAreEqual(CorsRule expected, CorsRule actual) { + if (expected == null) { + assertNull(actual); + } else { + assertEquals(expected.allowedHeaders(), actual.allowedHeaders()); + assertEquals(expected.allowedMethods(), actual.allowedMethods()); + assertEquals(expected.allowedOrigins(), actual.allowedOrigins()); + assertEquals(expected.exposedHeaders(), actual.exposedHeaders()); + assertEquals(expected.maxAgeInSeconds(), actual.maxAgeInSeconds()); + } + } + + void assertPermissionsAreEqual(SignedIdentifier expected, SignedIdentifier actual) { + assertEquals(expected.id(), actual.id()); + assertEquals(expected.accessPolicy().permission(), actual.accessPolicy().permission()); + assertEquals(expected.accessPolicy().start(), actual.accessPolicy().start()); + assertEquals(expected.accessPolicy().expiry(), actual.accessPolicy().expiry()); + } + + void assertResponseStatusCode(Response response, int expectedStatusCode) { + assertEquals(expectedStatusCode, response.statusCode()); + } + + void assertExceptionStatusCode(Throwable throwable, int expectedStatusCode) { + assertTrue(throwable instanceof StorageErrorException); + StorageErrorException storageErrorException = (StorageErrorException) throwable; + assertEquals(expectedStatusCode, storageErrorException.response().statusCode()); + } + + void sleep(Duration duration) { + try { + Thread.sleep(duration.toMillis()); + } catch (InterruptedException ex) { + // Ignore the errror + } + } +} diff --git a/storage/client/src/test/resources/session-records/clearMessages.json b/storage/client/src/test/resources/session-records/clearMessages.json new file mode 100644 index 0000000000000..2fc906e46ed18 --- /dev/null +++ b/storage/client/src/test/resources/session-records/clearMessages.json @@ -0,0 +1,161 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8460-c003-001a-760c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd846e-c003-001a-010c-23e044000000", + "Body" : "d485a4d4-faa9-4e90-aae9-650ff8790a7bFri, 14 Jun 2019 23:54:29 GMTFri, 21 Jun 2019 23:54:29 GMTAgAAAAMAAAAAAAAAsNc9gQwj1QE=Fri, 14 Jun 2019 23:54:29 GMT" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8477-c003-001a-090c-23e044000000", + "Body" : "7a26f870-86be-469e-94c7-6ae6faef3d79Fri, 14 Jun 2019 23:54:29 GMTFri, 21 Jun 2019 23:54:29 GMTAgAAAAMAAAAAAAAAl1NFgQwj1QE=Fri, 14 Jun 2019 23:54:29 GMT" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8483-c003-001a-130c-23e044000000", + "Body" : "5b058f88-9a64-4622-bd47-4ec8230c8830Fri, 14 Jun 2019 23:54:29 GMTFri, 21 Jun 2019 23:54:29 GMTAgAAAAMAAAAAAAAAaahMgQwj1QE=Fri, 14 Jun 2019 23:54:29 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "3", + "StatusCode" : "200", + "x-ms-request-id" : "eecd848d-c003-001a-1b0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8491-c003-001a-1f0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "eecd849f-c003-001a-2a0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd84a9-c003-001a-320c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue00553575", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd84b1-c003-001a-390c-23e044000000" + } + } ], + "variables" : [ "queue00553575" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/clearMessagesQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/clearMessagesQueueDoesNotExist.json new file mode 100644 index 0000000000000..0947c2e98be0b --- /dev/null +++ b/storage/client/src/test/resources/session-records/clearMessagesQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue91140320/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd88a7-c003-001a-660c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd88a7-c003-001a-660c-23e044000000\nTime:2019-06-14T23:54:33.8950205Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue91140320/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd88af-c003-001a-6d0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd88af-c003-001a-6d0c-23e044000000\nTime:2019-06-14T23:54:33.9320554Z" + } + } ], + "variables" : [ "queue91140320" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createQueue.json b/storage/client/src/test/resources/session-records/createQueue.json new file mode 100644 index 0000000000000..2abe48d5cd0ef --- /dev/null +++ b/storage/client/src/test/resources/session-records/createQueue.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue87446889", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdae0b-c003-001a-780c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue87446889/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdae17-c003-001a-030c-23e044000000", + "Body" : "93de04dd-c384-41c2-a49d-5a0ab3436cc7Fri, 14 Jun 2019 23:55:11 GMTFri, 21 Jun 2019 23:55:11 GMTAgAAAAMAAAAAAAAAxWm5mgwj1QE=Fri, 14 Jun 2019 23:55:11 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue87446889&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdae22-c003-001a-0c0c-23e044000000", + "Body" : "queue87446889queue87446889" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue87446889/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdae33-c003-001a-1c0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue87446889", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdae41-c003-001a-2a0c-23e044000000" + } + } ], + "variables" : [ "queue87446889" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createQueueTwiceDifferentMetadata.json b/storage/client/src/test/resources/session-records/createQueueTwiceDifferentMetadata.json new file mode 100644 index 0000000000000..2b583a3bcc408 --- /dev/null +++ b/storage/client/src/test/resources/session-records/createQueueTwiceDifferentMetadata.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue15394db0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdafaa-c003-001a-720c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue15394db0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "222", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueAlreadyExists", + "retry-after" : "0", + "StatusCode" : "409", + "x-ms-request-id" : "eecdafb7-c003-001a-7d0c-23e044000000", + "Body" : "QueueAlreadyExistsThe specified queue already exists.\nRequestId:eecdafb7-c003-001a-7d0c-23e044000000\nTime:2019-06-14T23:55:13.6747336Z" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue15394db0&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdafc1-c003-001a-070c-23e044000000", + "Body" : "queue15394db0queue15394db0" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue15394db0/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdafcb-c003-001a-100c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue15394db0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdafd4-c003-001a-180c-23e044000000" + } + } ], + "variables" : [ "queue15394db0" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createQueueTwiceSameMetadata.json b/storage/client/src/test/resources/session-records/createQueueTwiceSameMetadata.json new file mode 100644 index 0000000000000..8c19da9b2451d --- /dev/null +++ b/storage/client/src/test/resources/session-records/createQueueTwiceSameMetadata.json @@ -0,0 +1,125 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaf2b-c003-001a-020c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaf39-c003-001a-0f0c-23e044000000", + "Body" : "df79b53d-66e8-4cb8-bd39-9e5133600f4cFri, 14 Jun 2019 23:55:13 GMTFri, 21 Jun 2019 23:55:13 GMTAgAAAAMAAAAAAAAApo15mwwj1QE=Fri, 14 Jun 2019 23:55:13 GMT" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf41-c003-001a-150c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaf4d-c003-001a-1e0c-23e044000000", + "Body" : "df79b53d-66e8-4cb8-bd39-9e5133600f4cFri, 14 Jun 2019 23:55:13 GMTFri, 21 Jun 2019 23:55:13 GMT0Testing service client creating the same queue twice does not modify the queue" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue9577903d&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaf57-c003-001a-270c-23e044000000", + "Body" : "queue9577903dqueue9577903d" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf60-c003-001a-300c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9577903d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf6f-c003-001a-3e0c-23e044000000" + } + } ], + "variables" : [ "queue9577903d" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createQueueWithMetadata.json b/storage/client/src/test/resources/session-records/createQueueWithMetadata.json new file mode 100644 index 0000000000000..f9aba820e6cd9 --- /dev/null +++ b/storage/client/src/test/resources/session-records/createQueueWithMetadata.json @@ -0,0 +1,91 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue90065f84", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdae97-c003-001a-7f0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue90065f84?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "x-ms-meta-metadata1" : "value1", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaea1-c003-001a-080c-23e044000000", + "x-ms-meta-metadata2" : "value2" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue90065f84&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaeaa-c003-001a-110c-23e044000000", + "Body" : "queue90065f84queue90065f84" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue90065f84/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaeb0-c003-001a-170c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue90065f84", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaeb6-c003-001a-1c0c-23e044000000" + } + } ], + "variables" : [ "queue90065f84" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createTwiceDifferentMetadata.json b/storage/client/src/test/resources/session-records/createTwiceDifferentMetadata.json new file mode 100644 index 0000000000000..207c3a2367ea6 --- /dev/null +++ b/storage/client/src/test/resources/session-records/createTwiceDifferentMetadata.json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1099476e", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda776-c003-001a-760c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1099476e", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "222", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueAlreadyExists", + "retry-after" : "0", + "StatusCode" : "409", + "x-ms-request-id" : "eecda791-c003-001a-0d0c-23e044000000", + "Body" : "QueueAlreadyExistsThe specified queue already exists.\nRequestId:eecda791-c003-001a-0d0c-23e044000000\nTime:2019-06-14T23:55:05.5870661Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1099476e/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda79b-c003-001a-160c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1099476e", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda7ac-c003-001a-240c-23e044000000" + } + } ], + "variables" : [ "queue1099476e" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createTwiceSameMetadata.json b/storage/client/src/test/resources/session-records/createTwiceSameMetadata.json new file mode 100644 index 0000000000000..39fdbefdff687 --- /dev/null +++ b/storage/client/src/test/resources/session-records/createTwiceSameMetadata.json @@ -0,0 +1,68 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue75060784", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda6a9-c003-001a-390c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue75060784", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6b3-c003-001a-420c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue75060784/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6bb-c003-001a-4a0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue75060784", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6c5-c003-001a-540c-23e044000000" + } + } ], + "variables" : [ "queue75060784" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createWithMetadata.json b/storage/client/src/test/resources/session-records/createWithMetadata.json new file mode 100644 index 0000000000000..704e3b9753a2a --- /dev/null +++ b/storage/client/src/test/resources/session-records/createWithMetadata.json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue112575a0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8880-c003-001a-410c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue112575a0?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "x-ms-meta-metadata1" : "value1", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8889-c003-001a-480c-23e044000000", + "x-ms-meta-metadata2" : "value2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue112575a0/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd888f-c003-001a-4e0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue112575a0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd889a-c003-001a-590c-23e044000000" + } + } ], + "variables" : [ "queue112575a0" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createWithSASToken.json b/storage/client/src/test/resources/session-records/createWithSASToken.json new file mode 100644 index 0000000000000..25e307426563b --- /dev/null +++ b/storage/client/src/test/resources/session-records/createWithSASToken.json @@ -0,0 +1,23 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue013951b4/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd8448-c003-001a-5f0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd8448-c003-001a-5f0c-23e044000000\nTime:2019-06-14T23:54:29.0694468Z" + } + } ], + "variables" : [ "queue013951b4" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/createWithSharedKey.json b/storage/client/src/test/resources/session-records/createWithSharedKey.json new file mode 100644 index 0000000000000..b86fb09f0f028 --- /dev/null +++ b/storage/client/src/test/resources/session-records/createWithSharedKey.json @@ -0,0 +1,23 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue85706eb6/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda883-c003-001a-680c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda883-c003-001a-680c-23e044000000\nTime:2019-06-14T23:55:06.4839191Z" + } + } ], + "variables" : [ "queue85706eb6" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteExisting.json b/storage/client/src/test/resources/session-records/deleteExisting.json new file mode 100644 index 0000000000000..db3b15c0566f1 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteExisting.json @@ -0,0 +1,94 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue33228b80", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd892e-c003-001a-610c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue33228b80/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd893d-c003-001a-6c0c-23e044000000", + "Body" : "c163a3ab-35f4-4eb7-a051-b49b6bf1c86dFri, 14 Jun 2019 23:54:34 GMTFri, 21 Jun 2019 23:54:34 GMTAgAAAAMAAAAAAAAA1dpUhAwj1QE=Fri, 14 Jun 2019 23:54:34 GMT" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue33228b80", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8949-c003-001a-780c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue33228b80/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:03 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda692-c003-001a-250c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda692-c003-001a-250c-23e044000000\nTime:2019-06-14T23:55:04.4890263Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue33228b80/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda69b-c003-001a-2c0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda69b-c003-001a-2c0c-23e044000000\nTime:2019-06-14T23:55:04.5240581Z" + } + } ], + "variables" : [ "queue33228b80" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteExistingQueue.json b/storage/client/src/test/resources/session-records/deleteExistingQueue.json new file mode 100644 index 0000000000000..37d33332218a1 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteExistingQueue.json @@ -0,0 +1,75 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue751959b6", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdadda-c003-001a-4a0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue751959b6", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdade5-c003-001a-520c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue751959b6/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecdadf8-c003-001a-650c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecdadf8-c003-001a-650c-23e044000000\nTime:2019-06-14T23:55:11.8179758Z" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue751959b6&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdadfd-c003-001a-6a0c-23e044000000", + "Body" : "queue751959b6" + } + } ], + "variables" : [ "queue751959b6" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteMessage.json b/storage/client/src/test/resources/session-records/deleteMessage.json new file mode 100644 index 0000000000000..436e2ff05fcdd --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteMessage.json @@ -0,0 +1,124 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda831-c003-001a-1a0c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda84a-c003-001a-320c-23e044000000", + "Body" : "14047a6c-7291-4351-908f-88d54a0a2fc6Fri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAAUbFFlwwj1QE=Fri, 14 Jun 2019 23:55:06 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecda84e-c003-001a-360c-23e044000000", + "Body" : "14047a6c-7291-4351-908f-88d54a0a2fc6Fri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAAgb4tqQwj1QE=Fri, 14 Jun 2019 23:55:36 GMT1test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4/messages/14047a6c-7291-4351-908f-88d54a0a2fc6?popreceipt=AgAAAAMAAAAAAAAAgb4tqQwj1QE%3d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda865-c003-001a-4d0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "eecda86b-c003-001a-520c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda879-c003-001a-600c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue424274e4", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda87e-c003-001a-630c-23e044000000" + } + } ], + "variables" : [ "queue424274e4" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteMessageInvalidMessageId.json b/storage/client/src/test/resources/session-records/deleteMessageInvalidMessageId.json new file mode 100644 index 0000000000000..e89d96a79cc66 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteMessageInvalidMessageId.json @@ -0,0 +1,109 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e4d-c003-001a-510c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e57-c003-001a-5a0c-23e044000000", + "Body" : "98293ccf-733d-436e-b27f-9737450ba6fcFri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAA3v1mfQwj1QE=Fri, 14 Jun 2019 23:54:22 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd7e60-c003-001a-620c-23e044000000", + "Body" : "98293ccf-733d-436e-b27f-9737450ba6fcFri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAAeKdPjwwj1QE=Fri, 14 Jun 2019 23:54:52 GMT1test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f/messages/98293ccf-733d-436e-b27f-9737450ba6fcrandom?popreceipt=AgAAAAMAAAAAAAAAeKdPjwwj1QE%3d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "221", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "MessageNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd7e67-c003-001a-690c-23e044000000", + "Body" : "MessageNotFoundThe specified message does not exist.\nRequestId:eecd7e67-c003-001a-690c-23e044000000\nTime:2019-06-14T23:54:22.8665618Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7e70-c003-001a-710c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue4699132f", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7e78-c003-001a-790c-23e044000000" + } + } ], + "variables" : [ "queue4699132f" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteMessageInvalidPopReceipt.json b/storage/client/src/test/resources/session-records/deleteMessageInvalidPopReceipt.json new file mode 100644 index 0000000000000..169b89280efcb --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteMessageInvalidPopReceipt.json @@ -0,0 +1,109 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e02-c003-001a-110c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e0b-c003-001a-190c-23e044000000", + "Body" : "8ad3ddce-42b3-4b9c-b557-f8b64ccc8268Fri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAAdRY6fQwj1QE=Fri, 14 Jun 2019 23:54:22 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd7e18-c003-001a-260c-23e044000000", + "Body" : "8ad3ddce-42b3-4b9c-b557-f8b64ccc8268Fri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAALOcijwwj1QE=Fri, 14 Jun 2019 23:54:52 GMT1test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc/messages/8ad3ddce-42b3-4b9c-b557-f8b64ccc8268?popreceipt=AgAAAAMAAAAAAAAALOcijwwj1QE%3drandom", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "444", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidQueryParameterValue", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecd7e26-c003-001a-310c-23e044000000", + "Body" : "InvalidQueryParameterValueValue for one of the query parameters specified in the request URI is invalid.\nRequestId:eecd7e26-c003-001a-310c-23e044000000\nTime:2019-06-14T23:54:22.5752860ZpopreceiptAgAAAAMAAAAAAAAALOcijwwj1QE=randomInvalid pop receipt format" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7e2f-c003-001a-370c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue966338cc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7e3f-c003-001a-440c-23e044000000" + } + } ], + "variables" : [ "queue966338cc" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteMessageQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/deleteMessageQueueDoesNotExist.json new file mode 100644 index 0000000000000..b5d0b3eeb9948 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteMessageQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue507580a6/messages/invalid?popreceipt=call", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda941-c003-001a-1b0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda941-c003-001a-1b0c-23e044000000\nTime:2019-06-14T23:55:07.2456407Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue507580a6/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda95a-c003-001a-320c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda95a-c003-001a-320c-23e044000000\nTime:2019-06-14T23:55:07.2856782Z" + } + } ], + "variables" : [ "queue507580a6" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteMetadata.json b/storage/client/src/test/resources/session-records/deleteMetadata.json new file mode 100644 index 0000000000000..e1e51ff0c9a02 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteMetadata.json @@ -0,0 +1,106 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda9c5-c003-001a-150c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "x-ms-meta-metadata1" : "value1", + "StatusCode" : "200", + "x-ms-request-id" : "eecda9d3-c003-001a-220c-23e044000000", + "x-ms-meta-metadata2" : "value2" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda9dd-c003-001a-2c0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "eecda9e7-c003-001a-350c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda9f2-c003-001a-3f0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue73797acc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda9fd-c003-001a-480c-23e044000000" + } + } ], + "variables" : [ "queue73797acc" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteNonExistent.json b/storage/client/src/test/resources/session-records/deleteNonExistent.json new file mode 100644 index 0000000000000..c75f19e8a25c6 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteNonExistent.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue37360470", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7da-c003-001a-4b0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7da-c003-001a-4b0c-23e044000000\nTime:2019-06-14T23:55:05.8693364Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue37360470/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7e4-c003-001a-550c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7e4-c003-001a-550c-23e044000000\nTime:2019-06-14T23:55:05.9033676Z" + } + } ], + "variables" : [ "queue37360470" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/deleteNonExistentQueue.json b/storage/client/src/test/resources/session-records/deleteNonExistentQueue.json new file mode 100644 index 0000000000000..92faf1cdce415 --- /dev/null +++ b/storage/client/src/test/resources/session-records/deleteNonExistentQueue.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32273409", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecdb09e-c003-001a-540c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecdb09e-c003-001a-540c-23e044000000\nTime:2019-06-14T23:55:14.3784005Z" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue32273409&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdb0aa-c003-001a-5f0c-23e044000000", + "Body" : "queue32273409" + } + } ], + "variables" : [ "queue32273409" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/dequeueMessage.json b/storage/client/src/test/resources/session-records/dequeueMessage.json new file mode 100644 index 0000000000000..0361bd8b62de9 --- /dev/null +++ b/storage/client/src/test/resources/session-records/dequeueMessage.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue730724f9", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7d87-c003-001a-240c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue730724f9/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7d9a-c003-001a-310c-23e044000000", + "Body" : "99f3ab9f-ce37-4ee4-9e92-afc8e747ba1cFri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAAjTMAfQwj1QE=Fri, 14 Jun 2019 23:54:22 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue730724f9/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd7db2-c003-001a-470c-23e044000000", + "Body" : "99f3ab9f-ce37-4ee4-9e92-afc8e747ba1cFri, 14 Jun 2019 23:54:22 GMTFri, 21 Jun 2019 23:54:22 GMTAgAAAAMAAAAAAAAA2u7pjgwj1QE=Fri, 14 Jun 2019 23:54:52 GMT1test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue730724f9/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7dc2-c003-001a-550c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue730724f9", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd7dce-c003-001a-610c-23e044000000" + } + } ], + "variables" : [ "queue730724f9" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/dequeueMultipleMessages.json b/storage/client/src/test/resources/session-records/dequeueMultipleMessages.json new file mode 100644 index 0000000000000..e58cc4e4f9f57 --- /dev/null +++ b/storage/client/src/test/resources/session-records/dequeueMultipleMessages.json @@ -0,0 +1,109 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda88f-c003-001a-720c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda89a-c003-001a-7c0c-23e044000000", + "Body" : "037d1172-845e-44c5-8225-bc353440c5fbFri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAAVfCClwwj1QE=Fri, 14 Jun 2019 23:55:06 GMT" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda89e-c003-001a-800c-23e044000000", + "Body" : "7aa4883e-d4ff-4935-954a-dfbb91446f60Fri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAA0s+Jlwwj1QE=Fri, 14 Jun 2019 23:55:06 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db/messages?numofmessages=2&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecda8a9-c003-001a-0b0c-23e044000000", + "Body" : "037d1172-845e-44c5-8225-bc353440c5fbFri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAAbQB0qQwj1QE=Fri, 14 Jun 2019 23:55:36 GMT1test message7aa4883e-d4ff-4935-954a-dfbb91446f60Fri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAAbQB0qQwj1QE=Fri, 14 Jun 2019 23:55:36 GMT1test message 2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda8b5-c003-001a-150c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue217443db", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda8bd-c003-001a-1d0c-23e044000000" + } + } ], + "variables" : [ "queue217443db" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/dequeueQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/dequeueQueueDoesNotExist.json new file mode 100644 index 0000000000000..e9491090b9c33 --- /dev/null +++ b/storage/client/src/test/resources/session-records/dequeueQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue83383d42/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7ce-c003-001a-420c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7ce-c003-001a-420c-23e044000000\nTime:2019-06-14T23:55:05.7882579Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue83383d42/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7d5-c003-001a-470c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7d5-c003-001a-470c-23e044000000\nTime:2019-06-14T23:55:05.8232909Z" + } + } ], + "variables" : [ "queue83383d42" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/dequeueTooManyMessages.json b/storage/client/src/test/resources/session-records/dequeueTooManyMessages.json new file mode 100644 index 0000000000000..c2554fa869e16 --- /dev/null +++ b/storage/client/src/test/resources/session-records/dequeueTooManyMessages.json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1049122d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8384-c003-001a-250c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1049122d/messages?numofmessages=64&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "456", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "OutOfRangeQueryParameterValue", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecd8393-c003-001a-320c-23e044000000", + "Body" : "OutOfRangeQueryParameterValueOne of the query parameters specified in the request URI is outside the permissible range.\nRequestId:eecd8393-c003-001a-320c-23e044000000\nTime:2019-06-14T23:54:28.4908949Znumofmessages64132" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1049122d/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd83a3-c003-001a-410c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue1049122d", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd83ad-c003-001a-4b0c-23e044000000" + } + } ], + "variables" : [ "queue1049122d" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/enqueueEmptyMessage.json b/storage/client/src/test/resources/session-records/enqueueEmptyMessage.json new file mode 100644 index 0000000000000..c8035f7d00769 --- /dev/null +++ b/storage/client/src/test/resources/session-records/enqueueEmptyMessage.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06041205", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda8c7-c003-001a-270c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06041205/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda8cc-c003-001a-2b0c-23e044000000", + "Body" : "94ae6cb7-6ee8-49af-9f8d-ec745f3c9c4cFri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMTAgAAAAMAAAAAAAAA+tOxlwwj1QE=Fri, 14 Jun 2019 23:55:06 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06041205/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecda8d4-c003-001a-330c-23e044000000", + "Body" : "94ae6cb7-6ee8-49af-9f8d-ec745f3c9c4cFri, 14 Jun 2019 23:55:06 GMTFri, 21 Jun 2019 23:55:06 GMT0" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06041205/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda8d9-c003-001a-370c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06041205", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda8de-c003-001a-3c0c-23e044000000" + } + } ], + "variables" : [ "queue06041205" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/enqueueMessage.json b/storage/client/src/test/resources/session-records/enqueueMessage.json new file mode 100644 index 0000000000000..b3dcb71f53ffd --- /dev/null +++ b/storage/client/src/test/resources/session-records/enqueueMessage.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52528731", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd84e8-c003-001a-6b0c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52528731/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd84fb-c003-001a-7d0c-23e044000000", + "Body" : "0a0ba8a1-69df-4dc5-aa83-d349e5eea3abFri, 14 Jun 2019 23:54:29 GMTFri, 21 Jun 2019 23:54:29 GMTAgAAAAMAAAAAAAAAOqGvgQwj1QE=Fri, 14 Jun 2019 23:54:29 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52528731/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8507-c003-001a-070c-23e044000000", + "Body" : "0a0ba8a1-69df-4dc5-aa83-d349e5eea3abFri, 14 Jun 2019 23:54:29 GMTFri, 21 Jun 2019 23:54:29 GMT0test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52528731/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8510-c003-001a-100c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52528731", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8516-c003-001a-160c-23e044000000" + } + } ], + "variables" : [ "queue52528731" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/enqueueQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/enqueueQueueDoesNotExist.json new file mode 100644 index 0000000000000..ef94235e8f5e6 --- /dev/null +++ b/storage/client/src/test/resources/session-records/enqueueQueueDoesNotExist.json @@ -0,0 +1,43 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue039365df/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd84bc-c003-001a-430c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd84bc-c003-001a-430c-23e044000000\nTime:2019-06-14T23:54:29.5719227Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue039365df/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd84c1-c003-001a-470c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd84c1-c003-001a-470c-23e044000000\nTime:2019-06-14T23:54:29.6129620Z" + } + } ], + "variables" : [ "queue039365df" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/enqueueShortTimeToLiveMessage.json b/storage/client/src/test/resources/session-records/enqueueShortTimeToLiveMessage.json new file mode 100644 index 0000000000000..d8dfc4e3d5f17 --- /dev/null +++ b/storage/client/src/test/resources/session-records/enqueueShortTimeToLiveMessage.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32619005", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e87-c003-001a-080c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32619005/messages?visibilitytimeout=0&messagettl=2", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:22 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd7e96-c003-001a-160c-23e044000000", + "Body" : "d5f3f8a6-a8a8-4c94-a0ab-ed7198085143Fri, 14 Jun 2019 23:54:23 GMTFri, 14 Jun 2019 23:54:25 GMTAgAAAAMAAAAAAAAAHd6XfQwj1QE=Fri, 14 Jun 2019 23:54:23 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32619005/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8339-c003-001a-640c-23e044000000", + "Body" : "" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32619005/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8341-c003-001a-6c0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32619005", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8355-c003-001a-7e0c-23e044000000" + } + } ], + "variables" : [ "queue32619005" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/getAccessPolicy.json b/storage/client/src/test/resources/session-records/getAccessPolicy.json new file mode 100644 index 0000000000000..90e443cd565ef --- /dev/null +++ b/storage/client/src/test/resources/session-records/getAccessPolicy.json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue414723da", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8571-c003-001a-690c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue414723da?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd857f-c003-001a-760c-23e044000000", + "Body" : "" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue414723da/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8591-c003-001a-010c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue414723da", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd859b-c003-001a-0b0c-23e044000000" + } + } ], + "variables" : [ "queue414723da" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/getAccessPolicyQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/getAccessPolicyQueueDoesNotExist.json new file mode 100644 index 0000000000000..b7f4ae9252641 --- /dev/null +++ b/storage/client/src/test/resources/session-records/getAccessPolicyQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue351703a0?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda761-c003-001a-630c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda761-c003-001a-630c-23e044000000\nTime:2019-06-14T23:55:05.3798691Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue351703a0/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda76b-c003-001a-6c0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda76b-c003-001a-6c0c-23e044000000\nTime:2019-06-14T23:55:05.4149020Z" + } + } ], + "variables" : [ "queue351703a0" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/getProperties.json b/storage/client/src/test/resources/session-records/getProperties.json new file mode 100644 index 0000000000000..4a0d12e313082 --- /dev/null +++ b/storage/client/src/test/resources/session-records/getProperties.json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue84035787", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8415-c003-001a-2e0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue84035787?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "x-ms-meta-metadata1" : "value1", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8421-c003-001a-380c-23e044000000", + "x-ms-meta-metadata2" : "value2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue84035787/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd842c-c003-001a-430c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue84035787", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8431-c003-001a-480c-23e044000000" + } + } ], + "variables" : [ "queue84035787" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/getPropertiesQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/getPropertiesQueueDoesNotExist.json new file mode 100644 index 0000000000000..5e1d1162efe91 --- /dev/null +++ b/storage/client/src/test/resources/session-records/getPropertiesQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue566185ba?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd8368-c003-001a-0e0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd8368-c003-001a-0e0c-23e044000000\nTime:2019-06-14T23:54:28.3437543Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue566185ba/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:27 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd8372-c003-001a-170c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd8372-c003-001a-170c-23e044000000\nTime:2019-06-14T23:54:28.3797886Z" + } + } ], + "variables" : [ "queue566185ba" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/getQueueDoesNotCreateAQueue.json b/storage/client/src/test/resources/session-records/getQueueDoesNotCreateAQueue.json new file mode 100644 index 0000000000000..666273f15c91d --- /dev/null +++ b/storage/client/src/test/resources/session-records/getQueueDoesNotCreateAQueue.json @@ -0,0 +1,43 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue135523a3/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecdaf8a-c003-001a-550c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecdaf8a-c003-001a-550c-23e044000000\nTime:2019-06-14T23:55:13.5185858Z" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue135523a3&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaf96-c003-001a-600c-23e044000000", + "Body" : "queue135523a3" + } + } ], + "variables" : [ "queue135523a3" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/listQueues.json b/storage/client/src/test/resources/session-records/listQueues.json new file mode 100644 index 0000000000000..8c5265f468f8c --- /dev/null +++ b/storage/client/src/test/resources/session-records/listQueues.json @@ -0,0 +1,186 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311550", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaec6-c003-001a-2b0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311551", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaecc-c003-001a-300c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311552", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaede-c003-001a-3c0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue88431155&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaeeb-c003-001a-470c-23e044000000", + "Body" : "queue88431155queue884311550queue884311551queue884311552" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue88431155&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdaef0-c003-001a-4b0c-23e044000000", + "Body" : "queue88431155queue884311550queue884311551queue884311552" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311550/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaefc-c003-001a-560c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311550", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf01-c003-001a-5b0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311551/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf06-c003-001a-600c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311551", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf0e-c003-001a-660c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311552/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf16-c003-001a-6e0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue884311552", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:12 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdaf1d-c003-001a-750c-23e044000000" + } + } ], + "variables" : [ "queue88431155" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/listQueuesIncludeMetadata.json b/storage/client/src/test/resources/session-records/listQueuesIncludeMetadata.json new file mode 100644 index 0000000000000..121b2ea5ab1c0 --- /dev/null +++ b/storage/client/src/test/resources/session-records/listQueuesIncludeMetadata.json @@ -0,0 +1,186 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdb0ba-c003-001a-6e0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d1", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdb0c5-c003-001a-780c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d2", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdb0ce-c003-001a-800c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue69579f6d&include=metadata&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdb0d7-c003-001a-080c-23e044000000", + "Body" : "queue69579f6dqueue69579f6d0value1value2queue69579f6d1queue69579f6d2value1value2" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue69579f6d&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdb0e3-c003-001a-120c-23e044000000", + "Body" : "queue69579f6dqueue69579f6d0queue69579f6d1queue69579f6d2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d0/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb0e6-c003-001a-150c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb0f7-c003-001a-230c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d1/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb0fd-c003-001a-290c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d1", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb102-c003-001a-2e0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d2/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb109-c003-001a-350c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue69579f6d2", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:14 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb110-c003-001a-3b0c-23e044000000" + } + } ], + "variables" : [ "queue69579f6d" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/listQueuesWithPrefix.json b/storage/client/src/test/resources/session-records/listQueuesWithPrefix.json new file mode 100644 index 0000000000000..ef9c955b1ee47 --- /dev/null +++ b/storage/client/src/test/resources/session-records/listQueuesWithPrefix.json @@ -0,0 +1,186 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdafe6-c003-001a-290c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue125047791", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdaffe-c003-001a-3f0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix2", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecdb008-c003-001a-480c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue12504779prefix&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdb018-c003-001a-570c-23e044000000", + "Body" : "queue12504779prefixqueue12504779prefix0queue12504779prefix2" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue12504779&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdb032-c003-001a-6e0c-23e044000000", + "Body" : "queue12504779queue125047791queue12504779prefix0queue12504779prefix2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue125047791/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb03f-c003-001a-7b0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue125047791", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb04d-c003-001a-090c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix0/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb05c-c003-001a-170c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix0", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb064-c003-001a-1f0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix2/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb071-c003-001a-2c0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue12504779prefix2", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:13 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecdb084-c003-001a-3b0c-23e044000000" + } + } ], + "variables" : [ "queue12504779" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/peekMessage.json b/storage/client/src/test/resources/session-records/peekMessage.json new file mode 100644 index 0000000000000..e681cc3e67500 --- /dev/null +++ b/storage/client/src/test/resources/session-records/peekMessage.json @@ -0,0 +1,90 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue954166c4", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda6f8-c003-001a-030c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue954166c4/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda6fc-c003-001a-060c-23e044000000", + "Body" : "f2ba5988-88c6-41d8-a4dd-9cc37318debcFri, 14 Jun 2019 23:55:04 GMTFri, 21 Jun 2019 23:55:04 GMTAgAAAAMAAAAAAAAAWSmRlgwj1QE=Fri, 14 Jun 2019 23:55:04 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue954166c4/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecda70d-c003-001a-170c-23e044000000", + "Body" : "f2ba5988-88c6-41d8-a4dd-9cc37318debcFri, 14 Jun 2019 23:55:04 GMTFri, 21 Jun 2019 23:55:04 GMT0test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue954166c4/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda711-c003-001a-1b0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue954166c4", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda71d-c003-001a-240c-23e044000000" + } + } ], + "variables" : [ "queue954166c4" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/peekMultipleMessages.json b/storage/client/src/test/resources/session-records/peekMultipleMessages.json new file mode 100644 index 0000000000000..8194dc40d6359 --- /dev/null +++ b/storage/client/src/test/resources/session-records/peekMultipleMessages.json @@ -0,0 +1,109 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd852b-c003-001a-290c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8530-c003-001a-2c0c-23e044000000", + "Body" : "09310a6e-4cf3-433d-a5df-c0231bc86744Fri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMTAgAAAAMAAAAAAAAAcbPagQwj1QE=Fri, 14 Jun 2019 23:54:30 GMT" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd853f-c003-001a-3a0c-23e044000000", + "Body" : "303cbbd4-41c6-4b98-80f2-938b06af3f3eFri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMTAgAAAAMAAAAAAAAAPo/jgQwj1QE=Fri, 14 Jun 2019 23:54:30 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831/messages?numofmessages=2&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8549-c003-001a-440c-23e044000000", + "Body" : "09310a6e-4cf3-433d-a5df-c0231bc86744Fri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMT0test message303cbbd4-41c6-4b98-80f2-938b06af3f3eFri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMT0test message 2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd854d-c003-001a-480c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue39191831", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8560-c003-001a-5b0c-23e044000000" + } + } ], + "variables" : [ "queue39191831" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/peekQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/peekQueueDoesNotExist.json new file mode 100644 index 0000000000000..888840e203e24 --- /dev/null +++ b/storage/client/src/test/resources/session-records/peekQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue04685840/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd7de0-c003-001a-730c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd7de0-c003-001a-730c-23e044000000\nTime:2019-06-14T23:54:22.3230477Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue04685840/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:21 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd7de9-c003-001a-7b0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd7de9-c003-001a-7b0c-23e044000000\nTime:2019-06-14T23:54:22.3640865Z" + } + } ], + "variables" : [ "queue04685840" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/peekTooManyMessages.json b/storage/client/src/test/resources/session-records/peekTooManyMessages.json new file mode 100644 index 0000000000000..2a91837a5fd5d --- /dev/null +++ b/storage/client/src/test/resources/session-records/peekTooManyMessages.json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06608efc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda7eb-c003-001a-5b0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06608efc/messages?numofmessages=64&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "456", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "OutOfRangeQueryParameterValue", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecda7fd-c003-001a-6b0c-23e044000000", + "Body" : "OutOfRangeQueryParameterValueOne of the query parameters specified in the request URI is outside the permissible range.\nRequestId:eecda7fd-c003-001a-6b0c-23e044000000\nTime:2019-06-14T23:55:05.9874477Znumofmessages64132" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06608efc/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda80f-c003-001a-7b0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue06608efc", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda81a-c003-001a-050c-23e044000000" + } + } ], + "variables" : [ "queue06608efc" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setAccessPolicy.json b/storage/client/src/test/resources/session-records/setAccessPolicy.json new file mode 100644 index 0000000000000..2e4cc409fa4a7 --- /dev/null +++ b/storage/client/src/test/resources/session-records/setAccessPolicy.json @@ -0,0 +1,88 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32490868", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda6ce-c003-001a-5c0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32490868?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6d9-c003-001a-650c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32490868?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecda6e3-c003-001a-6e0c-23e044000000", + "Body" : "testpermission2000-01-01T00:00:00.0000000Z2020-01-01T00:00:00.0000000Zraup" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32490868/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6ea-c003-001a-750c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue32490868", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda6f0-c003-001a-7b0c-23e044000000" + } + } ], + "variables" : [ "queue32490868" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setAccessPolicyQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/setAccessPolicyQueueDoesNotExist.json new file mode 100644 index 0000000000000..e8a2f99fd8c4b --- /dev/null +++ b/storage/client/src/test/resources/session-records/setAccessPolicyQueueDoesNotExist.json @@ -0,0 +1,43 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue097113ee?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "294", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidXmlDocument", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecdaa0a-c003-001a-530c-23e044000000", + "Body" : "InvalidXmlDocumentXML specified is not syntactically valid.\nRequestId:eecdaa0a-c003-001a-530c-23e044000000\nTime:2019-06-14T23:55:07.8191841Z00" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue097113ee/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecdaa18-c003-001a-600c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecdaa18-c003-001a-600c-23e044000000\nTime:2019-06-14T23:55:07.8682301Z" + } + } ], + "variables" : [ "queue097113ee" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setInvalidAccessPolicy.json b/storage/client/src/test/resources/session-records/setInvalidAccessPolicy.json new file mode 100644 index 0000000000000..18ee3ea6dd50b --- /dev/null +++ b/storage/client/src/test/resources/session-records/setInvalidAccessPolicy.json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue65964be3", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda8ed-c003-001a-4a0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue65964be3?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "371", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidXmlDocument", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecda8f9-c003-001a-550c-23e044000000", + "Body" : "InvalidXmlDocumentXML specified is not syntactically valid.\nRequestId:eecda8f9-c003-001a-550c-23e044000000\nTime:2019-06-14T23:55:07.1175194Z1304Signed identifier ID cannot be empty or over 64 characters in length" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue65964be3/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda90d-c003-001a-690c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue65964be3", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda920-c003-001a-7c0c-23e044000000" + } + } ], + "variables" : [ "queue65964be3" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setInvalidMetadata.json b/storage/client/src/test/resources/session-records/setInvalidMetadata.json new file mode 100644 index 0000000000000..d1848f88ad5bd --- /dev/null +++ b/storage/client/src/test/resources/session-records/setInvalidMetadata.json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue78767c95", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd83db-c003-001a-770c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue78767c95?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "285", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "EmptyMetadataKey", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecd83ed-c003-001a-060c-23e044000000", + "Body" : "EmptyMetadataKeyThe key for one of the metadata key-value pairs is empty.\nRequestId:eecd83ed-c003-001a-060c-23e044000000\nTime:2019-06-14T23:54:28.7171105Zbad metadata" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue78767c95/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd83f8-c003-001a-110c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue78767c95", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:28 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8405-c003-001a-1e0c-23e044000000" + } + } ], + "variables" : [ "queue78767c95" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setMetadata.json b/storage/client/src/test/resources/session-records/setMetadata.json new file mode 100644 index 0000000000000..7b07de461fc54 --- /dev/null +++ b/storage/client/src/test/resources/session-records/setMetadata.json @@ -0,0 +1,88 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52697000", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda970-c003-001a-450c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52697000?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda985-c003-001a-590c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52697000?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "cache-control" : "no-cache", + "x-ms-approximate-messages-count" : "0", + "x-ms-meta-metadata1" : "value1", + "StatusCode" : "200", + "x-ms-request-id" : "eecda999-c003-001a-6d0c-23e044000000", + "x-ms-meta-metadata2" : "value2" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52697000/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:06 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda9a9-c003-001a-7c0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue52697000", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:07 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda9b3-c003-001a-050c-23e044000000" + } + } ], + "variables" : [ "queue52697000" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setMetadataQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/setMetadataQueueDoesNotExist.json new file mode 100644 index 0000000000000..5b044f247499e --- /dev/null +++ b/storage/client/src/test/resources/session-records/setMetadataQueueDoesNotExist.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue942473a4?comp=metadata", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7b5-c003-001a-2d0c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7b5-c003-001a-2d0c-23e044000000\nTime:2019-06-14T23:55:05.7071802Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue942473a4/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:05 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecda7c1-c003-001a-360c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecda7c1-c003-001a-360c-23e044000000\nTime:2019-06-14T23:55:05.7412131Z" + } + } ], + "variables" : [ "queue942473a4" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setProperties.json b/storage/client/src/test/resources/session-records/setProperties.json new file mode 100644 index 0000000000000..de99cc3244c16 --- /dev/null +++ b/storage/client/src/test/resources/session-records/setProperties.json @@ -0,0 +1,114 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdae59-c003-001a-420c-23e044000000", + "Body" : "1.0falsetruetruetrue31.0truefalsetrue31.0truefalsetrue3" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "eecdae62-c003-001a-4b0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdae6b-c003-001a-540c-23e044000000", + "Body" : "1.0falsetruetruetrue31.0truefalsetrue31.0truefalsetrue3" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "eecdae74-c003-001a-5d0c-23e044000000" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdae7c-c003-001a-650c-23e044000000", + "Body" : "1.0falsetruetruetrue31.0truefalsetrue31.0truefalsetrue3" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net?prefix=queue8996328f&include=&comp=list", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:11 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecdae84-c003-001a-6d0c-23e044000000", + "Body" : "queue8996328f" + } + } ], + "variables" : [ "queue8996328f" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/setTooManyAccessPolicies.json b/storage/client/src/test/resources/session-records/setTooManyAccessPolicies.json new file mode 100644 index 0000000000000..e1ec29139bf61 --- /dev/null +++ b/storage/client/src/test/resources/session-records/setTooManyAccessPolicies.json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue71621932", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecda738-c003-001a-3e0c-23e044000000" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue71621932?comp=acl", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "294", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidXmlDocument", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecda73f-c003-001a-440c-23e044000000", + "Body" : "InvalidXmlDocumentXML specified is not syntactically valid.\nRequestId:eecda73f-c003-001a-440c-23e044000000\nTime:2019-06-14T23:55:05.2557509Z00" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue71621932/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda74c-c003-001a-500c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue71621932", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:55:04 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecda757-c003-001a-590c-23e044000000" + } + } ], + "variables" : [ "queue71621932" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/updateMessage.json b/storage/client/src/test/resources/session-records/updateMessage.json new file mode 100644 index 0000000000000..0c0242e21dd88 --- /dev/null +++ b/storage/client/src/test/resources/session-records/updateMessage.json @@ -0,0 +1,128 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd85a9-c003-001a-180c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd85ae-c003-001a-1c0c-23e044000000", + "Body" : "7ab459a2-5d41-4aa4-b70d-9d7c6926680bFri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMTAgAAAAMAAAAAAAAALZNAggwj1QE=Fri, 14 Jun 2019 23:54:30 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd85c3-c003-001a-2f0c-23e044000000", + "Body" : "7ab459a2-5d41-4aa4-b70d-9d7c6926680bFri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMTAgAAAAMAAAAAAAAAlAovlAwj1QE=Fri, 14 Jun 2019 23:55:00 GMT1test message" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7/messages/7ab459a2-5d41-4aa4-b70d-9d7c6926680b?popreceipt=AgAAAAMAAAAAAAAAlAovlAwj1QE%3d&visibilitytimeout=1", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:30 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "x-ms-time-next-visible" : "Fri, 14 Jun 2019 23:54:32 GMT", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd85db-c003-001a-460c-23e044000000", + "x-ms-popreceipt" : "AwAAAAMAAAAAAAAAs5nxggwj1QEBAAAA" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7/messages?numofmessages=1&peekonly=true", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:32 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd87e0-c003-001a-2f0c-23e044000000", + "Body" : "7ab459a2-5d41-4aa4-b70d-9d7c6926680bFri, 14 Jun 2019 23:54:30 GMTFri, 21 Jun 2019 23:54:30 GMT1updated test message" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:32 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd87ed-c003-001a-3c0c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue181287e7", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:32 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd87f3-c003-001a-420c-23e044000000" + } + } ], + "variables" : [ "queue181287e7" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/updateMessageInvalidMessageId.json b/storage/client/src/test/resources/session-records/updateMessageInvalidMessageId.json new file mode 100644 index 0000000000000..f67446f6c118b --- /dev/null +++ b/storage/client/src/test/resources/session-records/updateMessageInvalidMessageId.json @@ -0,0 +1,110 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:32 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8828-c003-001a-720c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:32 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd8834-c003-001a-7c0c-23e044000000", + "Body" : "3db1e467-aa40-44bb-ad91-afb20e111d65Fri, 14 Jun 2019 23:54:33 GMTFri, 21 Jun 2019 23:54:33 GMTAgAAAAMAAAAAAAAAtCHFgwwj1QE=Fri, 14 Jun 2019 23:54:33 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd8846-c003-001a-0c0c-23e044000000", + "Body" : "3db1e467-aa40-44bb-ad91-afb20e111d65Fri, 14 Jun 2019 23:54:33 GMTFri, 21 Jun 2019 23:54:33 GMTAgAAAAMAAAAAAAAAhRmulQwj1QE=Fri, 14 Jun 2019 23:55:03 GMT1test message" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8/messages/3db1e467-aa40-44bb-ad91-afb20e111d65random?popreceipt=AgAAAAMAAAAAAAAAhRmulQwj1QE%3d&visibilitytimeout=1", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "221", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "MessageNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd8857-c003-001a-1c0c-23e044000000", + "Body" : "MessageNotFoundThe specified message does not exist.\nRequestId:eecd8857-c003-001a-1c0c-23e044000000\nTime:2019-06-14T23:54:33.5566976Z" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8864-c003-001a-280c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue310620d8", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8870-c003-001a-320c-23e044000000" + } + } ], + "variables" : [ "queue310620d8" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/updateMessageInvalidPopReceipt.json b/storage/client/src/test/resources/session-records/updateMessageInvalidPopReceipt.json new file mode 100644 index 0000000000000..72310465129ad --- /dev/null +++ b/storage/client/src/test/resources/session-records/updateMessageInvalidPopReceipt.json @@ -0,0 +1,110 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd88bd-c003-001a-7a0c-23e044000000" + } + }, { + "Method" : "POST", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c/messages?visibilitytimeout=0&messagettl=604800", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "eecd88d6-c003-001a-0e0c-23e044000000", + "Body" : "c59ac1f3-2cbf-4fb1-8073-d6e696c0f14aFri, 14 Jun 2019 23:54:34 GMTFri, 21 Jun 2019 23:54:34 GMTAgAAAAMAAAAAAAAAVb4khAwj1QE=Fri, 14 Jun 2019 23:54:34 GMT" + } + }, { + "Method" : "GET", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c/messages?numofmessages=1&visibilitytimeout=30", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding" : "chunked", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "retry-after" : "0", + "cache-control" : "no-cache", + "StatusCode" : "200", + "x-ms-request-id" : "eecd88e9-c003-001a-1e0c-23e044000000", + "Body" : "c59ac1f3-2cbf-4fb1-8073-d6e696c0f14aFri, 14 Jun 2019 23:54:34 GMTFri, 21 Jun 2019 23:54:34 GMTAgAAAAMAAAAAAAAACY8Nlgwj1QE=Fri, 14 Jun 2019 23:55:04 GMT1test message" + } + }, { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c/messages/c59ac1f3-2cbf-4fb1-8073-d6e696c0f14a?popreceipt=AgAAAAMAAAAAAAAACY8Nlgwj1QE%3drandom&visibilitytimeout=1", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "444", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidQueryParameterValue", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecd8902-c003-001a-370c-23e044000000", + "Body" : "InvalidQueryParameterValueValue for one of the query parameters specified in the request URI is invalid.\nRequestId:eecd8902-c003-001a-370c-23e044000000\nTime:2019-06-14T23:54:34.1802920ZpopreceiptAgAAAAMAAAAAAAAACY8Nlgwj1QE=randomInvalid pop receipt format" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd890e-c003-001a-430c-23e044000000" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue9155466c", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:33 GMT", + "content-length" : "0", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "eecd8916-c003-001a-4b0c-23e044000000" + } + } ], + "variables" : [ "queue9155466c" ] +} \ No newline at end of file diff --git a/storage/client/src/test/resources/session-records/updateMessageQueueDoesNotExist.json b/storage/client/src/test/resources/session-records/updateMessageQueueDoesNotExist.json new file mode 100644 index 0000000000000..5effd7bf4e5ff --- /dev/null +++ b/storage/client/src/test/resources/session-records/updateMessageQueueDoesNotExist.json @@ -0,0 +1,43 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue10147877/messages/doesn't?popreceipt=exist&visibilitytimeout=5", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "415", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "InvalidQueryParameterValue", + "retry-after" : "0", + "StatusCode" : "400", + "x-ms-request-id" : "eecd84d0-c003-001a-540c-23e044000000", + "Body" : "InvalidQueryParameterValueValue for one of the query parameters specified in the request URI is invalid.\nRequestId:eecd84d0-c003-001a-540c-23e044000000\nTime:2019-06-14T23:54:29.6810264ZpopreceiptexistInvalid pop receipt format" + } + }, { + "Method" : "DELETE", + "Uri" : "https://alzimmerstorage.queue.core.windows.net/queue10147877/messages", + "Headers" : { + "x-ms-version" : "2018-03-28", + "User-Agent" : "azsdk-java-storage-queue/1.0.0-SNAPSHOT 11.0.2; Windows 10 10.0" + }, + "Response" : { + "date" : "Fri, 14 Jun 2019 23:54:29 GMT", + "content-length" : "217", + "server" : "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-version" : "2018-03-28", + "content-type" : "application/xml", + "x-ms-error-code" : "QueueNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "eecd84d4-c003-001a-580c-23e044000000", + "Body" : "QueueNotFoundThe specified queue does not exist.\nRequestId:eecd84d4-c003-001a-580c-23e044000000\nTime:2019-06-14T23:54:29.7240672Z" + } + } ], + "variables" : [ "queue10147877" ] +} \ No newline at end of file