PriorityChannel now uses a null semaphore to indicate an unbounded queue rather than relying on Integer.MAX_VALUE.

This commit is contained in:
Mark Fisher
2008-11-12 16:56:09 +00:00
parent 3a3ac1c298
commit 0ef08a42ba
2 changed files with 54 additions and 24 deletions

View File

@@ -99,6 +99,20 @@ public class PriorityChannelTests {
assertEquals("test-LOW", channel.receive(0).getPayload());
}
@Test
public void testUnboundedCapacity() {
PriorityChannel channel = new PriorityChannel();
Message<?> highPriority = createPriorityMessage(MessagePriority.HIGH);
Message<?> lowPriority = createPriorityMessage(MessagePriority.LOW);
Message<?> nullPriority = new StringMessage("test-NULL");
channel.send(lowPriority);
channel.send(highPriority);
channel.send(nullPriority);
assertEquals("test-HIGH", channel.receive(0).getPayload());
assertEquals("test-NULL", channel.receive(0).getPayload());
assertEquals("test-LOW", channel.receive(0).getPayload());
}
private static Message<String> createPriorityMessage(MessagePriority priority) {
return MessageBuilder.withPayload("test-" + priority).setPriority(priority).build();