@Test public void testInitialize() throws IOException { ServerSocketChannel serverSocketChannel = null; try { serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.socket().bind(new InetSocketAddress(0)); serverSocketChannel.configureBlocking(false); handler = new ClientTcpTransportHandler(100, "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) { } } } }
@Override public void initialize() throws IOException { socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout); if (!socket.isConnected()) { throw new IOException("Could not connect to " + hostname + ":" + "port"); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); socket.setSoTimeout(1); }
ClientTcpTransportHandler extends TransportHandler { @Override public void initialize() throws IOException { socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout); if (!socket.isConnected()) { throw new IOException("Could not connect to " + hostname + ":" + "port"); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); socket.setSoTimeout(1); } }
ClientTcpTransportHandler extends TransportHandler { @Override public void initialize() throws IOException { socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout); if (!socket.isConnected()) { throw new IOException("Could not connect to " + hostname + ":" + "port"); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); socket.setSoTimeout(1); } ClientTcpTransportHandler(Connection connection);  ClientTcpTransportHandler(long timeout, String hostname, int port);  ClientTcpTransportHandler(long connectionTimeout, long timeout, String hostname, int port); }
ClientTcpTransportHandler extends TransportHandler { @Override public void initialize() throws IOException { socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout); if (!socket.isConnected()) { throw new IOException("Could not connect to " + hostname + ":" + "port"); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); socket.setSoTimeout(1); } ClientTcpTransportHandler(Connection connection);  ClientTcpTransportHandler(long timeout, String hostname, int port);  ClientTcpTransportHandler(long connectionTimeout, long timeout, String hostname, int port); @Override void closeConnection(); @Override void initialize(); @Override boolean isClosed(); @Override void closeClientConnection(); SocketState getSocketState(); }
ClientTcpTransportHandler extends TransportHandler { @Override public void initialize() throws IOException { socket = new Socket(); socket.connect(new InetSocketAddress(hostname, port), (int) connectionTimeout); if (!socket.isConnected()) { throw new IOException("Could not connect to " + hostname + ":" + "port"); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); socket.setSoTimeout(1); } ClientTcpTransportHandler(Connection connection);  ClientTcpTransportHandler(long timeout, String hostname, int port);  ClientTcpTransportHandler(long connectionTimeout, long timeout, String hostname, int port); @Override void closeConnection(); @Override void initialize(); @Override boolean isClosed(); @Override void closeClientConnection(); SocketState getSocketState();  }