*/
public void testForkedError() throws Throwable {
String src = "<AWTTestScript>"
+ "<launch class=\"nonsense class\" method=\"main\" args=\"[]\"/>"
+ "</AWTTestScript>";
ForkedStepRunner fs = new ForkedStepRunner();
Script script = loadScript(src);
try {
fs.run(script);
fail("No error propagated");
}
catch(ForkedError fe) {
assertEquals("Error not set in runner",
fe, fs.getError(script));
String expected = "java.lang.ClassNotFoundException";
assertTrue("Wrong error: " + fe,
fe.toString().startsWith(expected));
StringWriter s = new StringWriter();
fe.printStackTrace(new PrintWriter(s));
String trace = s.toString();
assertTrue("Error is missing stack trace: " + trace,
trace.indexOf("at ") != -1);
}
catch(Throwable thr) {
fail("Wrong error: " + thr);
}
finally {
fs.terminate();
}
}