@Test(expectedExceptions = {NullPointerException.class}) public void testGetCommandsFromScriptWithIncorrectFilePath() throws Exception { new SshjClient(null, null, null).getCommandsFromScript("classpath:ssh-client/incorrect-classpath-test-ssh.txt"); }
List<String> getCommandsFromScript(String pathToFile) throws Exception { checkArgument(!Strings.isNullOrEmpty(pathToFile), "Path to file must NOT be Null or Empty"); Path path = pathToFile.startsWith("classpath") ? Paths.get(getClass().getClassLoader().getResource(pathToFile.split(":")[1]).toURI()) : Paths.get(pathToFile); try (BufferedReader br = Files.newBufferedReader(path)) { return br.lines().collect(Collectors.toList()); } }
SshjClient implements SshClient { List<String> getCommandsFromScript(String pathToFile) throws Exception { checkArgument(!Strings.isNullOrEmpty(pathToFile), "Path to file must NOT be Null or Empty"); Path path = pathToFile.startsWith("classpath") ? Paths.get(getClass().getClassLoader().getResource(pathToFile.split(":")[1]).toURI()) : Paths.get(pathToFile); try (BufferedReader br = Files.newBufferedReader(path)) { return br.lines().collect(Collectors.toList()); } } }
SshjClient implements SshClient { List<String> getCommandsFromScript(String pathToFile) throws Exception { checkArgument(!Strings.isNullOrEmpty(pathToFile), "Path to file must NOT be Null or Empty"); Path path = pathToFile.startsWith("classpath") ? Paths.get(getClass().getClassLoader().getResource(pathToFile.split(":")[1]).toURI()) : Paths.get(pathToFile); try (BufferedReader br = Files.newBufferedReader(path)) { return br.lines().collect(Collectors.toList()); } } SshjClient(SSHClient sshClient, String host, ServerCredentials credentials); private  SshjClient(String host, ServerCredentials credentials); }
SshjClient implements SshClient { List<String> getCommandsFromScript(String pathToFile) throws Exception { checkArgument(!Strings.isNullOrEmpty(pathToFile), "Path to file must NOT be Null or Empty"); Path path = pathToFile.startsWith("classpath") ? Paths.get(getClass().getClassLoader().getResource(pathToFile.split(":")[1]).toURI()) : Paths.get(pathToFile); try (BufferedReader br = Files.newBufferedReader(path)) { return br.lines().collect(Collectors.toList()); } } SshjClient(SSHClient sshClient, String host, ServerCredentials credentials); private  SshjClient(String host, ServerCredentials credentials); @Override SshjClient run(String command); @Override SshClient runScript(String pathToFile); @Override OperationFuture<ShellResponse> execute(); }
SshjClient implements SshClient { List<String> getCommandsFromScript(String pathToFile) throws Exception { checkArgument(!Strings.isNullOrEmpty(pathToFile), "Path to file must NOT be Null or Empty"); Path path = pathToFile.startsWith("classpath") ? Paths.get(getClass().getClassLoader().getResource(pathToFile.split(":")[1]).toURI()) : Paths.get(pathToFile); try (BufferedReader br = Files.newBufferedReader(path)) { return br.lines().collect(Collectors.toList()); } } SshjClient(SSHClient sshClient, String host, ServerCredentials credentials); private  SshjClient(String host, ServerCredentials credentials); @Override SshjClient run(String command); @Override SshClient runScript(String pathToFile); @Override OperationFuture<ShellResponse> execute(); static final int CONNECTION_TIMEOUT; }