ServerTcpTransportHandler extends TransportHandler { @Override public void initialize() throws IOException { if (!externalServerSocket) { if (serverSocket == null || serverSocket.isClosed()) { serverSocket = new ServerSocket(port); } socket = serverSocket.accept(); socket.setSoTimeout(1); } setStreams(new PushbackInputStream(socket.getInputStream()), socket.getOutputStream()); } ServerTcpTransportHandler(long timeout, int port);  ServerTcpTransportHandler(long timeout, ServerSocket serverSocket);  ServerTcpTransportHandler(long timeout, Socket socket); void closeServerSocket(); @Override void closeConnection(); @Override void initialize(); @Override boolean isClosed(); ServerSocket getServerSocket(); @Override void closeClientConnection(); int getPort();  }
@Test public void testInitialize() throws Exception { SocketOpenerCallable callable = new SocketOpenerCallable("localhost", handler.getPort()); Thread t = new Thread(new FutureTask(callable)); t.start(); handler.initialize(); assertTrue(handler.isInitialized()); }