ProcessBuilder pb = new ProcessBuilder(scriptPath, "user1", "foo");
pb.redirectErrorStream(true);
process = pb.start();
Piper piper = new Piper(process.getInputStream(), System.out, EXPECTED_OUTPUT, EXPECTED_OUTPUT);
piper.start();
boolean finishedSuccessfully = piper.await(2, TimeUnit.SECONDS);
assertTrue(
"Script should have completed with expected output " + EXPECTED_OUTPUT + ". Check standard output for actual output.",
finishedSuccessfully);