// the first subscription as the processQueue method proceeds.
List<QueueEntry> msgListSub1 = createEntriesList(msg1, msg2, msg3);
List<QueueEntry> msgListSub2 = createEntriesList(msg4);
List<QueueEntry> msgListSub3 = createEntriesList(msg5);
MockSubscription sub1 = new MockSubscription(msgListSub1);
MockSubscription sub2 = new MockSubscription(msgListSub2);
MockSubscription sub3 = new MockSubscription(msgListSub3);
// register the subscriptions
testQueue.registerSubscription(sub1, false);
testQueue.registerSubscription(sub2, false);
testQueue.registerSubscription(sub3, false);
//check that no messages have been delivered to the
//subscriptions during registration
assertEquals("No messages should have been delivered yet", 0, sub1.getMessages().size());
assertEquals("No messages should have been delivered yet", 0, sub2.getMessages().size());
assertEquals("No messages should have been delivered yet", 0, sub3.getMessages().size());
// call processQueue to deliver the messages
testQueue.processQueue(new QueueRunner(testQueue)
{
@Override
public void run()
{
// we dont actually want/need this runner to do any work
// because we we are already doing it!
}
});
// check expected messages delivered to correct consumers
verifyRecievedMessages(msgListSub1, sub1.getMessages());
verifyRecievedMessages(msgListSub2, sub2.getMessages());
verifyRecievedMessages(msgListSub3, sub3.getMessages());
}