PagingFilteredQueue queue1 =
new PagingFilteredQueue("queue1", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic1"), queue1);
PagingFilteredQueue queue2 =
new PagingFilteredQueue("queue2", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic1"), queue2);
PagingFilteredQueue queue3 =
new PagingFilteredQueue("queue3", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic1"), queue3);
PagingFilteredQueue queue4 =
new PagingFilteredQueue("queue4", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic2"), queue4);
PagingFilteredQueue queue5 =
new PagingFilteredQueue("queue5", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic2"), queue5);
PagingFilteredQueue queue6 =
new PagingFilteredQueue("queue6", channelIDManager.getID(), ms, pm, true, false,
-1, null);
postOffice.bindQueue(new SimpleCondition("topic2"), queue6);
SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue1.add(receiver1);
SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue2.add(receiver2);
SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue3.add(receiver3);
SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue4.add(receiver4);
SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue5.add(receiver5);
SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
queue6.add(receiver6);
queue1.deactivate();
queue2.deactivate();
queue5.deactivate();
queue6.deactivate();
assertFalse(queue1.isActive());
assertFalse(queue2.isActive());
assertFalse(queue5.isActive());
assertFalse(queue6.isActive());
assertTrue(queue3.isActive());
assertTrue(queue4.isActive());
Message msg1 = CoreMessageFactory.createCoreMessage(1);
MessageReference ref1 = ms.reference(msg1);
boolean routed = postOffice.route(ref1, new SimpleCondition("topic1"), null);
assertTrue(routed);
List msgs = receiver1.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
msgs = receiver2.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
msgs = receiver3.getMessages();
assertNotNull(msgs);
assertEquals(1, msgs.size());
Message msgRec = (Message)msgs.get(0);
assertTrue(msg1 == msgRec);
receiver3.acknowledge(msgRec, null);
msgs = queue3.browse();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
msgs = receiver4.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
msgs = receiver5.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
msgs = receiver6.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
receiver3.clear();
Message msg2 = CoreMessageFactory.createCoreMessage(2);
MessageReference ref2 = ms.reference(msg2);
routed = postOffice.route(ref2, new SimpleCondition("topic2"), null);
assertTrue(routed);
msgs = receiver1.getMessages();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());