SubprocessBuilder { public Builder forCommand(String command) { return new Builder(command, builder); } SubprocessBuilder();  SubprocessBuilder(ProcessBuilderWrapper builder); Builder forCommand(String command);  }
@Test(groups = "fast") public void testStart() { io.subprocess.forCommand("foo").start(); assertCommand("foo"); }
@Test(groups = "fast") public void testStream() { io.subprocess.forCommand("foo").stream(); assertCommand("foo"); }
@Test(groups = "fast") public void testArguments() { io.subprocess .forCommand("foo") .withArguments("bar") .withArguments("this", "is", "a test") .withArguments(123) .withArguments(Arrays.asList(456, "abc")) .start(); assertCommand("foo", "bar", "this", "is", "a test", "123", "456", "abc"); }
@Test(groups = "fast") public void testRedirectStdOutToStdErr() { io.subprocess.forCommand("foo").redirectStderrToStdout().start(); assertCommand(RedirectErrorsTo.STDOUT, Collections.emptyMap(), null, "foo"); }
@Test(groups = "fast") public void testEnvironmentVariables() { io.subprocess .forCommand("foo") .withEnvironmentVariable("bar", "baz") .withoutEnvironmentVariable("bad") .start(); Map<String, String> expected = new LinkedHashMap<>(); expected.put("bar", "baz"); expected.put("bad", null); assertCommand(RedirectErrorsTo.STDERR, expected, null, "foo"); }
@Test(groups = "fast") public void testWorkingDirectory() { io.subprocess.forCommand("foo").withWorkingDirectory(new File("/tmp/test")).start(); assertCommand(RedirectErrorsTo.STDERR, Collections.emptyMap(), new File("/tmp/test"), "foo"); }
@Test(groups = "fast") public void testEchoCommand() { io.subprocess.forCommand("foo").withArguments("bar", "baz").echoCommand(io).start().waitFor(); assertCommand("foo", "bar", "baz"); Assert.assertEquals(io.getOut(), "foo bar baz\n"); Assert.assertEquals(io.getErr(), ""); }
@Test(groups = "fast") public void testEchoOutput() { io.subprocess.forCommand("foo").echoOutput(io).start().waitFor(); assertCommand("foo"); Assert.assertEquals(io.getOut(), "out: this is a test of stdout\n"); Assert.assertEquals(io.getErr(), "err: this is a test of stderr\n"); }
@Test(groups = "fast") public void testOutputBytesLimit() { Subprocess foo = io.subprocess.forCommand("foo").echoOutput(io).outputBytesLimit(19).start(); assertCommand("foo"); Assert.assertEquals(foo.getOutput(), "out: this is a test"); Assert.assertEquals(foo.getError(), "err: this is a test"); }