}
catch(IOException io) {
throw new AssertionFailedError("VM fork failed");
}
try {
ProcessOutputHandler handler = new ProcessOutputHandler(p) {
protected void handleOutput(byte[] buf, int len) {
sb.append(new String(buf, 0, len));
}
protected void handleError(byte[] buf, int len) {
sbe.append(new String(buf, 0, len));
}
};
// FIXME add a timeout
p.waitFor();
assertEquals("Wrong exit value", 0, p.exitValue());
handler.waitFor();
assertEquals("Wrong output from subprocess",
OUTPUT_TEXT + LS, sb.toString());
assertEquals("Wrong error from subprocess",
ERROR_TEXT + LS, sbe.toString());
}