OortComet oortComet23 = oort2.findComet(oort3.getURL());
Assert.assertTrue(oortComet23.waitFor(5000, BayeuxClient.State.CONNECTED));
OortComet oortComet32 = oort3.findComet(oort2.getURL());
Assert.assertTrue(oortComet32.waitFor(5000, BayeuxClient.State.CONNECTED));
BayeuxClient client1 = startClient(oort1, null);
Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
BayeuxClient client2 = startClient(oort2, null);
Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.CONNECTED));
BayeuxClient client3 = startClient(oort3, null);
Assert.assertTrue(client3.waitFor(5000, BayeuxClient.State.CONNECTED));
// Oort1 observes the channel, so any publish to Oort2 or Oort3 is forwarded to Oort1
String channelName = "/oort_test";
oort1.observeChannel(channelName);
// Wait a while to be sure to be subscribed
Thread.sleep(1000);
// Subscribe client1
LatchListener subscribeLatch1 = new LatchListener();
client1.getChannel(Channel.META_SUBSCRIBE).addListener(subscribeLatch1);
LatchListener messageLatch1 = new LatchListener(1);
client1.getChannel(channelName).subscribe(messageLatch1);
Assert.assertTrue(subscribeLatch1.await(5, TimeUnit.SECONDS));
// Subscribe client3
LatchListener subscribeLatch3 = new LatchListener();
client3.getChannel(Channel.META_SUBSCRIBE).addListener(subscribeLatch3);
LatchListener messageLatch3 = new LatchListener(1);
client3.getChannel(channelName).subscribe(messageLatch3);
Assert.assertTrue(subscribeLatch3.await(5, TimeUnit.SECONDS));
// Sending a message to Oort2, must be received by client1 but not by client3
client2.getChannel(channelName).publish(new HashMapMessage());
Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));
Assert.assertFalse(messageLatch3.await(1, TimeUnit.SECONDS));
// Sending a message to Oort3, must be received by client1 and by client3
messageLatch1.reset(1);
client3.getChannel(channelName).publish(new HashMapMessage());
Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));
Assert.assertTrue(messageLatch3.await(5, TimeUnit.SECONDS));
}