@Test
public void peekLockedMessageCanBeUnlocked() throws Exception {
// Arrange
String queueName = "TestPeekLockedMessageCanBeUnlocked";
service.createQueue(new QueueInfo(queueName));
service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again"));
BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName,
PEEK_LOCK_5_SECONDS).getValue();
// Act
String lockToken = peekedMessage.getLockToken();
Date lockedUntil = peekedMessage.getLockedUntilUtc();
service.unlockMessage(peekedMessage);
BrokeredMessage receivedMessage = service.receiveQueueMessage(
queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue();
// Assert
assertNotNull(lockToken);
assertNotNull(lockedUntil);
assertNull(receivedMessage.getLockToken());
assertNull(receivedMessage.getLockedUntilUtc());
}