Connection { public void close() throws ConnectionException { if (isConnected()) { try { socket.close(); } catch (IOException ex) { throw new ConnectionException(ex); } } } 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 close() throws ConnectionException, IOException { doReturn(true).when(connection).isConnected(); doNothing().when(socket).close(); doNothing().when(redisOutputStream).flush(); connection.close(); verify(socket).close(); }