LocalTransport transport = new LocalTransport();
Channel channel1 = transport.createChannel("urn:xfire:local://Peer1");
channel1.open();
Channel channel2 = transport.createChannel("urn:xfire:local://Peer2");
JDOMEndpoint endpoint = new JDOMEndpoint();
channel2.setEndpoint(endpoint);
// Document to send
Element root = new Element("root");
root.addContent("hello");
Document doc = new Document(root);
MessageContext context = new MessageContext();
OutMessage msg = new OutMessage("urn:xfire:local://Peer2");
msg.setSerializer(new JDOMSerializer());
msg.setBody(doc);
channel1.send(context, msg);
channel1.send(context, msg);
for (int i = 0; i < 10000; i++)
{
Thread.sleep(50);
if (endpoint.getCount() == 2) break;
}
channel1.close();
channel2.close();
assertEquals(2, endpoint.getCount());
}