@Test
public void testResequencingWithCapacity() throws InterruptedException {
this.resequencer.setReleaseStrategy(new SequenceSizeReleaseStrategy(true));
this.resequencer.setMessageStore(new SimpleMessageStore(3, 2));
QueueChannel replyChannel = new QueueChannel();
Message<?> message1 = createMessage("123", "ABC", 4, 4, replyChannel);
Message<?> message2 = createMessage("456", "ABC", 4, 2, replyChannel);
Message<?> message3 = createMessage("789", "ABC", 4, 1, replyChannel);
this.resequencer.handleMessage(message1);
this.resequencer.handleMessage(message2);
try {
this.resequencer.handleMessage(message3);
fail("Expected exception");
}
catch (MessagingException e) {
assertThat(e.getMessage(), containsString("out of capacity (2) for group 'ABC'"));
}
}