@Test
public void testZmqDealer() throws Exception {
final ZMQ.Context context = ZMQ.context(1);
final ZMQ.Socket socket = context.socket(ZMQ.DEALER);
socket.connect("tcp://" + serverAddress.getHostName() + ":" + serverAddress.getPort());
final ZMsg request = ZMsg.newStringMsg("envelope", "", "hello", "world");
request.send(socket, false);
final ZMTPIncomingMessage receivedRequest = incomingMessages.take();
final ZMTPMessage receivedMessage = receivedRequest.getMessage();
receivedRequest.getSession().getChannel().write(receivedMessage);
final ZMsg reply = ZMsg.recvMsg(socket);
Iterator<ZFrame> reqIter = request.iterator();
Iterator<ZFrame> replyIter = reply.iterator();
while (reqIter.hasNext()) {
assertTrue(replyIter.hasNext());
assertArrayEquals(reqIter.next().getData(), replyIter.next().getData());
}
assertFalse(replyIter.hasNext());