Search in sources :

Example 1 with After

use of com.sun.tck.lib.tgf.After in project jtharness by openjdk.

the class AfterTestCaseActions method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(TestCaseContext.TestCaseLifePhase lifePhase, final TestCaseContext context) {
    Annotation tcAnnotation = getTheOnlyAnnotationInterestedIn(context);
    Annotation tgAnnotation = getTheOnlyTestGroupAnnotationInterestedIn(context);
    if (tcAnnotation != null && tgAnnotation != null) {
        throw new IllegalArgumentException("Annotation @After is attached " + "to both testgroup class and a testcase \"" + context.getTestCaseName() + "\". This is not allowed");
    }
    final After after = tcAnnotation != null ? (After) tcAnnotation : (After) tgAnnotation;
    String methodName = after.value();
    try {
        searchAndInvoke(methodName, context.getTestGroupInstance().getClass(), context.getTestGroupInstance(), context.getLog());
    } catch (SomethingIsWrong e) {
        final String message = e.getMessage();
        context.printlnToLog(message);
        final String failedTryingToInvoke = MessageFormat.format("Failed trying to invoke @After method \"{0}\"", methodName);
        context.setTestCaseInvocationArgValues(null);
        context.setOverridingResult(TestResult.failure(failedTryingToInvoke));
    }
}
Also used : SomethingIsWrong(com.sun.tck.lib.tgf.SomethingIsWrong) After(com.sun.tck.lib.tgf.After) Annotation(java.lang.annotation.Annotation)

Aggregations

After (com.sun.tck.lib.tgf.After)1 SomethingIsWrong (com.sun.tck.lib.tgf.SomethingIsWrong)1 Annotation (java.lang.annotation.Annotation)1