}
}
public void testUnbindResume() throws Exception {
bind(true);
IoConnector connector = newConnector();
IoSession session = null;
connector.setHandler(new IoHandlerAdapter());
ConnectFuture future = connector.connect(createSocketAddress(port));
future.awaitUninterruptibly();
session = future.getSession();
assertTrue(session.isConnected());
assertTrue(session.write(IoBuffer.allocate(1)).awaitUninterruptibly().isWritten());
// Wait for the server side session to be created.
Thread.sleep(500);
Collection<IoSession> managedSession = acceptor.getManagedSessions().values();
assertEquals(1, managedSession.size());
acceptor.unbind();
// Wait for the client side sessions to close.
Thread.sleep(500);
assertEquals(0, managedSession.size());
for (IoSession element : managedSession) {
assertFalse(element.isConnected());
}
// Rebind
bind(true);
// Check again the connection
future = connector.connect(createSocketAddress(port));
future.awaitUninterruptibly();
session = future.getSession();
assertTrue(session.isConnected());
assertTrue(session.write(IoBuffer.allocate(1)).awaitUninterruptibly().isWritten());