//Route to condition1 from office1
Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);
MessageReference ref = ms.reference(msg);
RouteResult routed = office1.route(ref, new SimpleCondition("myqueue1"), null);
assertTrue(routed.getResult());
//Messages are sent asych so may take some finite time to arrive
Thread.sleep(3000);
//Only queue0 should get the message
checkGetsMessage(queue0, receiver0, msg);
checkNotGetsMessage(queue1, receiver1);
checkNotGetsMessage(queue2, receiver2);
checkNotGetsMessage(queue3, receiver3);
// Route to myqueue1 from office 2
msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);
ref = ms.reference(msg);
routed = office2.route(ref, new SimpleCondition("myqueue1"), null);
assertTrue(routed.getResult());
//Messages are sent asych so may take some finite time to arrive
Thread.sleep(3000);
//Only queue1 should get the message
checkGetsMessage(queue1, receiver1, msg);
checkNotGetsMessage(queue0, receiver0);
checkNotGetsMessage(queue2, receiver2);
checkNotGetsMessage(queue3, receiver3);
//Now route to condition2 from office 1
msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;
ref = ms.reference(msg);
routed = office1.route(ref, new SimpleCondition("myqueue2"), null);
assertTrue(routed.getResult());
//Messages are sent asych so may take some finite time to arrive
Thread.sleep(3000);
// Only queue2 should get the message
checkGetsMessage(queue2, receiver2, msg);
checkNotGetsMessage(queue1, receiver1);
checkNotGetsMessage(queue0, receiver0);
checkNotGetsMessage(queue3, receiver3);
//Now route to condition2 from office 2
msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;
ref = ms.reference(msg);
routed = office2.route(ref, new SimpleCondition("myqueue2"), null);
assertTrue(routed.getResult());
//Messages are sent asych so may take some finite time to arrive
Thread.sleep(3000);
// Only queue3 should get the message
checkGetsMessage(queue3, receiver3, msg);