From 29a1551eae05f11fc58b04b20a397fb6d044ef51 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 18 Jul 2013 10:35:37 -0700 Subject: [PATCH] a unit test trying to repeat service bus large message failure. --- .../serviceBus/ServiceBusIntegrationTest.java | 28 +++++++++++++++++++ 1 file changed, 28 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 971df258c02c..51462c07c5fc 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 @@ -67,6 +67,14 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { .setTimeout(5); static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); + private String createLongString(int length) { + String result = new String(); + for (int i = 0; i < length; i++) { + result = result + "a"; + } + return result; + } + @Before public void createService() throws Exception { // reinitialize configuration from known state @@ -278,6 +286,26 @@ public void receiveMessageWorks() throws Exception { assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size)); } + @Test + public void receiveLargeMessageWorks() throws Exception { + // Arrange + String queueName = "TestReceiveLargeMessageWorks"; + service.createQueue(new QueueInfo(queueName)); + String expectedBody = createLongString(64000); + BrokeredMessage expectedMessage = new BrokeredMessage(expectedBody); + service.sendQueueMessage(queueName, expectedMessage); + + // Act + BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + byte[] data = new byte[64000]; + int size = message.getBody().read(data); + + // Assert + assertEquals(expectedBody.length(), size); + assertArrayEquals(expectedBody.getBytes(), Arrays.copyOf(data, size)); + + } + @Test public void renewSubscriptionMessageLockWorks() throws Exception { // Arrange