ClientTcpNoDelayTransportHandler extends ClientTcpTransportHandler { @Override public void initialize() throws IOException { socket = new Socket(hostname, port); socket.setTcpNoDelay(true); setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); } ClientTcpNoDelayTransportHandler(long timeout, String hostname, int port); @Override void initialize();  }
@Test public void testInitialize() throws IOException { ServerSocketChannel serverSocketChannel = null; try { serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.socket().bind(new InetSocketAddress(0)); serverSocketChannel.configureBlocking(false); handler = new ClientTcpNoDelayTransportHandler(0, "localhost", serverSocketChannel.socket().getLocalPort()); handler.initialize(); SocketChannel acceptChannel = serverSocketChannel.accept(); assertNotNull(acceptChannel); assertTrue(handler.isInitialized()); } finally { if (serverSocketChannel != null) { try { serverSocketChannel.close(); } catch (IOException ex) { LOGGER.warn(ex); } } } }