try
{
final StringBuffer buf = new StringBuffer();
IoConnector connector = createConnector();
ConnectFuture future = connector.connect(
new InetSocketAddress( "localhost", port ),
new IoHandlerAdapter()
{
public void sessionCreated( IoSession session )
{
buf.append( "1" );
}
public void sessionOpened( IoSession session )
{
buf.append( "2" );
}
public void exceptionCaught( IoSession session, Throwable cause )
{
buf.append( "X" );
}
});
future.join();
buf.append("3");
future.getSession().close();
Assert.assertEquals( "123", buf.toString() );
}
finally
{
acceptor.unbind( new InetSocketAddress( port ) );