Package org.zeroturnaround.exec

Examples of org.zeroturnaround.exec.ProcessExecutor


    Assert.assertEquals(0, exit);
  }

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


    Assert.assertFalse(StringUtils.isEmpty(str));
  }

  @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

    Assert.assertEquals(str, executor.execute().outputUTF8());
  }

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

  }

  @Test
  public void testJavaVersionLogInfo() throws Exception {
    // Just expect no errors - don't check the log file itself
    new ProcessExecutor().command("java", "-version").redirectOutput(Slf4jStream.of("testJavaVersionLogInfo").asInfo()).execute();
  }
View Full Code Here

  }

  @Test
  public void testJavaVersionLogInfoAndOutput() throws Exception {
    // Just expect no errors - don't check the log file itself
    ProcessResult result = new ProcessExecutor().command("java", "-version").redirectOutput(Slf4jStream.of("testJavaVersionLogInfoAndOutput").asInfo()).readOutput(true).execute();
    String str = result.outputUTF8();
    Assert.assertFalse(StringUtils.isEmpty(str));
  }
View Full Code Here

  }

  @Test
  public void testJavaVersionLogInfoAndOutputFuture() throws Exception {
    // Just expect no errors - don't check the log file itself
    ProcessResult result = new ProcessExecutor().command("java", "-version").redirectOutput(Slf4jStream.of("testJavaVersionLogInfoAndOutputFuture").asInfo()).readOutput(true).start().getFuture().get();
    String str = result.outputUTF8();
    Assert.assertFalse(StringUtils.isEmpty(str));
  }
View Full Code Here

  }

  @Test
  public void testJavaVersionNoStreams() throws Exception {
    // Just expect no errors
    new ProcessExecutor().command("java", "-version").streams(null).execute();
  }
View Full Code Here

  }

  @Test
  public void testProcessDestroyerEvents() throws Exception {
    MockProcessDestroyer mock = new MockProcessDestroyer();
    new ProcessExecutor().command("java", "-version").destroyer(mock).execute();
    Assert.assertNotNull(mock.added);
    Assert.assertEquals(mock.added, mock.removed);
  }
View Full Code Here

  @Test
  public void testProcessDestroyerEventsOnStreamsFail() throws Exception {
    MockProcessDestroyer mock = new MockProcessDestroyer();
    ExecuteStreamHandler streams = new SetFailExecuteStreamHandler();
    try {
      new ProcessExecutor().command("java", "-version").streams(streams).destroyer(mock).execute();
      Assert.fail("IOException expected");
    }
    catch (IOException e) {
      // Good
    }
View Full Code Here

        add("-cp");
        add("target/test-classes");
        add(HelloWorld.class.getName());
      }
    };
    ProcessExecutor exec = new ProcessExecutor(args);
    ProcessResult result = exec.readOutput(true).execute();
    Assert.assertEquals("Hello world!", result.outputUTF8());
  }
View Full Code Here

TOP

Related Classes of org.zeroturnaround.exec.ProcessExecutor

Copyright © 2018 www.massapicom. 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.