Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #329

Merged
merged 2 commits into from
Apr 22, 2013
Merged

Dev #329

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ else if (options.isPeekLock()) {
throw new RuntimeException("Unknown ReceiveMode");
}

if (clientResult.getStatus() == 204) {
return null;
}

BrokerProperties brokerProperties;
if (clientResult.getHeaders().containsKey("BrokerProperties")) {
brokerProperties = mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult;
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.RuleInfo;
import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo;
import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo;
Expand Down Expand Up @@ -172,6 +173,21 @@ public void receiveMessageWorks() throws Exception {
assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size));
}

@Test
public void receiveMessageEmptyQueueWorks() throws Exception {
// Arrange
String queueName = "TestReceiveMessageEmptyQueueWorks";
service.createQueue(new QueueInfo(queueName));

// Act
ReceiveQueueMessageResult receiveQueueMessageResult = service.receiveQueueMessage(queueName,
RECEIVE_AND_DELETE_5_SECONDS);

// Assert
assertNotNull(receiveQueueMessageResult);
assertNull(receiveQueueMessageResult.getValue());
}

@Test
public void peekLockMessageWorks() throws Exception {
// Arrange
Expand All @@ -189,6 +205,20 @@ public void peekLockMessageWorks() throws Exception {
assertEquals("Hello Again", new String(data, 0, size));
}

@Test
public void peekLockMessageEmptyQueueWorks() throws Exception {
// Arrange
String queueName = "TestPeekLockMessageEmptyQueueWorks";
service.createQueue(new QueueInfo(queueName));

// Act
ReceiveQueueMessageResult result = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS);

// Assert
assertNotNull(result);
assertNull(result.getValue());
}

@Test
public void peekLockedMessageCanBeCompleted() throws Exception {
// Arrange
Expand Down Expand Up @@ -252,8 +282,20 @@ public void peekLockedMessageCanBeDeleted() throws Exception {
// Assert
assertNotNull(lockToken);
assertNotNull(lockedUntil);
assertNull(receivedMessage.getLockToken());
assertNull(receivedMessage.getLockedUntilUtc());
assertNull(receivedMessage);
}

@Test
public void emptyQueueReturnsNullMessage() throws Exception {
// Arrange
String queueName = "testEmptyQueueReturnsNullMessage";
service.createQueue(new QueueInfo(queueName));

// Act
BrokeredMessage brokeredMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue();

// Assert
assertNull(brokeredMessage);
}

@Test
Expand Down