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; }
@Test public void testGetCommandsFromScript() throws Exception { assertEquals(new SshjClient(null, null, null) .getCommandsFromScript("classpath:ssh-client/classpath-test-ssh.txt"), Arrays.asList("ping -c google.com", "echo hello")); }
@Test(expectedExceptions = {NullPointerException.class}) public void testGetCommandsFromScriptWithIncorrectFilePath() throws Exception { new SshjClient(null, null, null).getCommandsFromScript("classpath:ssh-client/incorrect-classpath-test-ssh.txt"); }