@Test public void execute() throws Exception { File file = folder.newFile("testing"); Assume.assumeTrue(file.delete()); Map<String, String> config = new HashMap<>(); config.put(JschProcessExecutor.KEY_USER, System.getProperty("user.name")); config.put(JschProcessExecutor.KEY_HOST, "localhost"); config.put(JschProcessExecutor.KEY_PRIVATE_KEY, privateKey.getAbsolutePath()); VariableResolver resolver = VariableResolver.system(); JschProcessExecutor extracted = JschProcessExecutor.extract("testing", config, resolver); try { int exit = extracted.execute( new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, Collections.emptyMap()), Arrays.asList("touch", file.getAbsolutePath()), Collections.emptyMap()); assertThat(exit, is(0)); } catch (IOException e) { System.err.printf("Test is skipped because SSH session was not available%n"); Assume.assumeNoException(e); } assertThat(file.exists(), is(true)); }
@Override public int execute( ExecutionContext context, List<String> commandLineTokens, Map<String, String> environmentVariables, Map<String, Blob> extensions, OutputStream output) throws InterruptedException, IOException { try { return execute0(context, commandLineTokens, environmentVariables, extensions, output); } catch (IOException | JSchException e) { throw new IOException(MessageFormat.format( "Failed to execute command via SSH ({0}@{1}:{2})", user, host, String.valueOf(port)), e); } }
JschProcessExecutor implements ProcessExecutor { @Override public int execute( ExecutionContext context, List<String> commandLineTokens, Map<String, String> environmentVariables, Map<String, Blob> extensions, OutputStream output) throws InterruptedException, IOException { try { return execute0(context, commandLineTokens, environmentVariables, extensions, output); } catch (IOException | JSchException e) { throw new IOException(MessageFormat.format( "Failed to execute command via SSH ({0}@{1}:{2})", user, host, String.valueOf(port)), e); } } }
JschProcessExecutor implements ProcessExecutor { @Override public int execute( ExecutionContext context, List<String> commandLineTokens, Map<String, String> environmentVariables, Map<String, Blob> extensions, OutputStream output) throws InterruptedException, IOException { try { return execute0(context, commandLineTokens, environmentVariables, extensions, output); } catch (IOException | JSchException e) { throw new IOException(MessageFormat.format( "Failed to execute command via SSH ({0}@{1}:{2})", user, host, String.valueOf(port)), e); } } JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull);  JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull,
            String temporaryBlobPrefix); }
JschProcessExecutor implements ProcessExecutor { @Override public int execute( ExecutionContext context, List<String> commandLineTokens, Map<String, String> environmentVariables, Map<String, Blob> extensions, OutputStream output) throws InterruptedException, IOException { try { return execute0(context, commandLineTokens, environmentVariables, extensions, output); } catch (IOException | JSchException e) { throw new IOException(MessageFormat.format( "Failed to execute command via SSH ({0}@{1}:{2})", user, host, String.valueOf(port)), e); } } JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull);  JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull,
            String temporaryBlobPrefix); String getUser(); String getHost(); Integer getPort(); String getPrivateKey(); String getPassPhrase(); String getTemporaryBlobPrefix(); static JschProcessExecutor extract(
            String servicePrefix,
            Map<String, String> configuration,
            VariableResolver variables); @Override int execute(
            ExecutionContext context,
            List<String> commandLineTokens,
            Map<String, String> environmentVariables,
            Map<String, Blob> extensions,
            OutputStream output); }
JschProcessExecutor implements ProcessExecutor { @Override public int execute( ExecutionContext context, List<String> commandLineTokens, Map<String, String> environmentVariables, Map<String, Blob> extensions, OutputStream output) throws InterruptedException, IOException { try { return execute0(context, commandLineTokens, environmentVariables, extensions, output); } catch (IOException | JSchException e) { throw new IOException(MessageFormat.format( "Failed to execute command via SSH ({0}@{1}:{2})", user, host, String.valueOf(port)), e); } } JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull);  JschProcessExecutor(
            String user,
            String host,
            Integer portOrNull,
            String privateKeyPath,
            String passPhraseOrNull,
            String temporaryBlobPrefix); String getUser(); String getHost(); Integer getPort(); String getPrivateKey(); String getPassPhrase(); String getTemporaryBlobPrefix(); static JschProcessExecutor extract(
            String servicePrefix,
            Map<String, String> configuration,
            VariableResolver variables); @Override int execute(
            ExecutionContext context,
            List<String> commandLineTokens,
            Map<String, String> environmentVariables,
            Map<String, Blob> extensions,
            OutputStream output); static final String KEY_USER; static final String KEY_HOST; static final String KEY_PORT; static final String KEY_PRIVATE_KEY; static final String KEY_PASS_PHRASE; static final String KEY_TEMPORARY_BLOB_PREFIX; static final String DEFAULT_TEMPORARY_BLOB_PREFIX; }