use of com.sun.tck.lib.TestFailedException in project jtharness by openjdk.
the class DefaultExecutionResult method process.
/**
* {@inheritDoc}
*/
@Override
public void process(TestCaseContext.TestCaseLifePhase lifePhase, TestCaseContext context) {
TestResult result;
Throwable t = AUTD2Utils.unwrapCoreExceptionFromITEs(context);
if (t == null) {
Object testCaseReturnedResult = context.getTestCaseResult().getResult();
if (testCaseReturnedResult != null) {
// setting tight policy for what a testcase method can return by default
// to catch mistakes since a non-void return value is not processed
// anyhow by this processor and would be basically lost
// even if the returned result reflects a failure.
String nonVoidResult = format("Testcase \"{0}\" returned unrecognized value {1}" + ", but it is expected to return void", context.getTestCaseName(), testCaseReturnedResult);
result = TestResult.failure(nonVoidResult);
} else {
result = OK_RESULT;
}
} else {
if (t instanceof ClassCastException || t instanceof IllegalArgumentException) {
// todo share this with exp exceptions processor
result = TestResult.failure(unmatchedArgsExceptionThrown(t.getClass().getSimpleName(), context, t, context.getTestCaseMethod(), context.getTestCaseInvocationArgValues()));
} else if (t instanceof SomethingIsWrong) {
// todo share this with exp exceptions processor
context.printlnToLog(t.getMessage());
result = TestResult.failure(t.getMessage());
} else if (t instanceof NotApplicableException) {
// todo share this with exp exceptions processor
String message = t.getMessage();
context.recordNotApplicable();
result = new InapplicableTestResult("Not applicable." + (message != null ? " Reason: " + message : ""), message);
} else if (t instanceof TestFailedException) {
testFailed(context.getTestCaseNameWithIndex(), t, context);
result = TestResult.failure(t.getMessage());
} else {
String unexpectedThrown = format("Testcase \"{0}\" has thrown an unexpected exception {1}", context.getTestCaseNameWithIndex(), t);
context.getParentContext().printlnToLog(unexpectedThrown);
context.getParentContext().printStackTraceToLog(t);
result = TestResult.failure(unexpectedThrown);
}
}
context.addExecutionResult(context.getTestCaseName(), result);
context.clearTestCaseResult();
}
Aggregations