}
@Test
public void testMultipleURLMappings() throws Exception
{
BayeuxClient client1 = newBayeuxClient(servletPath1);
client1.handshake();
Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
BayeuxClient client2 = newBayeuxClient(servletPath2);
client2.handshake();
Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.CONNECTED));
String channelName = "/foobarbaz";
final CountDownLatch messageLatch = new CountDownLatch(4);
final CountDownLatch subscribeLatch = new CountDownLatch(2);
client1.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
{
@Override
public void onMessage(ClientSessionChannel channel, Message message)
{
messageLatch.countDown();
}
}, new ClientSessionChannel.MessageListener()
{
@Override
public void onMessage(ClientSessionChannel channel, Message message)
{
subscribeLatch.countDown();
}
});
client2.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
{
@Override
public void onMessage(ClientSessionChannel channel, Message message)
{
messageLatch.countDown();
}
}, new ClientSessionChannel.MessageListener()
{
@Override
public void onMessage(ClientSessionChannel channel, Message message)
{
subscribeLatch.countDown();
}
});
Assert.assertTrue(subscribeLatch.await(5, TimeUnit.SECONDS));
client1.getChannel(channelName).publish("1");
client2.getChannel(channelName).publish("2");
Assert.assertTrue(messageLatch.await(5, TimeUnit.SECONDS));
client1.disconnect(1000);
client2.disconnect(1000);
}