use of org.junit.runners.model.Statement in project buck by facebook.
the class BuckBlockJUnit4ClassRunner method methodBlock.
/**
* Override the default timeout behavior so that when no timeout is specified in the {@link Test}
* annotation, the timeout specified by the constructor will be used (if it has been set).
*/
@Override
protected Statement methodBlock(FrameworkMethod method) {
Statement statement = super.methodBlock(method);
// If the test class has a Timeout @Rule, then that should supersede the default timeout. The
// same applies if it has a timeout value for the @Test annotation.
long timeout = getTimeout(method);
return new SameThreadFailOnTimeout(executor.get(), timeout, testName(method), statement);
}
use of org.junit.runners.model.Statement in project dropwizard by dropwizard.
the class ResourceTestRule method apply.
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration);
try {
test = new JerseyTest() {
@Override
protected TestContainerFactory getTestContainerFactory() {
return configuration.testContainerFactory;
}
@Override
protected DeploymentContext configureDeployment() {
return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)).initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()).initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()).build();
}
@Override
protected void configureClient(ClientConfig clientConfig) {
final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(configuration.mapper);
configuration.clientConfigurator.accept(clientConfig);
clientConfig.register(jsonProvider);
}
};
test.setUp();
base.evaluate();
} finally {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.remove(configuration.getId());
test.tearDown();
}
}
};
}
use of org.junit.runners.model.Statement in project neo4j by neo4j.
the class SessionRule method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Map<Setting<?>, String> config = new HashMap<>();
config.put(GraphDatabaseSettings.auth_enabled, Boolean.toString(authEnabled));
gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase(config);
DependencyResolver resolver = gdb.getDependencyResolver();
Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class), resolver.resolveDependency(UserManagerSupplier.class));
boltFactory = new BoltFactoryImpl(gdb, new UsageData(null), NullLogService.getInstance(), resolver.resolveDependency(ThreadToStatementContextBridge.class), authentication, BoltConnectionTracker.NOOP, Config.defaults());
boltFactory.start();
try {
base.evaluate();
} finally {
try {
if (runningMachines != null) {
runningMachines.forEach(BoltStateMachine::close);
}
} catch (Throwable e) {
e.printStackTrace();
}
gdb.shutdown();
}
}
};
}
use of org.junit.runners.model.Statement in project neo4j by neo4j.
the class Neo4jWithSocket method apply.
@Override
public Statement apply(final Statement statement, final Description description) {
Statement testMethod = new Statement() {
@Override
public void evaluate() throws Throwable {
// If this is used as class rule then getMethodName() returns null, so use
// getClassName() instead.
String name = description.getMethodName() != null ? description.getMethodName() : description.getClassName();
workingDirectory = testDirectory.directory(name);
ensureDatabase(settings -> {
});
try {
statement.evaluate();
} finally {
shutdownDatabase();
}
}
};
Statement testMethodWithBeforeAndAfter = super.apply(testMethod, description);
return testDirectory.apply(testMethodWithBeforeAndAfter, description);
}
use of org.junit.runners.model.Statement in project hibernate-orm by hibernate.
the class CustomRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
log.info(Test.class.getSimpleName() + ": " + method.getName());
final Statement originalMethodBlock = super.methodBlock(method);
final ExtendedFrameworkMethod extendedFrameworkMethod = (ExtendedFrameworkMethod) method;
return new FailureExpectedHandler(originalMethodBlock, testClassMetadata, extendedFrameworkMethod, testInstance);
}
Aggregations