@Test
public void testPublishDuringCometJoined() throws Exception
{
Server serverA = startServer(0);
final Oort oortA = startOort(serverA);
final BayeuxServer bayeuxServerA = oortA.getBayeuxServer();
final LocalSession serviceA = bayeuxServerA.newLocalSession("test");
serviceA.handshake();
final String channelName = "/test";
final String data = "data";
final CountDownLatch joinedLatch = new CountDownLatch(1);
oortA.addCometListener(new Oort.CometListener.Adapter()
{
public void cometJoined(Event event)
{
bayeuxServerA.createChannelIfAbsent(channelName).getReference().publish(serviceA, data);
joinedLatch.countDown();
}
});
oortA.observeChannel(channelName);
Server serverB = startServer(0);
Oort oortB = startOort(serverB);
oortB.observeChannel(channelName);
BayeuxServer bayeuxServerB = oortB.getBayeuxServer();
final CountDownLatch latch = new CountDownLatch(1);
bayeuxServerB.createChannelIfAbsent(channelName).getReference().addListener(new ServerChannel.MessageListener()
{
public boolean onMessage(ServerSession from, ServerChannel channel, ServerMessage.Mutable message)
{
if (data.equals(message.getData()))
latch.countDown();