MockHandler connectorHandler = new MockHandler();
acceptor.bind(new InetSocketAddress(port), acceptorHandler, config);
try {
ConnectFuture future = connector.connect(new InetSocketAddress(
"localhost", port), connectorHandler, config);
future.join();
// Write whatever to trigger the acceptor.
future.getSession().write(ByteBuffer.allocate(1)).join();
// Wait until the connection is closed.
future.getSession().getCloseFuture().join(3000);
Assert.assertTrue(future.getSession().getCloseFuture().isClosed());
acceptorHandler.session.getCloseFuture().join(3000);
Assert.assertTrue(acceptorHandler.session.getCloseFuture()
.isClosed());
Thread.sleep(1000);