@Test public void testExecuteShellCommand() throws Exception { when(mockExecCommand.getRunInShell()).thenReturn(true); when(mockExecCommand.toCommandString()).thenReturn("some-command.sh"); when(mockRemoteExecCommand.getCommand()).thenReturn(mockExecCommand); when(mockJschService.runShellCommand(any(RemoteSystemConnection.class), eq("some-command.sh"), anyLong())) .thenReturn(new RemoteCommandReturnInfo(0, "EXIT_CODE=0*** ", null)); final RemoteCommandReturnInfo remoteCommandReturnInfo = jschRemoteCommandExecutorService .executeCommand(mockRemoteExecCommand); assertEquals(0, remoteCommandReturnInfo.retCode); }
@Override public RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand) { if (remoteExecCommand.getCommand().getRunInShell()) { final int shellReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_SHELL_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runShellCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), shellReadRemoteOutputTimeout); } final int execReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_EXEC_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runExecCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), execReadRemoteOutputTimeout); }
JschRemoteCommandExecutorServiceImpl implements RemoteCommandExecutorService { @Override public RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand) { if (remoteExecCommand.getCommand().getRunInShell()) { final int shellReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_SHELL_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runShellCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), shellReadRemoteOutputTimeout); } final int execReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_EXEC_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runExecCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), execReadRemoteOutputTimeout); } }
JschRemoteCommandExecutorServiceImpl implements RemoteCommandExecutorService { @Override public RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand) { if (remoteExecCommand.getCommand().getRunInShell()) { final int shellReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_SHELL_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runShellCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), shellReadRemoteOutputTimeout); } final int execReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_EXEC_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runExecCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), execReadRemoteOutputTimeout); } @Autowired  JschRemoteCommandExecutorServiceImpl(final JschService jschService); }
JschRemoteCommandExecutorServiceImpl implements RemoteCommandExecutorService { @Override public RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand) { if (remoteExecCommand.getCommand().getRunInShell()) { final int shellReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_SHELL_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runShellCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), shellReadRemoteOutputTimeout); } final int execReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_EXEC_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runExecCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), execReadRemoteOutputTimeout); } @Autowired  JschRemoteCommandExecutorServiceImpl(final JschService jschService); @Override RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand); }
JschRemoteCommandExecutorServiceImpl implements RemoteCommandExecutorService { @Override public RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand) { if (remoteExecCommand.getCommand().getRunInShell()) { final int shellReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_SHELL_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runShellCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), shellReadRemoteOutputTimeout); } final int execReadRemoteOutputTimeout = Integer.parseInt(ApplicationProperties.get(JSCH_EXEC_READ_REMOTE_OUTPUT_TIMEOUT.getPropertyName(), DEFAULT_READ_REMOTE_OUTPUT_TIMEOUT)); return jschService.runExecCommand(remoteExecCommand.getRemoteSystemConnection(), remoteExecCommand.getCommand().toCommandString(), execReadRemoteOutputTimeout); } @Autowired  JschRemoteCommandExecutorServiceImpl(final JschService jschService); @Override RemoteCommandReturnInfo executeCommand(final RemoteExecCommand remoteExecCommand);  }