ConnectivityManager { public Socket establishConnection() { Socket connectedSocket = this.connectionEstablishment.establishConnection(this.targetId, config); if (null == connectedSocket) { logger.error("socket for target {} is null", this.targetId); } else if (!connectedSocket.isConnected()) { logger.error("socket for target {} is not connected: {}", this.targetId, connectedSocket); } else { logger.debug("Connection to {} established: {}", this.targetId, connectedSocket); } return connectedSocket; } ConnectivityManager(final String targetId, final ConnectionEstablishment connectionEstablishment,
            ConnectionConfiguration config);  ConnectivityManager(final String targetId, final ConnectionEstablishment connectionEstablishment); Socket establishConnection(); String getTargetId();  }
@Test public void testEstablishConenction() throws Exception { Future<Socket> sourceResult = this.executor.submit(new Callable<Socket>() { @Override public Socket call() throws Exception { return sourceManager.establishConnection(); } }); Future<Socket> targetResult = this.executor.submit(new Callable<Socket>() { @Override public Socket call() throws Exception { return targetManager.establishConnection(); } }); final Socket sourceSocket = sourceResult.get(60, TimeUnit.SECONDS); final Socket targetSocket = targetResult.get(60, TimeUnit.SECONDS); final boolean result = sourceSocket.isConnected() && targetSocket.isConnected(); sourceSocket.close(); targetSocket.close(); assertTrue(result); }