@Test public void tetsClosesClient() throws IOException { SshConfig config = new SshConfig("localhost", "me"); when(client.isConnected()).thenReturn(true); new SshConnection(config, client).close(); verify(client).close(); }
@Override public void close() throws IOException { if (client.isConnected()) { client.close(); } }
SshConnection implements AutoCloseable, CommandExecutor { @Override public void close() throws IOException { if (client.isConnected()) { client.close(); } } }
SshConnection implements AutoCloseable, CommandExecutor { @Override public void close() throws IOException { if (client.isConnected()) { client.close(); } } SshConnection(SshConfig config, SSHClient client); }
SshConnection implements AutoCloseable, CommandExecutor { @Override public void close() throws IOException { if (client.isConnected()) { client.close(); } } SshConnection(SshConfig config, SSHClient client); SshConfig getConfig(); InteractiveSession startShell(); @Override void close(); @Override ExecutionResult tryExecute(Path workingDirectory, String... cmd); ExecutionResult executeIn(String workingDirectory, String... cmd); ExecutionResult tryExecuteIn(String workingDirectory, String... cmd); void uploadFile(Path localFile, String targetPath); void writeTextFile(String targetPath, String contents); String readTextFile(String remotePath); void downloadFile(String remotePath, Path localPath); }
SshConnection implements AutoCloseable, CommandExecutor { @Override public void close() throws IOException { if (client.isConnected()) { client.close(); } } SshConnection(SshConfig config, SSHClient client); SshConfig getConfig(); InteractiveSession startShell(); @Override void close(); @Override ExecutionResult tryExecute(Path workingDirectory, String... cmd); ExecutionResult executeIn(String workingDirectory, String... cmd); ExecutionResult tryExecuteIn(String workingDirectory, String... cmd); void uploadFile(Path localFile, String targetPath); void writeTextFile(String targetPath, String contents); String readTextFile(String remotePath); void downloadFile(String remotePath, Path localPath);  }