org.junit.internal.runners.statements.RunAfters Java Examples

The following examples show how to use org.junit.internal.runners.statements.RunAfters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoWaveITRunner.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected Statement withAfterClasses(final Statement statement) {
  // add test environment tear down
  try {
    final Statement newStatement = super.withAfterClasses(statement);
    final Method tearDownMethod = GeoWaveITRunner.class.getDeclaredMethod("tearDown");
    tearDownMethod.setAccessible(true);
    return new RunAfters(
        newStatement,
        Collections.singletonList(new FrameworkMethod(tearDownMethod)),
        this);
  } catch (NoSuchMethodException | SecurityException e) {
    LOGGER.warn("Unable to find tearDown method", e);
  }
  return super.withAfterClasses(statement);
}
 
Example #2
Source File: WebTauRunner.java    From webtau with Apache License 2.0 5 votes vote down vote up
@Override
protected Statement withAfterClasses(Statement statement) {
    List<FrameworkMethod> afters = wrapInWebTauTestEntry(getTestClass()
            .getAnnotatedMethods(AfterClass.class));
    return afters.isEmpty() ? statement :
            new RunAfters(statement, afters, null);
}
 
Example #3
Source File: ClassRunner.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds any @AfterAll methods to be run after the normal @After annotated methods for the last test method only.
 * <p>
 * {@inheritDoc}
 */
@Override
protected Statement withAfters(final FrameworkMethod method, final Object target, final Statement stmt) {
  ensureInitialized();
  Statement statement = super.withAfters(method, target, stmt); // NOPMD.CloseResource
  if (method.equals(Iterables.getLast(expectedMethods))) {
    final List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(AfterAll.class);
    statement = afters.isEmpty() ? statement : new RunAfters(statement, afters, target);
  }
  return statement;
}
 
Example #4
Source File: GeoWaveITSuiteRunner.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected Statement withAfterClasses(final Statement statement) {
  try {
    final Statement newStatement = super.withAfterClasses(statement);
    final Method tearDownMethod = GeoWaveITSuiteRunner.class.getDeclaredMethod("tearDown");
    tearDownMethod.setAccessible(true);
    return new RunAfters(
        newStatement,
        Collections.singletonList(new FrameworkMethod(tearDownMethod)),
        this);
  } catch (NoSuchMethodException | SecurityException e) {
    LOGGER.warn("Unable to find tearDown method", e);
  }
  return super.withAfterClasses(statement);
}
 
Example #5
Source File: ParameterTest.java    From openCypher with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.junit.runners.BlockJUnit4ClassRunner#withAfters(FrameworkMethod, Object, Statement)
 */
private Statement withAfters( Object target, Statement statement )
{
    List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods( After.class );
    return afters.isEmpty() ? statement : new RunAfters( statement, afters, target );
}
 
Example #6
Source File: RunAftersContiPerfAdapter.java    From components with Apache License 2.0 4 votes vote down vote up
public static RunAftersContiPerfAdapter create(RunAfters runBefores, Statement next)
        throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    List<FrameworkMethod> befores = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "afters");
    Object target = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "target");
    return new RunAftersContiPerfAdapter(next, befores, target);
}
 
Example #7
Source File: RuleContext.java    From spectrum with MIT License 4 votes vote down vote up
private Statement withAfterClasses(final Statement base) {
  List<FrameworkMethod> afters = getAfterClassMethods();

  return afters.isEmpty() ? base : new RunAfters(base, afters, null);
}
 
Example #8
Source File: AbstractPinpointPluginTestSuite.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Override
protected Statement withAfterClasses(Statement statement) {
    List<FrameworkMethod> afters= getTestClass().getAnnotatedMethods(AfterPinpointPluginTest.class);
    return afters.isEmpty() ? statement : new RunAfters(statement, afters, null);
}
 
Example #9
Source File: EndToEndRunner.java    From buck with Apache License 2.0 4 votes vote down vote up
private Statement withAfters(Object target, Statement statement) {
  List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class);
  return afters.isEmpty() ? statement : new RunAfters(statement, afters, target);
}
 
Example #10
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 3 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @AfterClass} methods on this class
 * and superclasses before executing {@code statement}; all AfterClass methods are
 * always executed: exceptions thrown by previous steps are combined, if
 * necessary, with exceptions from AfterClass methods into a
 * {@link org.junit.runners.model.MultipleFailureException}.
 */
protected Statement withAfterClasses(Statement statement) {
    List<FrameworkMethod> afters = getTestClass()
            .getAnnotatedMethods(AfterClass.class);
    return afters.isEmpty() ? statement :
            new RunAfters(statement, afters, null);
}
 
Example #11
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 3 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @After}
 * methods on this class and superclasses before running {@code next}; all
 * After methods are always executed: exceptions thrown by previous steps
 * are combined, if necessary, with exceptions from After methods into a
 * {@link org.junit.runners.model.MultipleFailureException}.
 *
 * @deprecated Will be private soon: use Rules instead
 */
@Deprecated
protected Statement withAfters(FrameworkMethod method, Object target,
        Statement statement) {
    List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(
            After.class);
    return afters.isEmpty() ? statement : new RunAfters(statement, afters,
            target);
}