Assert.assertTrue(oortComet12.waitFor(5000, BayeuxClient.State.CONNECTED));
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
OortComet oortComet21 = oort2.findComet(oort1.getURL());
Assert.assertTrue(oortComet21.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));
// Oort1 observes the channel, so any publish to Oort2 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));
// Sending a message to Oort2, must be received by client1
client2.getChannel(channelName).publish(new HashMapMessage());
Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));
// Deobserve the channel
oort1.deobserveChannel(channelName);
// Wait a while to be sure to be unsubscribed
Thread.sleep(1000);
// Resend, the message must not be received
messageLatch1.reset(1);
client2.getChannel(channelName).publish(new HashMapMessage());
Assert.assertFalse(messageLatch1.await(1, TimeUnit.SECONDS));
}