use of org.junit.runners.model.Statement in project sling by apache.
the class Service method apply.
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final BundleContext bundleContext = Activator.getBundleContext();
if (bundleContext == null) {
// No bundle context usually means we're running client-side
// in a test that uses ServerSideTestRule. In this case, this
// rule does nothing.
base.evaluate();
return;
}
serviceGetter = ServiceGetter.create(bundleContext, serviceClass, null);
try {
base.evaluate();
} finally {
serviceGetter.close();
}
}
};
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class ApplicationComposer method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new DeployApplication(target, base, delegate);
}
});
return rules;
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class ApplicationRule method apply.
@Override
public Statement apply(final Statement statement, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final Thread thread = Thread.currentThread();
final ClassLoader old = thread.getContextClassLoader();
final ApplicationComposers composers = new ApplicationOnlyApplicationComposers(instance);
composers.deployApp(instance);
try {
statement.evaluate();
} finally {
composers.stopApplication();
thread.setContextClassLoader(old);
}
}
};
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class TomEEEmbeddedSingleRunner method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
start(test);
getRunner().composerInject(target);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class LocalClientRunner method methodBlock.
@Override
protected Statement methodBlock(final FrameworkMethod method) {
final Object instance = newTestInstance();
final Test test = new Test(clazz, method.getMethod(), instance, deployment);
Statement statement = methodInvoker(method, instance);
statement = wrap(test, statement, RunAs.class, javax.annotation.security.RunAs.class);
statement = wrap(test, statement, RunTestAs.class, org.apache.openejb.junit.RunTestAs.class);
statement = wrap(test, statement, Transaction.class, org.apache.openejb.junit.Transaction.class);
statement = wrap(test, statement, TransactionAttribute.class, javax.ejb.TransactionAttribute.class);
statement = possiblyExpectingExceptions(method, instance, statement);
statement = withPotentialTimeout(method, instance, statement);
statement = withBefores(method, instance, statement);
statement = withAfters(method, instance, statement);
return statement;
}
Aggregations