Skip to content

Commit

Permalink
Merge pull request #386 from gcheng/sbbugs
Browse files Browse the repository at this point in the history
a unit test trying to repro service bus large message failure.
  • Loading branch information
Albert Cheng committed Jul 20, 2013
2 parents bb186b0 + 29a1551 commit b96cd5d
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b96cd5d

Please sign in to comment.