Connection { public boolean isConnected() { return socket != null && socket.isBound() && !socket.isClosed() && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown(); } Connection();  Connection(final String host);  Connection(final String host, final int port);  Connection(final String host, final int port, final int timeout, final int socketTimeout); int getTimeout(); int getSocketTimeout(); String getHost(); int getPort(); boolean isConnected(); void open(); void close(); RedisStreamWriter getStreamWriter(); RedisStreamReader getStreamReader(); final static int DEFAULT_TIMEOUT; final static int DEFAULT_SOCKET_TIMEOUT; static final String DEFAULT_HOST; static final int DEFAULT_PORT; }
@Test public void isConnectedReturnsFalse() throws ConnectionException, IOException { doReturn(false).when(socket).isBound(); assertFalse(connection.isConnected()); }
@Test public void isConnectedReturnsTrue() throws ConnectionException, IOException { doReturn(false).when(socket).isBound(); doReturn(false).when(socket).isClosed(); doReturn(true).when(socket).isConnected(); doReturn(false).when(socket).isInputShutdown(); doReturn(false).when(socket).isOutputShutdown(); assertFalse(connection.isConnected()); }