Search in sources :

Example 1 with BounceMemberRule

use of com.hazelcast.test.bounce.BounceMemberRule in project hazelcast by hazelcast.

the class AbstractHazelcastClassRunner method withBefores.

// Override withBefores to accommodate spawning the member bouncing thread after @Before's have been executed and before @Test
// when MemberBounceRule is in use
@Override
protected Statement withBefores(FrameworkMethod method, Object target, Statement statement) {
    List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class);
    List<TestRule> testRules = getTestRules(target);
    Statement nextStatement = statement;
    if (!testRules.isEmpty()) {
        for (TestRule rule : testRules) {
            if (rule instanceof BounceMemberRule) {
                nextStatement = ((BounceMemberRule) rule).startBouncing(statement);
            }
        }
    }
    return befores.isEmpty() ? nextStatement : new RunBefores(nextStatement, befores, target);
}
Also used : TestRule(org.junit.rules.TestRule) Statement(org.junit.runners.model.Statement) EmptyStatement(com.hazelcast.util.EmptyStatement) BounceMemberRule(com.hazelcast.test.bounce.BounceMemberRule) RunBefores(org.junit.internal.runners.statements.RunBefores) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 2 with BounceMemberRule

use of com.hazelcast.test.bounce.BounceMemberRule in project hazelcast by hazelcast.

the class AbstractHazelcastClassRunner method withAfters.

@Override
protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) {
    List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class);
    Statement nextStatement = statement;
    List<TestRule> testRules = getTestRules(target);
    if (!testRules.isEmpty()) {
        for (TestRule rule : testRules) {
            if (rule instanceof BounceMemberRule) {
                nextStatement = ((BounceMemberRule) rule).stopBouncing(statement);
            }
        }
    }
    if (THREAD_DUMP_ON_FAILURE) {
        return new ThreadDumpAwareRunAfters(method, nextStatement, afters, target);
    }
    if (afters.isEmpty()) {
        return nextStatement;
    } else {
        return new RunAfters(nextStatement, afters, target);
    }
}
Also used : TestRule(org.junit.rules.TestRule) RunAfters(org.junit.internal.runners.statements.RunAfters) Statement(org.junit.runners.model.Statement) EmptyStatement(com.hazelcast.util.EmptyStatement) BounceMemberRule(com.hazelcast.test.bounce.BounceMemberRule) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Aggregations

BounceMemberRule (com.hazelcast.test.bounce.BounceMemberRule)2 EmptyStatement (com.hazelcast.util.EmptyStatement)2 TestRule (org.junit.rules.TestRule)2 FrameworkMethod (org.junit.runners.model.FrameworkMethod)2 Statement (org.junit.runners.model.Statement)2 RunAfters (org.junit.internal.runners.statements.RunAfters)1 RunBefores (org.junit.internal.runners.statements.RunBefores)1