NioSocketAcceptor acceptor = new NioSocketAcceptor();
acceptor.setReuseAddress(true);
SocketAddress address = new InetSocketAddress("localhost",
AvailablePortFinder.getNextAvailable());
NioSocketConnector connector = new NioSocketConnector();
// Generate 4MB of random data
byte[] data = new byte[4 * 1024 * 1024];
new Random().nextBytes(data);
byte[] expectedMd5 = MessageDigest.getInstance("MD5").digest(data);
M message = createMessage(data);
SenderHandler sender = new SenderHandler(message);
ReceiverHandler receiver = new ReceiverHandler(data.length);
acceptor.setHandler(sender);
connector.setHandler(receiver);
acceptor.bind(address);
connector.connect(address);
sender.latch.await();
receiver.latch.await();
acceptor.dispose();