/*
* Give mule and the clients time to warm up; we get an intermittent failure,
* see if this helps
*/
Thread.sleep(5000);
final Latch latch = new Latch();
final AtomicReference<Object> data = new AtomicReference<Object>();
bayeuxClient.addListener(new MessageListener()
{
public void deliver(Client fromClient, Client toClient, Message message)
{
if (message.getData() != null)
{
// This simulates what the browser would receive
data.set(message.toString());
latch.release();
}
}
});
bayeuxClient.subscribe("/test1");
MuleClient muleClient = new MuleClient(muleContext);
muleClient.dispatch("vm://in1", "Ross", null);
latch.await(10, TimeUnit.SECONDS);
assertNotNull(data.get());
// parse the result string into java objects. different jvms return it in different order, so we can't do a straight string comparison
ObjectMapper mapper = new ObjectMapper();
Map<?, ?> result = mapper.readValue((String) data.get(), Map.class);