Examples of OverthereProcess


Examples of com.xebialabs.overthere.OverthereProcess

        return execute(sysoutHandler(), syserrHandler(), commandLine);
    }

    @Override
    public int execute(final OverthereExecutionOutputHandler stdoutHandler, final OverthereExecutionOutputHandler stderrHandler, final CmdLine commandLine) {
        final OverthereProcess process = startProcess(commandLine);
        Thread stdoutReaderThread = null;
        Thread stderrReaderThread = null;
        final CountDownLatch latch = new CountDownLatch(2);
        try {
            stdoutReaderThread = getThread("stdout", commandLine.toString(), stdoutHandler, process.getStdout(), latch);
            stdoutReaderThread.start();

            stderrReaderThread = getThread("stderr", commandLine.toString(), stderrHandler, process.getStderr(), latch);
            stderrReaderThread.start();

            try {
                latch.await();
                return process.waitFor();
            } catch (InterruptedException exc) {
                Thread.currentThread().interrupt();

                logger.info("Execution interrupted, destroying the process.");
                process.destroy();

                throw new RuntimeIOException("Execution interrupted", exc);
            }
        } finally {
            quietlyJoinThread(stdoutReaderThread);
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

                }
            };
            outputReaderThread.setDaemon(true);
            outputReaderThread.start();

            return new OverthereProcess() {
                boolean processTerminated = false;

                @Override
                public synchronized OutputStream getStdin() {
                    return callersStdin;
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

                }
            };
            outputReaderThread.setDaemon(true);
            outputReaderThread.start();

            return new OverthereProcess() {
                @Override
                public synchronized OutputStream getStdin() {
                    return stdin;
                }
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

    }

    @Test
    @Assumption(methods = "onUnix")
    public void shouldStartProcessSimpleCommandOnUnix() throws IOException, InterruptedException {
        OverthereProcess p = connection.startProcess(CmdLine.build("ls", "-ld", "/tmp/."));
        try {
            String commandOutput = CharStreams.toString(new InputStreamReader(p.getStdout()));
            assertThat(p.waitFor(), equalTo(0));
            assertThat(commandOutput, containsString("drwxrwxrwt"));
        } finally {
            p.destroy();
        }
    }
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

    }

    @Test
    @Assumption(methods = {"onWindows", "supportsProcess"})
    public void shouldStartProcessSimpleCommandOnWindows() throws IOException, InterruptedException {
        OverthereProcess p = connection.startProcess(CmdLine.build("ipconfig"));
        try {
            String commandOutput = CharStreams.toString(new InputStreamReader(p.getStdout()));
            assertThat(p.waitFor(), equalTo(0));
            assertThat(commandOutput, not(containsString("ipconfig")));
            assertThat(commandOutput, containsString("Windows IP Configuration"));
        } finally {
            p.waitFor();
        }
    }
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

        OverthereFile scriptToRun = connection.getTempFile("echo.ps1");
        writeData(scriptToRun, ("Write-Host \"Enter your name the prompt\"\n" +
                "$name = [Console]::In.ReadLine()\n" +
                "Write-Host \"Hi $name\"").getBytes("UTF-8"));

        OverthereProcess process = connection.startProcess(CmdLine.build("powershell.exe", "-ExecutionPolicy", "Unrestricted", "-File", scriptToRun.getPath()));
        try {
            OutputStream stdin = process.getStdin();
            BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getStdout()));

            waitForPrompt(stdout, "name");

            String reply = "Vincent";
            enterPrompt(stdin, reply);

            String hi = waitForPrompt(stdout, "Hi");
            assertThat(hi, containsString("Vincent"));
        } finally {
            process.waitFor();
        }
    }
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);

    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      OverthereProcess process = connection.startProcess(CmdLine.build("cat", "/etc/motd"));
      BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getStdout()));
      try {
        String line;
        while((line = stdout.readLine()) != null) {
          System.err.println(line);
        }
      } finally {
        stdout.close();
      }
      int exitCode = process.waitFor();
      System.err.println("Exit code: " + exitCode);
    } finally {
      connection.close();
    }
  }
View Full Code Here

Examples of com.xebialabs.overthere.OverthereProcess

  public int runAndWaitCommand(String... command) throws IOException {
    return connection.execute(CmdLine.build(command));
  }

  public String execAndWaitCommand(String... command) throws IOException {
    OverthereProcess process = connection.startProcess(CmdLine
        .build(command));
    return CharStreams.toString(new InputStreamReader(process.getStdout(),
        "UTF-8"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.