final TranscriptExceptionTracer exceptions = TranscriptExceptionTracer.create (transcript, exceptionsQueue);
final BasicThreadingContext threading = BasicThreadingContext.create (this, exceptions, exceptions.catcher);
Assert.assertTrue (threading.initialize (ZeroMqChannelTest.defaultPollTimeout));
final String serverIdentifier = UUID.randomUUID ().toString ();
final String clientIdentifier = UUID.randomUUID ().toString ();
final ZeroMqChannelSocket server = ZeroMqChannelSocket.create (serverIdentifier, null, threading, exceptions);
final ZeroMqChannelSocket client = ZeroMqChannelSocket.create (clientIdentifier, null, threading, exceptions);
server.accept (ZeroMqChannelTest.defaultServerEndpoint);
client.connect (ZeroMqChannelTest.defaultServerEndpoint);
for (int index = 0; index < ZeroMqChannelTest.defaultTries; index++) {
final ByteBuffer header = ByteBuffer.wrap (UUID.randomUUID ().toString ().getBytes ());
final ByteBuffer payload = ByteBuffer.wrap (UUID.randomUUID ().toString ().getBytes ());
final ZeroMqChannelPacket packet1 = ZeroMqChannelPacket.create (serverIdentifier, header, payload);
client.enqueue (packet1, ZeroMqChannelTest.defaultPollTimeout);
final ZeroMqChannelPacket packet2 = server.dequeue (ZeroMqChannelTest.defaultPollTimeout);
Assert.assertNotNull (packet2);
server.enqueue (packet2, ZeroMqChannelTest.defaultPollTimeout);
final ZeroMqChannelPacket packet3 = client.dequeue (ZeroMqChannelTest.defaultPollTimeout);
Assert.assertNotNull (packet3);
packet1.header.flip ();
packet1.payload.flip ();
Assert.assertEquals (packet1.header, packet3.header);
Assert.assertEquals (packet1.payload, packet3.payload);
}
Assert.assertTrue (server.terminate (ZeroMqChannelTest.defaultPollTimeout));
Assert.assertTrue (client.terminate (ZeroMqChannelTest.defaultPollTimeout));
Assert.assertTrue (threading.destroy (ZeroMqChannelTest.defaultPollTimeout));
Assert.assertNull (exceptionsQueue.queue.poll ());
}