From 671e917d4b8917d0b4ae6fa49da95812e3654f37 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 8 May 2013 15:33:27 -0700 Subject: [PATCH 01/38] message count details. --- .../implementation/ServiceBusRestProxy.java | 2 +- .../services/serviceBus/models/QueueInfo.java | 5 +++ .../serviceBus/models/SubscriptionInfo.java | 5 +++ .../services/serviceBus/models/TopicInfo.java | 5 +++ ...netservices.2010.10.servicebus.connect.xsd | 31 ++++++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 35 +++++++++++++++++++ 6 files changed, 82 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 05e12f33bfac6..482d26a741990 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -110,7 +110,7 @@ public void setChannel(Client channel) { } private WebResource getResource() { - WebResource resource = getChannel().resource(uri); + WebResource resource = getChannel().resource(uri).queryParam("api-version", "2012-08"); for (ServiceFilter filter : filters) { resource.addFilter(new ClientFilterAdapter(filter)); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 8cc7a1efde54b..732536aa7373a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; @@ -538,4 +539,8 @@ public QueueInfo setUserMetadata(String userMetadata) { getModel().setUserMetadata(userMetadata); return this; } + + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 04263c1115036..7bd3637e47d3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; @@ -430,4 +431,8 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 41be6a80acd38..60701a7c57ff6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; @@ -405,6 +406,10 @@ public Integer getSubscriptionCount() { return getModel().getSubscriptionCount(); } + public MessageCountDetails getCountDetails() { + return getModel().getCountDetails(); + } + /** * Sets the auto delete on idle. * diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index ff5f9bb9359a8..a9a1de46cfdc2 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -150,6 +150,13 @@ + + + + + + + @@ -274,6 +281,13 @@ + + + + + + + @@ -362,6 +376,16 @@ + + + + + + + + + + @@ -532,6 +556,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8c20cce470f2..b00abc8a5ac34 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -36,6 +36,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; @@ -170,6 +171,40 @@ public void sendMessageWorks() throws Exception { // Assert } + @Test + public void getQueueMessageCountDetails() throws Exception { + // Arrange + String queueName = "testGetQueueMessageCountDetails"; + service.createQueue(new QueueInfo(queueName)); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); + Long expectedActiveMessageCount = 1L; + + // Act + QueueInfo queueInfo = service.getQueue(queueName).getValue(); + MessageCountDetails countDetails = queueInfo.getCountDetails(); + + // Assert + assertEquals(true, queueInfo.isSupportOrdering()); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + + } + + @Test + public void getTopicMessageCountDetails() throws Exception { + // Arrange + + // Act + + // Assert + + } + + @Test + public void getSubscriptionMessageCountDetails() throws Exception { + + } + @Test public void receiveMessageWorks() throws Exception { // Arrange From 46c37e4a34b878e8bc5aabf3beed494213448b4e Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Wed, 8 May 2013 19:16:05 -0700 Subject: [PATCH 02/38] update for 0.4.3 --- README.md | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a8805eb2e3262..36c1db7012323 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,37 @@ #Windows Azure SDK for Java -This SDK allows you to build Windows Azure applications in Java that allow -you to take advantage of Azure scalable cloud computing resources: table and blob -storage, messaging through Service Bus. - -For documentation please see the [Windows Azure Java Developer Center](http://www.windowsazure.com/en-us/develop/java/) +This project provides a client library in Java that makes it easy to consume Windows Azure services. For documentation please see the [Windows Azure Java Developer Center](http://www.windowsazure.com/en-us/develop/java/). #Features -* Blob - * Create/Read/Update/Delete Blobs -* Queue - * Create/Delete Queues - * Insert/Peek Queue Messages - * Advanced Queue Operations -* Media Services - * Upload Media Files to Media Services - * Change the encoding on uploaded Media Services - * Provide streaming or download access to uploaded/transformed Media Files + +* Storage + * Blob + * Create/Read/Update/Delete containers + * Create/Read/Update/Delete blobs + * Queue + * Create/Delete Queues + * Insert/Peek Queue Messages + * Advanced Queue Operations + * Table + * Create/Read/Update/Delete tables + * Create/Read/Update/Delete entities + * Batch operation * Service Bus - * Use either the Queue or Topic/Subscription Model + * Queues + * Create/Read/Update/Delete queues + * Send/Receive/Unlock/Delete messages + * Topics + * Create/Read/Update/Delete topics + * Create/Read/Update/Delete subscriptions + * Create/Read/Update/Delete rules + * Send/Receive/Unlock/Delete messages +* Media Services + * Upload Media Files to Media Services + * Change the encoding on uploaded Media Services + * Provide streaming or download access to uploaded/transformed Media Files * Service Runtime - * Retrieve information about the state of your Azure Compute instances -* Table - * Manage Tables - * Table Entity Operations - * Entity Group Transactions (Batch) + * Retrieve information about the state of your Azure Compute instances + #Getting Started @@ -45,7 +52,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.2 + 0.4.3 ##Minimum Requirements From 69b37ab70be5c1848421e0a756bfd80273814232 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 15 May 2013 18:05:29 -0700 Subject: [PATCH 03/38] initial check in for forward to feature. --- .../implementation/ServiceBusRestProxy.java | 7 ++- .../services/serviceBus/models/QueueInfo.java | 21 +++++++ ...netservices.2010.10.servicebus.connect.xsd | 7 +++ .../serviceBus/ServiceBusIntegrationTest.java | 56 +++++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 482d26a741990..6d76eb402d846 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -268,8 +268,11 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { @Override public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - return new CreateQueueResult(getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(QueueInfo.class, entry)); + ClientResponse clientResponse = getResource().path(entry.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").put(ClientResponse.class, entry); + QueueInfo queueInfo = new QueueInfo(); + CreateQueueResult createQueueResult = new CreateQueueResult(queueInfo); + return createQueueResult; } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 8cc7a1efde54b..b4bb5197a8ec9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -14,6 +14,7 @@ */ package com.microsoft.windowsazure.services.serviceBus.models; +import java.net.URI; import java.util.Calendar; import javax.ws.rs.core.MediaType; @@ -32,6 +33,8 @@ */ public class QueueInfo extends EntryModel { + private URI uri; + /** * Creates an instance of the QueueInfo class. */ @@ -538,4 +541,22 @@ public QueueInfo setUserMetadata(String userMetadata) { getModel().setUserMetadata(userMetadata); return this; } + + public QueueInfo setUri(URI uri) { + this.uri = uri; + return this; + } + + public URI getUri() { + return uri; + } + + public QueueInfo setForwardTo(String forwardTo) { + getModel().setForwardTo(forwardTo); + return this; + } + + public String getForwardTo() { + return getModel().getForwardTo(); + } } diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 2c8d69df7be6a..490d5b9397da0 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -115,6 +115,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 221a358acedc3..7a104e2a7a494 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -240,6 +240,62 @@ public void receiveMessageEmptyQueueWorks() throws Exception { assertNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveQueueForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNull(receiveQueueMessageResult.getValue()); + } + + @Test + public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNull(receiveQueueMessageResult.getValue()); + } + + @Test + public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + + } + + @Test + public void receiveQueueForwardToTopicMessageWorks() throws Exception { + + } + + @Test + public void receiveForwardedTopicMessageFails() throws Exception { + + } + + @Test + public void receiveForwardedSubscriptionMessageFails() throws Exception { + + } + @Test public void peekLockMessageWorks() throws Exception { // Arrange From 5481757c183948ff6a1849150b932acce2dc23c6 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 14:56:33 -0700 Subject: [PATCH 04/38] additional implementation of forward to feature. --- .../implementation/ServiceBusRestProxy.java | 11 +++--- .../serviceBus/implementation/WrapFilter.java | 36 ++++++++++++++----- .../services/serviceBus/models/QueueInfo.java | 9 +++-- ...netservices.2010.10.servicebus.connect.xsd | 2 +- .../src/main/resources/servicebus-atom.xsd | 4 +-- .../serviceBus/ServiceBusIntegrationTest.java | 9 ++--- 6 files changed, 49 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 6d76eb402d846..f1096e4d279ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -268,11 +268,12 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { @Override public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - ClientResponse clientResponse = getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(ClientResponse.class, entry); - QueueInfo queueInfo = new QueueInfo(); - CreateQueueResult createQueueResult = new CreateQueueResult(queueInfo); - return createQueueResult; + Builder webResourceBuilder = getResource().path(entry.getPath()).type( + "application/atom+xml;type=entry;charset=utf-8"); + if ((entry.getForwardTo() != null) && !entry.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", entry.getForwardTo()); + } + return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, entry)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index ac3c15b3a7d08..198783afb60bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -2,18 +2,19 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus.implementation; +import java.net.URI; import java.net.URISyntaxException; import com.microsoft.windowsazure.services.core.ServiceException; @@ -47,6 +48,25 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); + String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); + if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { + String secondaryAccessToken; + try { + secondaryAccessToken = tokenManager.getAccessToken(URI.create(secondaryAuthorizationUri)); + } + catch (ServiceException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + catch (URISyntaxException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); + cr.getHeaders().add("ServiceBusSupplementaryAuthorization", + "WRAP access_token=\"" + secondaryAccessToken + "\""); + } + return this.getNext().handle(cr); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index b4bb5197a8ec9..0d44c8288e9a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -543,12 +543,17 @@ public QueueInfo setUserMetadata(String userMetadata) { } public QueueInfo setUri(URI uri) { - this.uri = uri; + getEntry().setId(uri.toString()); return this; } public URI getUri() { - return uri; + return URI.create(removeQueryString(getEntry().getId())); + } + + private String removeQueryString(String uri) { + String[] result = uri.split("\\?"); + return result[0]; } public QueueInfo setForwardTo(String forwardTo) { diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 490d5b9397da0..74142943124b2 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -337,7 +337,7 @@ - + diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index b8387023a54be..415ccefeaae5a 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -12,7 +12,6 @@ - @@ -20,7 +19,8 @@ - + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 7a104e2a7a494..8cc96ae3696c7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -244,9 +244,10 @@ public void receiveMessageEmptyQueueWorks() throws Exception { public void receiveQueueForwardToQueueMessageSuccess() throws Exception { // Arrange String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); - service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessDestination"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + QueueInfo sourceQueueInfo = service.createQueue( + new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())).getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -255,7 +256,7 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { // Assert assertNotNull(receiveQueueMessageResult); - assertNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From a6a749f9cf6e8ff5cddb49e29e016cc2440ae6e4 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 15:37:12 -0700 Subject: [PATCH 05/38] implement subscription forward to feature. --- .../implementation/ServiceBusRestProxy.java | 10 +++++++--- .../serviceBus/models/SubscriptionInfo.java | 9 +++++++++ ...com.netservices.2010.10.servicebus.connect.xsd | 7 +++++++ .../serviceBus/ServiceBusIntegrationTest.java | 15 +++++++++------ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index f1096e4d279ff..5508c2b4fe9cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -350,9 +350,13 @@ public TopicInfo updateTopic(TopicInfo topicInfo) throws ServiceException { @Override public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - return new CreateSubscriptionResult(getResource().path(topicPath).path("subscriptions") - .path(subscription.getName()).type("application/atom+xml;type=entry;charset=utf-8") - .put(SubscriptionInfo.class, subscription)); + Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions").path(subscription.getName()) + .type("application/atom+xml;type=entry;charset=utf-8"); + if ((subscription.getForwardTo() != null) && (!subscription.getForwardTo().isEmpty())) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscription.getForwardTo()); + + } + return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscription)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 04263c1115036..7bb06502885fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -430,4 +430,13 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + public SubscriptionInfo setForwardTo(String forwardTo) { + getModel().setForwardTo(forwardTo); + return this; + } + + public String getForwardTo() { + return getModel().getForwardTo(); + } + } diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 74142943124b2..8eb6931a6ee51 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -253,6 +253,13 @@ + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8cc96ae3696c7..21530a17665d1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -262,19 +262,22 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { @Test public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange - String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(sourceQueueName)).getValue(); - service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())); + String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); // Act - service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, RECEIVE_AND_DELETE_5_SECONDS); // Assert assertNotNull(receiveQueueMessageResult); - assertNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From ff2faf48bc14b983cbfe639aae8e4a116aed3d5c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 16:07:55 -0700 Subject: [PATCH 06/38] implementing update for forward to feature. --- .../implementation/ServiceBusRestProxy.java | 18 +++++--- .../serviceBus/ServiceBusIntegrationTest.java | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 5508c2b4fe9cc..a894df4619166 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -300,8 +300,12 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce @Override public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException { - return getResource().path(queueInfo.getPath()).type("application/atom+xml;type=entry;charset=utf-8") - .header("If-Match", "*").put(QueueInfo.class, queueInfo); + Builder webResourceBuilder = getResource().path(queueInfo.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*"); + if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo()); + } + return webResourceBuilder.put(QueueInfo.class, queueInfo); } private WebResource listOptions(AbstractListOptions options, WebResource path) { @@ -385,9 +389,13 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript @Override public SubscriptionInfo updateSubscription(String topicName, SubscriptionInfo subscriptionInfo) throws ServiceException { - return getResource().path(topicName).path("subscriptions").path(subscriptionInfo.getName()) - .type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*") - .put(SubscriptionInfo.class, subscriptionInfo); + Builder webResourceBuilder = getResource().path(topicName).path("subscriptions") + .path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8") + .header("If-Match", "*"); + if ((subscriptionInfo.getForwardTo() != null) && !subscriptionInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo()); + } + return webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo); } @Override diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 21530a17665d1..e9058e355d9e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -259,6 +259,26 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { assertNotNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveUpdatedQueueForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveUpdatedQueueForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveUpdatedQueueForwardToQueueMessageSuccessDestination"; + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + QueueInfo sourceQueueInfo = new QueueInfo(sourceQueueName); + service.createQueue(sourceQueueInfo).getValue(); + service.updateQueue(sourceQueueInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); + } + @Test public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange @@ -280,6 +300,28 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { assertNotNull(receiveQueueMessageResult.getValue()); } + @Test + public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName)).getValue(); + service.updateSubscription(sourceTopicName, + sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); + } + @Test public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { From a1a095a88bee0acd3c7dd80286c969c6aae4a89d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 16 May 2013 16:54:52 -0700 Subject: [PATCH 07/38] update forward to integration test. --- .../services/serviceBus/models/TopicInfo.java | 5 ++ .../serviceBus/ServiceBusIntegrationTest.java | 74 ++++++++++++++++++- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 627af7f6d05ea..af1f75e97955e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -14,6 +14,7 @@ */ package com.microsoft.windowsazure.services.serviceBus.models; +import java.net.URI; import java.util.Calendar; import javax.ws.rs.core.MediaType; @@ -467,4 +468,8 @@ public TopicInfo setEntityAvailabilityStatus(EntityAvailabilityStatus entityAvai public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + + public URI getUri() { + return URI.create(getEntry().getId()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index e9058e355d9e1..44d9e61396cef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -49,6 +49,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; @@ -323,23 +324,88 @@ public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exce } @Test - public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + public void receiveQueueForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveQueueForwardToTopicMessageSuccessSource"; + String destinationTopicName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; + String destinationSubscriptionName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + QueueInfo sourceQueueInfo = service.createQueue( + new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())).getValue(); + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test - public void receiveQueueForwardToTopicMessageWorks() throws Exception { + public void receiveUpdatedQueueForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceQueueName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessSource"; + String destinationTopicName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessDestination"; + String destinationSubscriptionName = "TestReceiveUpdatedQueueForwardToTopicMessageSuccessDestination"; + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + QueueInfo sourceQueueInfo = new QueueInfo(sourceQueueName); + service.createQueue(sourceQueueInfo).getValue(); + service.updateQueue(sourceQueueInfo.setForwardTo(destinationTopicInfo.getUri().toString())); + // Act + service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test - public void receiveForwardedTopicMessageFails() throws Exception { + public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test - public void receiveForwardedSubscriptionMessageFails() throws Exception { + public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exception { + // Arrange + String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, + new SubscriptionInfo(sourceSubscriptionName)).getValue(); + service.updateSubscription(sourceTopicName, + sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + // Act + service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); + ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, + RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(receiveQueueMessageResult); + assertNotNull(receiveQueueMessageResult.getValue()); } @Test From f0609a82463e4e3f5a79067de2ca8aab6038b34b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 17 May 2013 16:43:42 -0700 Subject: [PATCH 08/38] add more integration tests for forward to feature. --- .../serviceBus/ServiceBusIntegrationTest.java | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 44d9e61396cef..435707051391f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -304,9 +304,9 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { @Test public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; + String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; + String destinationQueueName = "TestUpdatedReceiveSubForwardToQMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, @@ -356,56 +356,62 @@ public void receiveUpdatedQueueForwardToTopicMessageSuccess() throws Exception { // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; + String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, + new SubscriptionInfo(destinationSubscriptionName)).getValue(); service.createSubscription(sourceTopicName, - new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); + new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationTopicInfo.getUri().toString())); // Act service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exception { // Arrange - String sourceTopicName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessSource"; - String destinationQueueName = "TestUpdatedReceiveSubForwardToQueueMessageSuccessDestination"; + String sourceTopicName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; + String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; + String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); - QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); + TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); + SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, + new SubscriptionInfo(destinationSubscriptionName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); service.updateSubscription(sourceTopicName, - sourceSubscriptionInfo.setForwardTo(destinationQueueInfo.getUri().toString())); + sourceSubscriptionInfo.setForwardTo(destinationTopicInfo.getUri().toString())); // Act service.sendTopicMessage(sourceTopicName, new BrokeredMessage("Hello source queue!")); - ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(destinationQueueName, - RECEIVE_AND_DELETE_5_SECONDS); + ReceiveSubscriptionMessageResult receiveSubscriptionMessageResult = service.receiveSubscriptionMessage( + destinationTopicName, destinationSubscriptionName, RECEIVE_AND_DELETE_5_SECONDS); // Assert - assertNotNull(receiveQueueMessageResult); - assertNotNull(receiveQueueMessageResult.getValue()); + assertNotNull(receiveSubscriptionMessageResult); + assertNotNull(receiveSubscriptionMessageResult.getValue()); } @Test From eb11213cf3ea07ac980d9a9050fab4699b57aeca Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 17 May 2013 17:55:57 -0700 Subject: [PATCH 09/38] refactoring and documentation work. --- .../serviceBus/ServiceBusContract.java | 6 +-- .../implementation/ServiceBusRestProxy.java | 22 +++++----- .../serviceBus/implementation/WrapFilter.java | 40 ++++++++----------- .../services/serviceBus/models/QueueInfo.java | 34 +++++++++++++++- .../serviceBus/models/SubscriptionInfo.java | 12 ++++++ .../serviceBus/ServiceBusIntegrationTest.java | 22 +++++----- 6 files changed, 84 insertions(+), 52 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 075f3c7484335..537d22623dd0a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -195,13 +195,13 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St /** * Creates a queue. * - * @param queue - * A Queue object that represents the queue to create. + * @param queueInfo + * A QueueInfo object that represents the queue to create. * @return A CreateQueueResult object that represents the result. * @throws ServiceException * If a service exception is encountered. */ - CreateQueueResult createQueue(QueueInfo queue) throws ServiceException; + CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException; /** * Deletes a queue. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index a894df4619166..472bf9e510563 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -267,13 +267,13 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { } @Override - public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - Builder webResourceBuilder = getResource().path(entry.getPath()).type( + public CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException { + Builder webResourceBuilder = getResource().path(queueInfo.getPath()).type( "application/atom+xml;type=entry;charset=utf-8"); - if ((entry.getForwardTo() != null) && !entry.getForwardTo().isEmpty()) { - webResourceBuilder.header("ServiceBusSupplementaryAuthorization", entry.getForwardTo()); + if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo()); } - return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, entry)); + return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, queueInfo)); } @Override @@ -353,14 +353,14 @@ public TopicInfo updateTopic(TopicInfo topicInfo) throws ServiceException { } @Override - public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions").path(subscription.getName()) - .type("application/atom+xml;type=entry;charset=utf-8"); - if ((subscription.getForwardTo() != null) && (!subscription.getForwardTo().isEmpty())) { - webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscription.getForwardTo()); + public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscriptionInfo) { + Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions") + .path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8"); + if ((subscriptionInfo.getForwardTo() != null) && (!subscriptionInfo.getForwardTo().isEmpty())) { + webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo()); } - return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscription)); + return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 198783afb60bb..f1d0187a6b21c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -32,10 +32,23 @@ public WrapFilter(WrapTokenManager tokenManager) { @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + String accessToken = getWrapToken(cr.getURI()); + cr.getHeaders().add("Authorization", accessToken); - String accessToken; + String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); + if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { + String secondaryAccessToken = getWrapToken(URI.create(secondaryAuthorizationUri)); + cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); + cr.getHeaders().add("ServiceBusSupplementaryAuthorization", secondaryAccessToken); + } + + return this.getNext().handle(cr); + } + + private String getWrapToken(URI uri) { + String result; try { - accessToken = tokenManager.getAccessToken(cr.getURI()); + result = tokenManager.getAccessToken(uri); } catch (ServiceException e) { // must wrap exception because of base class signature @@ -46,27 +59,6 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { throw new ClientHandlerException(e); } - cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); - - String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization"); - if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) { - String secondaryAccessToken; - try { - secondaryAccessToken = tokenManager.getAccessToken(URI.create(secondaryAuthorizationUri)); - } - catch (ServiceException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - catch (URISyntaxException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - cr.getHeaders().remove("ServiceBusSupplementaryAuthorization"); - cr.getHeaders().add("ServiceBusSupplementaryAuthorization", - "WRAP access_token=\"" + secondaryAccessToken + "\""); - } - - return this.getNext().handle(cr); + return "WRAP access_token=\"" + result + "\""; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 0d44c8288e9a4..b8eb8be76a64c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -33,8 +33,6 @@ */ public class QueueInfo extends EntryModel { - private URI uri; - /** * Creates an instance of the QueueInfo class. */ @@ -542,25 +540,57 @@ public QueueInfo setUserMetadata(String userMetadata) { return this; } + /** + * Sets the URI of the QueueInfo instance. + * + * @param uri + * the URI of the QueueInfo + * + * @return A QueueInfo object that represents the updated queue. + */ public QueueInfo setUri(URI uri) { getEntry().setId(uri.toString()); return this; } + /** + * Gets the URI of the QueueInfo instance. + * + * @return A URI representing the QueueInfo. + */ public URI getUri() { return URI.create(removeQueryString(getEntry().getId())); } + /** + * Removes the query string of the URI. + * + * @param uri + * A raw string representing the URI of queue. + * @return the string + */ private String removeQueryString(String uri) { String[] result = uri.split("\\?"); return result[0]; } + /** + * Sets the URI of the entity to forward to. + * + * @param forwardTo + * A String instance representing the URI of the entity to forward message to. + * @return A QueueInfo instance representing the updated queue information. + */ public QueueInfo setForwardTo(String forwardTo) { getModel().setForwardTo(forwardTo); return this; } + /** + * Gets a String instance representing entity to forward to. + * + * @return A String instance representing the URI of the instance to forward to. + */ public String getForwardTo() { return getModel().getForwardTo(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 7bb06502885fe..d6d8f5d432461 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -430,11 +430,23 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Sets the forward to. + * + * @param forwardTo + * A String representing the string to forward to. + * @return the subscription info + */ public SubscriptionInfo setForwardTo(String forwardTo) { getModel().setForwardTo(forwardTo); return this; } + /** + * Gets a String representing the URI of the entity to forward to. + * + * @return A String representing the URI of the entity to forward to. + */ public String getForwardTo() { return getModel().getForwardTo(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 435707051391f..ed67cb2528177 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -247,8 +247,8 @@ public void receiveQueueForwardToQueueMessageSuccess() throws Exception { String sourceQueueName = "TestReceiveQueueForwardToQueueMessageSuccessSource"; String destinationQueueName = "TestReceiveQueueForwardToQueueMessageSuccessDestination"; QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); - QueueInfo sourceQueueInfo = service.createQueue( - new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationQueueInfo.getUri().toString())) + .getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -286,7 +286,7 @@ public void receiveSubscriptionForwardToQueueMessageSuccess() throws Exception { String sourceTopicName = "TestReceiveSubForwardToQueueMessageSuccessSource"; String sourceSubscriptionName = "TestReceiveSubForwardToQueueMessageSuccessSource"; String destinationQueueName = "TestReceiveSubForwardToQueueMessageSuccessDestination"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationQueueInfo.getUri().toString())); @@ -307,7 +307,7 @@ public void receiveUpdatedSubscriptionForwardToQueueMessageSuccess() throws Exce String sourceTopicName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; String sourceSubscriptionName = "TestUpdatedReceiveSubForwardToQMessageSuccessSrc"; String destinationQueueName = "TestUpdatedReceiveSubForwardToQMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); QueueInfo destinationQueueInfo = service.createQueue(new QueueInfo(destinationQueueName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); @@ -330,8 +330,8 @@ public void receiveQueueForwardToTopicMessageSuccess() throws Exception { String destinationTopicName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; String destinationSubscriptionName = "TestReceiveQueueForwardToTopicMessageSuccessDestination"; TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - QueueInfo sourceQueueInfo = service.createQueue( - new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())).getValue(); + service.createQueue(new QueueInfo(sourceQueueName).setForwardTo(destinationTopicInfo.getUri().toString())) + .getValue(); // Act service.sendQueueMessage(sourceQueueName, new BrokeredMessage("Hello source queue!")); @@ -371,10 +371,9 @@ public void receiveSubscriptionForwardToTopicMessageSuccess() throws Exception { String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, - new SubscriptionInfo(destinationSubscriptionName)).getValue(); + service.createSubscription(destinationTopicName, new SubscriptionInfo(destinationSubscriptionName)).getValue(); service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName).setForwardTo(destinationTopicInfo.getUri().toString())); @@ -395,10 +394,9 @@ public void receiveUpdatedSubscriptionForwardToTopicMessageSuccess() throws Exce String sourceSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessSrc"; String destinationTopicName = "TestReceiveSubForwardToTopMessageSuccessDest"; String destinationSubscriptionName = "TestReceiveSubForwardToTopMessageSuccessDest"; - TopicInfo sourceTopicInfo = service.createTopic(new TopicInfo(sourceTopicName)).getValue(); + service.createTopic(new TopicInfo(sourceTopicName)).getValue(); TopicInfo destinationTopicInfo = service.createTopic(new TopicInfo(destinationTopicName)).getValue(); - SubscriptionInfo destinationSubscriptionInfo = service.createSubscription(destinationTopicName, - new SubscriptionInfo(destinationSubscriptionName)).getValue(); + service.createSubscription(destinationTopicName, new SubscriptionInfo(destinationSubscriptionName)).getValue(); SubscriptionInfo sourceSubscriptionInfo = service.createSubscription(sourceTopicName, new SubscriptionInfo(sourceSubscriptionName)).getValue(); service.updateSubscription(sourceTopicName, From 36489bd099f4fb2c7cdaf188e464858642271466 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 20 May 2013 12:33:09 -0700 Subject: [PATCH 10/38] fix two scenario tests for CI machine. --- .../windowsazure/services/scenarios/MediaServiceWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index c71781c96fe61..bb996eb10b77b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -272,7 +272,7 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss String configuration = null; switch (encoderType) { case WindowsAzureMediaEncoder: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.2.0.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.3"); // Full list of configurations strings for version 2.1 is at: // http://msdn.microsoft.com/en-us/library/jj129582.aspx configuration = "VC1 Broadband SD 4x3"; From 928fafefdaec8190447fb771c23e2e2034626430 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 20 May 2013 16:52:41 -0700 Subject: [PATCH 11/38] initial check in for multiple property filter --- ...t.com.netservices.2010.10.servicebus.connect.xsd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 8eb6931a6ee51..5a5d0adf905e5 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,11 +406,24 @@ + + + + + + + + + + + + + From 24b88f127f206812c3e1dc5fc4d5eae3990b6b4b Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Wed, 22 May 2013 10:59:53 -0700 Subject: [PATCH 12/38] update pom.xml to 0.4.3 --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 9c0bb981d0a7e..b5663e1e6f6a6 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.2 + 0.4.3 jar Microsoft Windows Azure Client API From 7f4c8e5a3020b728e5c362764d4ad838f958daf3 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Wed, 22 May 2013 11:30:00 -0700 Subject: [PATCH 13/38] update changelog for 0.4.2 and 0.4.3 --- ChangeLog.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 2c15b781280a6..bfa94c50772d7 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,13 @@ +2013.05.27 Version 0.4.3 +* Added support for updating existing Queue/Topic/Subscription for Service Bus +* Added support for message lock renewal to support long running message processing for Service Bus +* Added new properties to Queue/Topic/Subscription/Rule for Service Bus +* Added support for rebinding content key for Media Services + +2013.04.16 Version 0.4.2 +* Fixed a bunch of GB18030 encoding issues +* Fixed a service bus issue when the locale is not UTC + 2013.03.12 Version 0.4.1 * Added "Azure-SDK-For-Java/" To User-Agent HTTP header * Added connection string support for Service Bus From abd2999febe8491f33980f32d7b90eda7362ea6b Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Wed, 22 May 2013 12:18:55 -0700 Subject: [PATCH 14/38] update based on code review feedback --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36c1db7012323..6c2ed9bf03431 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,19 @@ This project provides a client library in Java that makes it easy to consume Win * Queues * Create/Read/Update/Delete queues * Send/Receive/Unlock/Delete messages + * Renew message lock * Topics * Create/Read/Update/Delete topics * Create/Read/Update/Delete subscriptions * Create/Read/Update/Delete rules * Send/Receive/Unlock/Delete messages + * Renew message lock * Media Services - * Upload Media Files to Media Services - * Change the encoding on uploaded Media Services - * Provide streaming or download access to uploaded/transformed Media Files + * Create/Read/Update/Delete access policies + * Create/Read/Update/Delete asset files + * Create/Read/Update/Delete assets + * Create/Read/Update/Delete/Rebind content keys + * Create/Read/Update/Cancel/Delete jobs * Service Runtime * Retrieve information about the state of your Azure Compute instances From d6abcae89fa07b768e7cd691780efa757de445cb Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 16:42:13 -0700 Subject: [PATCH 15/38] complete the schema change for correlation filter. --- ...crosoft.com.netservices.2010.10.servicebus.connect.xsd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 5a5d0adf905e5..4bdf4c154a337 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,9 +406,15 @@ + + + + + + - + From 931004ceac9a82437e8586257494c1d9f0b39a9d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 18:18:33 -0700 Subject: [PATCH 16/38] integration test for multiple properties filter. --- ...netservices.2010.10.servicebus.connect.xsd | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 4bdf4c154a337..f39e6c7b02f43 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -414,7 +414,7 @@ - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ed67cb2528177..ef1ffded6b895 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -37,6 +37,9 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.FilterProperties; +import com.microsoft.windowsazure.services.serviceBus.implementation.KeyValueOfStringAnyType; +import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; @@ -641,6 +644,36 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { assertNotNull(created.getAutoDeleteOnIdle()); } + @Test + public void createSubscriptionWithCorrelationFilter() throws Exception { + // Arrange + String topicName = "createSubscriptionWithCorrelationFilter"; + service.createTopic(new TopicInfo(topicName)); + CorrelationFilter correlationFilter = new CorrelationFilter(); + FilterProperties filterProperties = new FilterProperties(); + KeyValueOfStringAnyType keyValueOfStringAnyType = new KeyValueOfStringAnyType(); + keyValueOfStringAnyType.setKey("AKey"); + keyValueOfStringAnyType.setValue(new String("A Value")); + filterProperties.getKeyValueOfstringanyTypes().add(keyValueOfStringAnyType); + correlationFilter.setProperties(filterProperties); + RuleDescription ruleDescription = new RuleDescription(); + ruleDescription.setFilter(correlationFilter); + + // Act + SubscriptionInfo created = service.createSubscription(topicName, + new SubscriptionInfo("MySubscription").setDefaultRuleDescription(ruleDescription)).getValue(); + + // Assert + assertNotNull(created); + assertEquals("MySubscription", created.getName()); + assertEquals(false, created.isRequiresSession()); + assertEquals(true, created.isDeadLetteringOnFilterEvaluationExceptions()); + assertNotNull(created.getCreatedAt()); + assertNotNull(created.getUpdatedAt()); + assertNotNull(created.getAccessedAt()); + assertNotNull(created.getAutoDeleteOnIdle()); + } + @Test public void subscriptionsCanBeListed() throws Exception { // Arrange From 92c356e98a2e4fdaa50acbb3fdc97379bc2f29ae Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 22 May 2013 18:23:41 -0700 Subject: [PATCH 17/38] initial check in for OData support. --- .../models/AbstractListOptions.java | 26 ++++--- .../serviceBus/ServiceBusIntegrationTest.java | 72 +++++++++++++++++++ 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java index 5970d10fc96f7..d18d87edf874d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java @@ -2,21 +2,22 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus.models; public abstract class AbstractListOptions { Integer skip; Integer top; + String filter; public Integer getSkip() { return skip; @@ -37,4 +38,13 @@ public T setTop(Integer top) { this.top = top; return (T) this; } + + public String getFilter() { + return filter; + } + + public T setFilter(String filter) { + this.filter = filter; + return (T) this; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8c20cce470f2..5520d372f5da4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -44,6 +44,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; @@ -382,6 +383,77 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); } + @Test + public void listTopicsUnderASpecificPath() throws ServiceException { + // Arrange + String topicName = "testPathA/testPathB/listTopicUnderASpecificPath"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("startswith(path, \"testPathA\\/testPathB\") eq true")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsUpdatedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicUpdatedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("ModifiedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicAccessedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("AccessedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { + String topicName = "testListTopicCreatedInLastFiveMinutes"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("CreatedAt gt '1/25/2012 3:41:41 PM'")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + + @Test + public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { + String topicName = "testListTopicsUnderSpecificPathWithAtLeastOneMessage"; + + // Act + TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() + .setFilter("startwith(path, 'foo/bar') eq true and messageCount Gt 0")); + + // Assert + assertNotNull(topicInfo); + assertEquals(1, listTopicResult.getItems().size()); + } + @Test public void topicCanBeUpdated() throws ServiceException { // Arrange From fc61698a28d5937da6270ec78c6bfd4b9a733eea Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 16:35:23 -0700 Subject: [PATCH 18/38] implement the integration tests for odata query. --- .../implementation/ServiceBusRestProxy.java | 3 ++ .../serviceBus/IntegrationTestBase.java | 34 ++++++++++++------- .../serviceBus/ServiceBusIntegrationTest.java | 15 +++++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 05e12f33bfac6..c65567db64dd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -307,6 +307,9 @@ private WebResource listOptions(AbstractListOptions options, WebResource path if (options.getSkip() != null) { path = path.queryParam("$skip", options.getSkip().toString()); } + if (options.getFilter() != null) { + path = path.queryParam("$filter", options.getFilter()); + } return path; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index aa8c21ec5cbbc..02e0cbee1984b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus; @@ -21,11 +21,15 @@ import org.junit.BeforeClass; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public abstract class IntegrationTestBase { + + private ServiceBusContract service; + @BeforeClass public static void initializeSystem() { System.setProperty("http.keepAlive", "false"); @@ -36,7 +40,7 @@ public void initialize() throws Exception { boolean testAlphaExists = false; Configuration config = createConfiguration(); - ServiceBusContract service = ServiceBusService.create(config); + service = ServiceBusService.create(config); for (QueueInfo queue : iterateQueues(service)) { String queueName = queue.getPath(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { @@ -52,15 +56,21 @@ public void initialize() throws Exception { } } } + + removeTopics(); + + if (!testAlphaExists) { + service.createQueue(new QueueInfo("TestAlpha")); + } + } + + protected void removeTopics() throws ServiceException { for (TopicInfo topic : iterateTopics(service)) { String topicName = topic.getPath(); if (topicName.startsWith("Test") || topicName.startsWith("test")) { service.deleteTopic(topicName); } } - if (!testAlphaExists) { - service.createQueue(new QueueInfo("TestAlpha")); - } } @AfterClass diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 5520d372f5da4..c50b7a0307fc6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -413,7 +413,8 @@ public void listTopicsUpdatedInLastFiveMinutes() throws ServiceException { } @Test - public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { + public void listTopicsAccessedSinceASpecificTime() throws ServiceException { + removeTopics(); String topicName = "testListTopicAccessedInLastFiveMinutes"; // Act @@ -427,7 +428,8 @@ public void listTopicsAccessedInLastFiveMinutes() throws ServiceException { } @Test - public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { + public void listTopicsCreatedSinceASpecificTime() throws ServiceException { + removeTopics(); String topicName = "testListTopicCreatedInLastFiveMinutes"; // Act @@ -442,15 +444,20 @@ public void listTopicsCreatedInLastFiveMinutes() throws ServiceException { @Test public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { - String topicName = "testListTopicsUnderSpecificPathWithAtLeastOneMessage"; + removeTopics(); + String topicName = "testListTopics/UnderSpecificPathWithAtLeastOneMessage"; + String secondTopicName = "testListTopics/UnderNoMessage"; // Act TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); + TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); + service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startwith(path, 'foo/bar') eq true and messageCount Gt 0")); + .setFilter("startwith(path, 'testListTopics/Under') eq true and messageCount Gt 0")); // Assert assertNotNull(topicInfo); + assertNotNull(secondTopicInfo); assertEquals(1, listTopicResult.getItems().size()); } From cdecace8524f26004d34ea5fe319c5b46f1b8866 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 16:54:33 -0700 Subject: [PATCH 19/38] modification of service bus integration test. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 1600b71d6cb99..8020a4d3799d1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -568,7 +568,7 @@ public void listTopicsUnderASpecificPath() throws ServiceException { // Act TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startswith(path, \"testPathA\\/testPathB\") eq true")); + .setFilter("startswith(path, 'testPathA/testPathB') eq true")); // Assert assertNotNull(topicInfo); @@ -629,8 +629,7 @@ public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceExc TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); - ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions() - .setFilter("startwith(path, 'testListTopics/Under') eq true and messageCount Gt 0")); + ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions().setFilter("MessageCount gt 0")); // Assert assertNotNull(topicInfo); From dc4e7d2ad555ccc94e7d32a2de30637732d5bb00 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 17:10:43 -0700 Subject: [PATCH 20/38] remove invalid scenarios. --- .../serviceBus/ServiceBusIntegrationTest.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8020a4d3799d1..121ec2ffd8c23 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -619,24 +619,6 @@ public void listTopicsCreatedSinceASpecificTime() throws ServiceException { assertEquals(1, listTopicResult.getItems().size()); } - @Test - public void listTopicsUnderSpecificPathWithAtLeastOneMessage() throws ServiceException { - removeTopics(); - String topicName = "testListTopics/UnderSpecificPathWithAtLeastOneMessage"; - String secondTopicName = "testListTopics/UnderNoMessage"; - - // Act - TopicInfo topicInfo = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); - TopicInfo secondTopicInfo = service.createTopic(new TopicInfo().setPath(secondTopicName)).getValue(); - service.sendTopicMessage(topicName, new BrokeredMessage("Hello!")); - ListTopicsResult listTopicResult = service.listTopics(new ListTopicsOptions().setFilter("MessageCount gt 0")); - - // Assert - assertNotNull(topicInfo); - assertNotNull(secondTopicInfo); - assertEquals(1, listTopicResult.getItems().size()); - } - @Test public void topicCreatedContainsMetadata() throws ServiceException { // Arrange From 8d1b7718c709dc849caedc53dc1a89daa811364f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 23 May 2013 17:29:42 -0700 Subject: [PATCH 21/38] fix a broken unit test for odata query. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 121ec2ffd8c23..7724d8d2fcbfc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -601,7 +601,7 @@ public void listTopicsAccessedSinceASpecificTime() throws ServiceException { // Assert assertNotNull(topicInfo); - assertEquals(1, listTopicResult.getItems().size()); + assertEquals(0, listTopicResult.getItems().size()); } @Test From 2c564fcd1b8870da7d1b40dfcccbd9667d8385e6 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 24 May 2013 17:17:26 -0700 Subject: [PATCH 22/38] separate message count details into a separated namespace. --- .../serviceBus/implementation/EntryModel.java | 19 +++++++------ .../src/main/resources/package-names.xjb | 5 ++++ ...netservices.2010.10.servicebus.connect.xsd | 18 ++++-------- ...oft.com.netservices.2011.06.servicebus.xsd | 28 +++++++++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 24 ++++++++++++++++ 5 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java index 71f11d9e6e463..248b2afcf145e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus.implementation; @@ -18,6 +18,9 @@ public class EntryModel { Entry entry; T model; + public EntryModel() { + } + public EntryModel(Entry entry, T model) { this.entry = entry; this.model = model; diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 70e0e3714dd7b..3befcf2e0bb08 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -4,6 +4,11 @@ xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc"> + + + + + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index eeb464a32d625..c79fba2d99c66 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -2,6 +2,7 @@ + @@ -150,7 +152,7 @@ - + @@ -281,7 +283,7 @@ - + @@ -376,16 +378,6 @@ - - - - - - - - - - @@ -556,7 +548,7 @@ - + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd new file mode 100644 index 0000000000000..406ce46ddd86b --- /dev/null +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index e0991c81b2f4f..50dc4dfb89c5c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -16,12 +16,16 @@ import static org.junit.Assert.*; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; + import org.junit.Before; import org.junit.Test; @@ -205,6 +209,26 @@ public void getTopicMessageCountDetails() throws Exception { } + @Test + public void deSerializeMessageCountDetails() throws Exception { + // Arrange + // String queueInfoString = "https://gongchen1.servicebus.windows.net/testGetQueueMessageCountDetails?api-version=2012-08testGetQueueMessageCountDetails2013-05-24T18:15:47Z2013-05-24T18:15:47Zgongchen1PT1M1024falsefalseP10675199DT2H48M5.4775807SfalsePT10M10true1551falseActive2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.8919861Ztrue10000P10675199DT2H48M5.4775807S"; + + File queueInfoFile = new File("d:\\src\\jaxb\\queueinfo.xml"); + + JAXBContext jaxbContext = JAXBContext.newInstance(String.class); + + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + + String result = (String) jaxbUnmarshaller.unmarshal(queueInfoFile); + + // QueueInfo queueInfo = (QueueInfo) jaxbUnmarshaller.unmarshal(queueInfoFile); + + // Act + assertNotNull(result); + // Assert + } + @Test public void getSubscriptionMessageCountDetails() throws Exception { From d41dfe049b83fbea3c6361a2744ea62fc7a83bdf Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 24 May 2013 17:26:33 -0700 Subject: [PATCH 23/38] fix a typo for the schema. --- .../schemas.microsoft.com.netservices.2011.06.servicebus.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index 406ce46ddd86b..b82e6e6388d90 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -5,7 +5,7 @@ xmlns:tnsn="http://schemas.microsoft.com/netservices/2011/06/servicebus" elementFormDefault="qualified" attributeFormDefault="qualified" - targetNamespace="http://schemas.microsoft.com/netservices/2011/06/servicebus/connect" + targetNamespace="http://schemas.microsoft.com/netservices/2011/06/servicebus" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="0.2" From 409a11267bf79accbb9ef2bfc19b9dbea7e45ab1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 28 May 2013 16:13:57 -0700 Subject: [PATCH 24/38] a fix for servicebus schema. --- microsoft-azure-api/src/main/resources/servicebus-atom.xsd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index b8387023a54be..af199118fb4cc 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -3,6 +3,9 @@ attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/"> + From 704be53cbdde3b580a7ad921cc47e2999d007709 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 3 Jun 2013 16:57:36 -0700 Subject: [PATCH 25/38] remove bad service bus design. --- ...t.com.netservices.2010.10.servicebus.connect.xsd | 13 ------------- .../serviceBus/ServiceBusIntegrationTest.java | 11 ++--------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index f39e6c7b02f43..dde511d1558c8 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -406,17 +406,6 @@ - - - - - - - - - - - @@ -429,12 +418,10 @@ - - diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 36a3ef04cce5b..39958694b2589 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -37,8 +37,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.FilterProperties; -import com.microsoft.windowsazure.services.serviceBus.implementation.KeyValueOfStringAnyType; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; @@ -707,15 +705,10 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { @Test public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange - String topicName = "createSubscriptionWithCorrelationFilter"; + String topicName = "testCreateSubscriptionWithCorrelationFilter"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); - FilterProperties filterProperties = new FilterProperties(); - KeyValueOfStringAnyType keyValueOfStringAnyType = new KeyValueOfStringAnyType(); - keyValueOfStringAnyType.setKey("AKey"); - keyValueOfStringAnyType.setValue(new String("A Value")); - filterProperties.getKeyValueOfstringanyTypes().add(keyValueOfStringAnyType); - correlationFilter.setProperties(filterProperties); + correlationFilter.setContentType("sampleCorrelationId"); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); From e63622eb4ee52ba9b678644f3d2a09ff7e5d1789 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 4 Jun 2013 10:55:12 -0700 Subject: [PATCH 26/38] fix the schema for message count details. --- microsoft-azure-api/pom.xml | 8 +++++--- ....com.netservices.2010.10.servicebus.connect.xsd | 4 ++-- ...icrosoft.com.netservices.2011.06.servicebus.xsd | 14 +++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 9c0bb981d0a7e..f1c0aca272d33 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -143,7 +143,7 @@ org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.8.0 + 0.8.3 generate-sources @@ -154,16 +154,18 @@ true + true + true org.jvnet.jaxb2_commons jaxb2-basics - 0.6.0 + 0.6.4 org.jvnet.jaxb2_commons jaxb2-basics-annotate - 0.6.0 + 0.6.4 diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index c79fba2d99c66..ed557fbea1df5 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -22,8 +22,8 @@ - - + + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index b82e6e6388d90..8c184128c6426 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -1,17 +1,14 @@ + version="0.2" + jaxb:version="2.0" + xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" + jaxb:extensionBindingPrefixes="xjc"> @@ -24,5 +21,4 @@ - From 74def0cb45be88523f1acaa075893c4b8845cdfa Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 4 Jun 2013 18:01:44 -0700 Subject: [PATCH 27/38] improving unit test for message count details. --- .../serviceBus/ServiceBusIntegrationTest.java | 75 ++++++++++++------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 7024d4d1fc154..f0d61225c162a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -16,16 +16,12 @@ import static org.junit.Assert.*; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; - import org.junit.Before; import org.junit.Test; @@ -190,6 +186,10 @@ public void getQueueMessageCountDetails() throws Exception { service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; // Act QueueInfo queueInfo = service.getQueue(queueName).getValue(); @@ -199,41 +199,66 @@ public void getQueueMessageCountDetails() throws Exception { assertEquals(true, queueInfo.isSupportOrdering()); assertNotNull(countDetails); assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } @Test public void getTopicMessageCountDetails() throws Exception { - // Arrange + // Arrange + String topicName = "TestGetTopicMessageCountDetails"; + service.createTopic(new TopicInfo(topicName)).getValue(); + service.sendTopicMessage(topicName, new BrokeredMessage("Hello World!")); + Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; - // Act + // Act + TopicInfo topicInfo = service.getTopic(topicName).getValue(); + MessageCountDetails countDetails = topicInfo.getCountDetails(); - // Assert + // Assert + assertNotNull(topicInfo); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } @Test - public void deSerializeMessageCountDetails() throws Exception { - // Arrange - // String queueInfoString = "https://gongchen1.servicebus.windows.net/testGetQueueMessageCountDetails?api-version=2012-08testGetQueueMessageCountDetails2013-05-24T18:15:47Z2013-05-24T18:15:47Zgongchen1PT1M1024falsefalseP10675199DT2H48M5.4775807SfalsePT10M10true1551falseActive2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.2785247Z2013-05-24T18:15:52.8919861Ztrue10000P10675199DT2H48M5.4775807S"; - - File queueInfoFile = new File("d:\\src\\jaxb\\queueinfo.xml"); - - JAXBContext jaxbContext = JAXBContext.newInstance(String.class); - - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - - String result = (String) jaxbUnmarshaller.unmarshal(queueInfoFile); + public void getSubscriptionMessageCountDetails() throws Exception { + // Arrange + String topicName = "TestGetSubscriptionMessageCountDetails"; + String subscriptionName = "TestGetSubscriptionMessageCountDetails"; + service.createTopic(new TopicInfo(topicName)).getValue(); + service.createSubscription(topicName, new SubscriptionInfo(subscriptionName)); + Long expectedActiveMessageCount = 1L; + Long expectedDeadLetterMessageCount = 0L; + Long expectedScheduledMessageCount = 0L; + Long expectedTransferMessageCount = 0L; + Long expectedTransferDeadLetterMessageCount = 0L; - // QueueInfo queueInfo = (QueueInfo) jaxbUnmarshaller.unmarshal(queueInfoFile); + // Act + service.sendTopicMessage(topicName, new BrokeredMessage("Hello world!")); + SubscriptionInfo subscriptionInfo = service.getSubscription(topicName, subscriptionName).getValue(); + MessageCountDetails countDetails = subscriptionInfo.getCountDetails(); - // Act - assertNotNull(result); // Assert - } - - @Test - public void getSubscriptionMessageCountDetails() throws Exception { + assertNotNull(subscriptionInfo); + assertNotNull(countDetails); + assertEquals(expectedActiveMessageCount, countDetails.getActiveMessageCount()); + assertEquals(expectedDeadLetterMessageCount, countDetails.getDeadLetterMessageCount()); + assertEquals(expectedScheduledMessageCount, countDetails.getScheduledMessageCount()); + assertEquals(expectedTransferMessageCount, countDetails.getTransferMessageCount()); + assertEquals(expectedTransferDeadLetterMessageCount, countDetails.getTransferDeadLetterMessageCount()); } From 5576deae8bafea3c9c9157fe6c744eee8abad54a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 10:37:40 -0700 Subject: [PATCH 28/38] add javadoc for message count details. --- .../services/serviceBus/models/QueueInfo.java | 6 ++++++ .../services/serviceBus/models/SubscriptionInfo.java | 6 ++++++ .../services/serviceBus/models/TopicInfo.java | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 9f3642b0428b2..2ebe5ed5a5945 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; +// TODO: Auto-generated Javadoc /** * Represents a queue. */ @@ -541,6 +542,11 @@ public QueueInfo setUserMetadata(String userMetadata) { return this; } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance that represents the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 10864cd736c62..675302f172688 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -28,6 +28,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; +// TODO: Auto-generated Javadoc /** * Represents a subscription. */ @@ -431,6 +432,11 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance representing the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index d722ecc218887..44ca571e983e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; +// TODO: Auto-generated Javadoc /** * Represents a topic. */ @@ -407,6 +408,11 @@ public Integer getSubscriptionCount() { return getModel().getSubscriptionCount(); } + /** + * Gets the message count details. + * + * @return A MessageCountDetails instance representing the details of the message count. + */ public MessageCountDetails getCountDetails() { return getModel().getCountDetails(); } @@ -474,6 +480,11 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() { return getModel().getEntityAvailabilityStatus(); } + /** + * Gets the uri. + * + * @return the uri + */ public URI getUri() { return URI.create(getEntry().getId()); } From 1a61a24b1ca40e5f4385e07b8a9b7de7b9fcd7c1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 10:43:38 -0700 Subject: [PATCH 29/38] remove newly introduced TODOs --- .../windowsazure/services/serviceBus/models/QueueInfo.java | 1 - .../services/serviceBus/models/SubscriptionInfo.java | 1 - .../windowsazure/services/serviceBus/models/TopicInfo.java | 1 - 3 files changed, 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 2ebe5ed5a5945..d0600c19ec43f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -29,7 +29,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; -// TODO: Auto-generated Javadoc /** * Represents a queue. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 675302f172688..0df71b38b78f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -28,7 +28,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; -// TODO: Auto-generated Javadoc /** * Represents a subscription. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 44ca571e983e6..d3233b1a81745 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -29,7 +29,6 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; -// TODO: Auto-generated Javadoc /** * Represents a topic. */ From 2bfbfcae9418cf0c8f188c86d1928c70a6566fa9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 5 Jun 2013 13:09:45 -0700 Subject: [PATCH 30/38] code review feedback --- .../schemas.microsoft.com.netservices.2011.06.servicebus.xsd | 2 +- .../services/serviceBus/ServiceBusIntegrationTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd index 8c184128c6426..b3bf4be77e9fd 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2011.06.servicebus.xsd @@ -16,7 +16,7 @@ - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index f0d61225c162a..d2f97235afb67 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -211,8 +211,7 @@ public void getTopicMessageCountDetails() throws Exception { // Arrange String topicName = "TestGetTopicMessageCountDetails"; service.createTopic(new TopicInfo(topicName)).getValue(); - service.sendTopicMessage(topicName, new BrokeredMessage("Hello World!")); - Long expectedActiveMessageCount = 1L; + Long expectedActiveMessageCount = 0L; Long expectedDeadLetterMessageCount = 0L; Long expectedScheduledMessageCount = 0L; Long expectedTransferMessageCount = 0L; From 57f75cc726c377043e3594aed51317bbfbce22ff Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Fri, 7 Jun 2013 13:07:22 -0700 Subject: [PATCH 31/38] updated sample code to use containerPermissions. added java & xml formatting --- README.md | 120 ++++++++++++++++++++++++++---------------------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 6c2ed9bf03431..e90ba41e17c10 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ To get the source code of the SDK via git just type: To get the binaries of this library as distributed by Microsoft, ready for use within your project you can also have them installed by the Java package manager Maven. - - - com.microsoft.windowsazure - microsoft-windowsazure-api - 0.4.3 - - +```xml + + com.microsoft.windowsazure + microsoft-windowsazure-api + 0.4.3 + +``` ##Minimum Requirements * Java 1.6 @@ -72,67 +72,63 @@ account. To host your Java code in Windows Azure, you additionally need to down the full Windows Azure SDK for Java - which includes packaging, emulation, and deployment tools. -##Code Samples +##Code Sample The following is a quick example on how to set up a Azure blob using the API and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed [here](http://www.windowsazure.com/en-us/develop/java/). +```java +import java.io.*; + +import com.microsoft.windowsazure.services.core.storage.*; +import com.microsoft.windowsazure.services.blob.client.*; + +public class BlobSample { + public static final String storageConnectionString = + "DefaultEndpointsProtocol=http;" + + "AccountName=your_account_name;" + + "AccountKey= your_account_name"; + + public static void main(String[] args) { + try { + CloudStorageAccount account; + CloudBlobClient serviceClient; + CloudBlobContainer container; + CloudBlockBlob blob; + + account = CloudStorageAccount.parse(storageConnectionString); + serviceClient = account.createCloudBlobClient(); + // Container name must be lower case. + container = serviceClient.getContainerReference("blobsample"); + container.createIfNotExist(); + + // Set anonymous access on the container. + BlobContainerPermissions containerPermissions; + containerPermissions = new BlobContainerPermissions(); + container.uploadPermissions(containerPermissions); + + // Upload an image file. + blob = container.getBlockBlobReference("image1.jpg"); + File fileReference = new File("c:\\myimages\\image1.jpg"); + blob.upload(new FileInputStream(fileReference), + fileReference.length()); + } catch (FileNotFoundException fileNotFoundException) { + System.out.print("FileNotFoundException encountered: "); + System.out.println(fileNotFoundException.getMessage()); + System.exit(-1); + } catch (StorageException storageException) { + System.out.print("StorageException encountered: "); + System.out.println(storageException.getMessage()); + System.exit(-1); + } catch (Exception e) { + System.out.print("Exception encountered: "); + System.out.println(e.getMessage()); + System.exit(-1); + } - import com.microsoft.windowsazure.services.core.storage.*; - import com.microsoft.windowsazure.services.blob.client.*; - - public class BlobSample { - public static final String storageConnectionString = - "DefaultEndpointsProtocol=http;" + - "AccountName=your_account_name;" + - "AccountKey= your_account_name"; - - public static void main(String[] args) - { - try - { - CloudStorageAccount account; - CloudBlobClient serviceClient; - CloudBlobContainer container; - CloudBlockBlob blob; - - account = CloudStorageAccount.parse(storageConnectionString); - serviceClient = account.createCloudBlobClient(); - // Container name must be lower case. - container = serviceClient.getContainerReference("blobsample"); - container.createIfNotExist(); - - // Set anonymous access on the container. - BlobContainerPermissions containerPermissions; - containerPermissions = new BlobContainerPermissions(); - - // Upload an image file. - blob = container.getBlockBlobReference("image1.jpg"); - File fileReference = new File ("c:\\myimages\\image1.jpg"); - blob.upload(new FileInputStream(fileReference), fileReference.length()); - } - catch (FileNotFoundException fileNotFoundException) - { - System.out.print("FileNotFoundException encountered: "); - System.out.println(fileNotFoundException.getMessage()); - System.exit(-1); - } - catch (StorageException storageException) - { - System.out.print("StorageException encountered: "); - System.out.println(storageException.getMessage()); - System.exit(-1); - } - catch (Exception e) - { - System.out.print("Exception encountered: "); - System.out.println(e.getMessage()); - System.exit(-1); - } - - } } - +} +``` #Need Help? From c06f38c9d5f3a6046b5abe568c953246c4d86f19 Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Fri, 7 Jun 2013 14:39:21 -0700 Subject: [PATCH 32/38] Revert "updated sample code to use containerPermissions. added java & xml formatting" This reverts commit 57f75cc726c377043e3594aed51317bbfbce22ff. --- README.md | 120 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index e90ba41e17c10..6c2ed9bf03431 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ To get the source code of the SDK via git just type: To get the binaries of this library as distributed by Microsoft, ready for use within your project you can also have them installed by the Java package manager Maven. -```xml - - com.microsoft.windowsazure - microsoft-windowsazure-api - 0.4.3 - -``` + + + com.microsoft.windowsazure + microsoft-windowsazure-api + 0.4.3 + + ##Minimum Requirements * Java 1.6 @@ -72,63 +72,67 @@ account. To host your Java code in Windows Azure, you additionally need to down the full Windows Azure SDK for Java - which includes packaging, emulation, and deployment tools. -##Code Sample +##Code Samples The following is a quick example on how to set up a Azure blob using the API and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed [here](http://www.windowsazure.com/en-us/develop/java/). -```java -import java.io.*; - -import com.microsoft.windowsazure.services.core.storage.*; -import com.microsoft.windowsazure.services.blob.client.*; - -public class BlobSample { - public static final String storageConnectionString = - "DefaultEndpointsProtocol=http;" - + "AccountName=your_account_name;" - + "AccountKey= your_account_name"; - - public static void main(String[] args) { - try { - CloudStorageAccount account; - CloudBlobClient serviceClient; - CloudBlobContainer container; - CloudBlockBlob blob; - - account = CloudStorageAccount.parse(storageConnectionString); - serviceClient = account.createCloudBlobClient(); - // Container name must be lower case. - container = serviceClient.getContainerReference("blobsample"); - container.createIfNotExist(); - - // Set anonymous access on the container. - BlobContainerPermissions containerPermissions; - containerPermissions = new BlobContainerPermissions(); - container.uploadPermissions(containerPermissions); - - // Upload an image file. - blob = container.getBlockBlobReference("image1.jpg"); - File fileReference = new File("c:\\myimages\\image1.jpg"); - blob.upload(new FileInputStream(fileReference), - fileReference.length()); - } catch (FileNotFoundException fileNotFoundException) { - System.out.print("FileNotFoundException encountered: "); - System.out.println(fileNotFoundException.getMessage()); - System.exit(-1); - } catch (StorageException storageException) { - System.out.print("StorageException encountered: "); - System.out.println(storageException.getMessage()); - System.exit(-1); - } catch (Exception e) { - System.out.print("Exception encountered: "); - System.out.println(e.getMessage()); - System.exit(-1); - } + import com.microsoft.windowsazure.services.core.storage.*; + import com.microsoft.windowsazure.services.blob.client.*; + + public class BlobSample { + public static final String storageConnectionString = + "DefaultEndpointsProtocol=http;" + + "AccountName=your_account_name;" + + "AccountKey= your_account_name"; + + public static void main(String[] args) + { + try + { + CloudStorageAccount account; + CloudBlobClient serviceClient; + CloudBlobContainer container; + CloudBlockBlob blob; + + account = CloudStorageAccount.parse(storageConnectionString); + serviceClient = account.createCloudBlobClient(); + // Container name must be lower case. + container = serviceClient.getContainerReference("blobsample"); + container.createIfNotExist(); + + // Set anonymous access on the container. + BlobContainerPermissions containerPermissions; + containerPermissions = new BlobContainerPermissions(); + + // Upload an image file. + blob = container.getBlockBlobReference("image1.jpg"); + File fileReference = new File ("c:\\myimages\\image1.jpg"); + blob.upload(new FileInputStream(fileReference), fileReference.length()); + } + catch (FileNotFoundException fileNotFoundException) + { + System.out.print("FileNotFoundException encountered: "); + System.out.println(fileNotFoundException.getMessage()); + System.exit(-1); + } + catch (StorageException storageException) + { + System.out.print("StorageException encountered: "); + System.out.println(storageException.getMessage()); + System.exit(-1); + } + catch (Exception e) + { + System.out.print("Exception encountered: "); + System.out.println(e.getMessage()); + System.exit(-1); + } + + } } -} -``` + #Need Help? From 8ee99c91fd4304d284dcdc60ce2338db13b6e3e6 Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Mon, 10 Jun 2013 15:14:38 -0700 Subject: [PATCH 33/38] fixed README.md fixes #360 - code sample now uses containerPermissions variable - added java and xml tags for syntax highlighting --- README.md | 117 ++++++++++++++++++++++++++---------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index a8805eb2e3262..97d57a4855d2d 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,13 @@ To get the source code of the SDK via git just type: To get the binaries of this library as distributed by Microsoft, ready for use within your project you can also have them installed by the Java package manager Maven. - - com.microsoft.windowsazure - microsoft-windowsazure-api - 0.4.2 - +```xml + + com.microsoft.windowsazure + microsoft-windowsazure-api + 0.4.2 + +``` ##Minimum Requirements @@ -61,67 +63,62 @@ account. To host your Java code in Windows Azure, you additionally need to down the full Windows Azure SDK for Java - which includes packaging, emulation, and deployment tools. -##Code Samples +##Code Sample The following is a quick example on how to set up a Azure blob using the API and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed [here](http://www.windowsazure.com/en-us/develop/java/). +```java +import java.io.*; + +import com.microsoft.windowsazure.services.core.storage.*; +import com.microsoft.windowsazure.services.blob.client.*; + +public class BlobSample { + public static final String storageConnectionString = + "DefaultEndpointsProtocol=http;" + + "AccountName=your_account_name;" + + "AccountKey= your_account_name"; + + public static void main(String[] args) { + try { + CloudStorageAccount account; + CloudBlobClient serviceClient; + CloudBlobContainer container; + CloudBlockBlob blob; + + account = CloudStorageAccount.parse(storageConnectionString); + serviceClient = account.createCloudBlobClient(); + // Container name must be lower case. + container = serviceClient.getContainerReference("blobsample"); + container.createIfNotExist(); + + // Set anonymous access on the container. + BlobContainerPermissions containerPermissions; + containerPermissions = new BlobContainerPermissions(); + container.uploadPermissions(containerPermissions); + + // Upload an image file. + blob = container.getBlockBlobReference("image1.jpg"); + File fileReference = new File("c:\\myimages\\image1.jpg"); + blob.upload(new FileInputStream(fileReference), fileReference.length()); + } catch (FileNotFoundException fileNotFoundException) { + System.out.print("FileNotFoundException encountered: "); + System.out.println(fileNotFoundException.getMessage()); + System.exit(-1); + } catch (StorageException storageException) { + System.out.print("StorageException encountered: "); + System.out.println(storageException.getMessage()); + System.exit(-1); + } catch (Exception e) { + System.out.print("Exception encountered: "); + System.out.println(e.getMessage()); + System.exit(-1); + } - import com.microsoft.windowsazure.services.core.storage.*; - import com.microsoft.windowsazure.services.blob.client.*; - - public class BlobSample { - public static final String storageConnectionString = - "DefaultEndpointsProtocol=http;" + - "AccountName=your_account_name;" + - "AccountKey= your_account_name"; - - public static void main(String[] args) - { - try - { - CloudStorageAccount account; - CloudBlobClient serviceClient; - CloudBlobContainer container; - CloudBlockBlob blob; - - account = CloudStorageAccount.parse(storageConnectionString); - serviceClient = account.createCloudBlobClient(); - // Container name must be lower case. - container = serviceClient.getContainerReference("blobsample"); - container.createIfNotExist(); - - // Set anonymous access on the container. - BlobContainerPermissions containerPermissions; - containerPermissions = new BlobContainerPermissions(); - - // Upload an image file. - blob = container.getBlockBlobReference("image1.jpg"); - File fileReference = new File ("c:\\myimages\\image1.jpg"); - blob.upload(new FileInputStream(fileReference), fileReference.length()); - } - catch (FileNotFoundException fileNotFoundException) - { - System.out.print("FileNotFoundException encountered: "); - System.out.println(fileNotFoundException.getMessage()); - System.exit(-1); - } - catch (StorageException storageException) - { - System.out.print("StorageException encountered: "); - System.out.println(storageException.getMessage()); - System.exit(-1); - } - catch (Exception e) - { - System.out.print("Exception encountered: "); - System.out.println(e.getMessage()); - System.exit(-1); - } - - } } - +} +``` #Need Help? From 07297a3616b6cf11742d7f4da475f1d654a087e0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 10 Jun 2013 16:20:04 -0700 Subject: [PATCH 34/38] harmonize the design with mooncake requirement. --- .../ServiceBusConnectionSettings.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java index dc0d3da353c8c..00405bc666c93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java @@ -1,11 +1,11 @@ /** * Copyright Microsoft Corporation - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,18 +15,17 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException; - import java.net.URI; import java.net.URISyntaxException; +import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException; + /** * Class that encapsulates all the various settings needed * to connect to Service Bus, provided via either a * connection string or via separate configuration variables. *

- * The connection string is looked for first, falling back - * to separate config values if not found. + * The connection string is looked for first, falling back to separate config values if not found. */ class ServiceBusConnectionSettings { private String uri; @@ -34,10 +33,12 @@ class ServiceBusConnectionSettings { private String wrapName; private String wrapPassword; - public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName, String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException { + public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName, + String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException { if (connectionString != null) { parseConnectionString(connectionString); - } else { + } + else { this.uri = uri; this.wrapUri = wrapUri; this.wrapName = wrapName; @@ -61,7 +62,8 @@ public String getWrapPassword() { return wrapPassword; } - private boolean parseConnectionString(String connectionString) throws URISyntaxException, ConnectionStringSyntaxException { + private boolean parseConnectionString(String connectionString) throws URISyntaxException, + ConnectionStringSyntaxException { ServiceBusConnectionString cs = new ServiceBusConnectionString(connectionString); setUri(cs); setWrapUri(cs); @@ -79,8 +81,9 @@ private void setWrapUri(ServiceBusConnectionString connectionString) throws URIS URI hostUri = new URI(uri); String namespace = hostUri.getHost().split("\\.")[0]; wrapUri = "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"; - } else { - wrapUri = connectionString.getStsEndpoint(); + } + else { + wrapUri = connectionString.getStsEndpoint() + "/WRAPv0.9"; } } } From 3ebd298828ce11222b58263d8908528da8d6dd8a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 10:42:55 -0700 Subject: [PATCH 35/38] improve the unit test to ensure that the created correlation filter does exist. --- .../services/serviceBus/ServiceBusIntegrationTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 39958694b2589..a8daefc71df74 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -706,9 +706,10 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange String topicName = "testCreateSubscriptionWithCorrelationFilter"; + String expectedCorrelationId = "sampleCorrelationId"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); - correlationFilter.setContentType("sampleCorrelationId"); + correlationFilter.setCorrelationId(expectedCorrelationId); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); @@ -716,6 +717,9 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription").setDefaultRuleDescription(ruleDescription)).getValue(); + RuleInfo ruleInfo = service.getRule(topicName, "MySubscription", "$Default").getValue(); + CorrelationFilter correlationFilterResult = (CorrelationFilter) ruleInfo.getFilter(); + // Assert assertNotNull(created); assertEquals("MySubscription", created.getName()); @@ -725,6 +729,8 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { assertNotNull(created.getUpdatedAt()); assertNotNull(created.getAccessedAt()); assertNotNull(created.getAutoDeleteOnIdle()); + assertNotNull(correlationFilterResult); + assertEquals(expectedCorrelationId, correlationFilterResult.getCorrelationId()); } @Test From 63e3fc94412a401d8fc01d1d6af1ab86b7a767c0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 11:28:00 -0700 Subject: [PATCH 36/38] address code review fedback by trimming the / at the end of the sts end point. --- .../serviceBus/implementation/ServiceBusConnectionSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java index 00405bc666c93..20bd238789b9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusConnectionSettings.java @@ -83,7 +83,7 @@ private void setWrapUri(ServiceBusConnectionString connectionString) throws URIS wrapUri = "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"; } else { - wrapUri = connectionString.getStsEndpoint() + "/WRAPv0.9"; + wrapUri = connectionString.getStsEndpoint().replaceAll("\\/$", "") + "/WRAPv0.9"; } } } From a4586585ed2ba7885f1e24848beacc5ad5afa069 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Jun 2013 13:33:04 -0700 Subject: [PATCH 37/38] more test improvements to validate the properties on correlation filter. --- .../serviceBus/ServiceBusIntegrationTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index a8daefc71df74..75e648b6b449d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -707,9 +707,21 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { // Arrange String topicName = "testCreateSubscriptionWithCorrelationFilter"; String expectedCorrelationId = "sampleCorrelationId"; + String expectedContentType = "sampleContentType"; + String expectedLabel = "sampleLabel"; + String expectedMessageId = "sampleMessageId"; + String expectedSessionId = "sampleSessionId"; + String expectedReplyTo = "sampleReplyTo"; + String expectedTo = "sampleTo"; service.createTopic(new TopicInfo(topicName)); CorrelationFilter correlationFilter = new CorrelationFilter(); correlationFilter.setCorrelationId(expectedCorrelationId); + correlationFilter.setContentType(expectedContentType); + correlationFilter.setLabel(expectedLabel); + correlationFilter.setMessageId(expectedMessageId); + correlationFilter.setReplyTo(expectedReplyTo); + correlationFilter.setSessionId(expectedSessionId); + correlationFilter.setTo(expectedTo); RuleDescription ruleDescription = new RuleDescription(); ruleDescription.setFilter(correlationFilter); @@ -731,6 +743,12 @@ public void createSubscriptionWithCorrelationFilter() throws Exception { assertNotNull(created.getAutoDeleteOnIdle()); assertNotNull(correlationFilterResult); assertEquals(expectedCorrelationId, correlationFilterResult.getCorrelationId()); + assertEquals(expectedContentType, correlationFilterResult.getContentType()); + assertEquals(expectedLabel, correlationFilterResult.getLabel()); + assertEquals(expectedMessageId, correlationFilterResult.getMessageId()); + assertEquals(expectedSessionId, correlationFilterResult.getSessionId()); + assertEquals(expectedReplyTo, correlationFilterResult.getReplyTo()); + assertEquals(expectedTo, correlationFilterResult.getTo()); } @Test From f9fb1ff38deb267b8caa20adf8640f26fdb438b8 Mon Sep 17 00:00:00 2001 From: Anu Bandi Date: Thu, 13 Jun 2013 11:48:20 -0700 Subject: [PATCH 38/38] fixed mislabeled string --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc83347a4da73..f12d7aa79956f 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ public class BlobSample { public static final String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=your_account_name;" - + "AccountKey= your_account_name"; + + "AccountKey= your_account_key"; public static void main(String[] args) { try {