Assert.assertEquals(10, queue.getDeliveringCount());
}
public void testBusyConsumerThenAddMoreMessages() throws Exception
{
QueueImpl queue = new QueueImpl(1,
QueueImplTest.address1,
QueueImplTest.queue1,
null,
false,
true,
scheduledExecutor,
null,
null,
null,
executor);
FakeConsumer consumer = new FakeConsumer();
consumer.setStatusImmediate(HandleStatus.BUSY);
queue.addConsumer(consumer);
final int numMessages = 10;
List<MessageReference> refs = new ArrayList<MessageReference>();
for (int i = 0; i < numMessages; i++)
{
MessageReference ref = generateReference(queue, i);
refs.add(ref);
queue.addLast(ref);
}
Assert.assertEquals(10, queue.getMessageCount());
Assert.assertEquals(0, queue.getScheduledCount());
Assert.assertEquals(0, queue.getDeliveringCount());
queue.deliverNow();
Assert.assertEquals(10, queue.getMessageCount());
Assert.assertEquals(0, queue.getScheduledCount());
Assert.assertEquals(0, queue.getDeliveringCount());
Assert.assertTrue(consumer.getReferences().isEmpty());
for (int i = numMessages; i < numMessages * 2; i++)
{
MessageReference ref = generateReference(queue, i);
refs.add(ref);
queue.addLast(ref);
}
Assert.assertEquals(20, queue.getMessageCount());
Assert.assertEquals(0, queue.getScheduledCount());
Assert.assertEquals(0, queue.getDeliveringCount());
Assert.assertTrue(consumer.getReferences().isEmpty());
consumer.setStatusImmediate(HandleStatus.HANDLED);
for (int i = numMessages * 2; i < numMessages * 3; i++)
{
MessageReference ref = generateReference(queue, i);
refs.add(ref);
queue.addLast(ref);
}
queue.deliverNow();
assertRefListsIdenticalRefs(refs, consumer.getReferences());
Assert.assertEquals(30, queue.getMessageCount());
Assert.assertEquals(0, queue.getScheduledCount());
Assert.assertEquals(30, queue.getDeliveringCount());
}