}
// We expect failure. Is this the failure we expected?
String exceptionName = _failure.getException();
FailureStepType expectedStep = _failure.getFailureStep();
// If no specific step or Exception, then any failure is OK
if (exceptionName == null && expectedStep == null) {
return true;
}
// If we're expecting an exception, make sure we got the right one
Exception ex = exception;
if (ex instanceof NestedIOException) {
ex = ((NestedIOException)ex).getException();
}
if (exceptionName != null) {
try {
Class expected = Class.forName(exceptionName);
if (!expected.isAssignableFrom(ex.getClass())) {
String complaint = "Received Exception: '" + ex.getClass().getName()
+ ": " + ex + "' but expected: '" + exceptionName + "'.";
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.print(complaint);
if (_verbose) {
pw.println("Stacktrace for the Exception that was thrown:");
ex.printStackTrace(pw);
}
pw.flush();
System.out.println(sw.toString());
fail(complaint);
}
} catch (ClassNotFoundException cnfex) {
fail("The Exception specified: '" + exceptionName + "' cannot be found in the CLASSPATH");
}
}
// If we're expecting to fail at a specific step, make sure this is that step
if (expectedStep != null && !expectedStep.equals(checkStep)) {
fail("We expected to fail at test step '" + expectedStep.toString()
+ "' but actually failed at step '" + checkStep.toString() + "'");
}
// We got the expected failure! Return true.
return true;