### Question:
CachedConnection implements Connection { @Override public ChannelShell getShell() { if (isClosed()) { throw new IllegalStateException("Connection is closed."); } try { final ChannelShell shell = (ChannelShell) session.openChannel("shell"); channels.add(shell); return shell; } catch (final JSchException e) { throw new RuntimeException("Failed to open shell channel.", e); } } CachedConnection(final String username, final String password, final URI serverAddress,
            final ConnectionLibrarian<CachedConnection> librarian);  CachedConnection(final String username, final String salt, final URI privateKeyLocation,
            final URI serverAddress, final ConnectionLibrarian<CachedConnection> librarian); @Override void close(); void closePhysical(); @Override boolean equals(final Object obj); @Override ChannelSftp getSFtp(); @Override ChannelShell getShell(); @Override int hashCode(); @Override boolean isClosed();  }### Answer:
@Test public void testGetShell() throws Exception { prepareUsernamePasswordSession(); final CachedConnection connection = new CachedConnection(USERNAME, PASSWORD, SERVER_ADDRESS, librarian); when(usernamePasswordSession.openChannel("shell")).thenReturn(shell); assertThat(connection.getShell()).isEqualTo(shell); }