Package org.zeroturnaround.exec

Examples of org.zeroturnaround.exec.ProcessExecutor.execute()


    ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
        PrintInputToOutput.class.getName()).readOutput(true);
    exec.streams(handler);

    String result = exec.execute().outputUTF8();
    Assert.assertEquals(str, result);
  }

  @Test
  public void testPumpFromInputToOutputWithInput() throws Exception {
View Full Code Here


    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
        PrintInputToOutput.class.getName()).readOutput(true).redirectInput(bais);

    String result = exec.execute().outputUTF8();
    Assert.assertEquals(str, result);
  }

}
View Full Code Here

  }

  @Test
  public void testJavaVersionOutputTwice() throws Exception {
    ProcessExecutor executor = new ProcessExecutor().command("java", "-version").readOutput(true);
    ProcessResult result = executor.execute();
    String str = result.outputUTF8();
    Assert.assertFalse(StringUtils.isEmpty(str));
    Assert.assertEquals(str, executor.execute().outputUTF8());
  }
View Full Code Here

  public void testJavaVersionOutputTwice() throws Exception {
    ProcessExecutor executor = new ProcessExecutor().command("java", "-version").readOutput(true);
    ProcessResult result = executor.execute();
    String str = result.outputUTF8();
    Assert.assertFalse(StringUtils.isEmpty(str));
    Assert.assertEquals(str, executor.execute().outputUTF8());
  }

  @Test
  public void testJavaVersionOutputFuture() throws Exception {
    ProcessResult result = new ProcessExecutor().command("java", "-version").readOutput(true).start().getFuture().get();
View Full Code Here

    ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
        PrintInputToOutput.class.getName());
    exec.redirectInput(bais).redirectOutput(baos);

    exec.execute();
    Assert.assertEquals(str, baos.toString());
  }
}
View Full Code Here

            ByteArrayOutputStream errStream = new ByteArrayOutputStream();
            ProcessExecutor executor = new ProcessExecutor().command(command)
                                                            .readOutput(true)
                                                            .redirectOutput(outStream)
                                                            .redirectError(errStream);
            ProcessResult result = executor.execute();
            if (result.getExitValue() != 0) {
                LOG.error(result.getOutput().getString());
                throw new RuntimeException(String.format("mongoimport failed with exit code %d: %s", result.getExitValue(),
                                                         result.getOutput().getString()));
            }
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.