ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
PrintInputToOutput.class.getName());
exec.redirectInput(bais).redirectOutput(baos);
exec.execute();
Assert.assertEquals(str, baos.toString());
}
}