Search in sources :

Example 1 with TestContext

use of org.apache.openejb.junit.context.TestContext in project tomee by apache.

the class JUnit4Runner method createUnsecuredStatement.

/**
 * Builds a method statement that executes in an unauthenticated context
 */
protected Statement createUnsecuredStatement(final FrameworkMethod method) {
    final Object test = newTestInstance();
    Statement statement = methodInvoker(method, test);
    statement = possiblyExpectingExceptions(method, test, statement);
    statement = withPotentialTimeout(method, test, statement);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    final TestContext context = runner.newTestContext(method.getMethod());
    return new ContextWrapperStatement(context, statement, test);
}
Also used : Statement(org.junit.runners.model.Statement) ContextWrapperStatement(org.apache.openejb.junit.context.ContextWrapperStatement) ContextWrapperStatement(org.apache.openejb.junit.context.ContextWrapperStatement) TestContext(org.apache.openejb.junit.context.TestContext)

Example 2 with TestContext

use of org.apache.openejb.junit.context.TestContext in project tomee by apache.

the class JUnit4Runner method createSecuredStatement.

/**
 * Create a new statement to run with a given role and whether it should fail or not.
 *
 * @param method
 * @param role
 * @param failWithAccessException
 * @return statement
 */
private Statement createSecuredStatement(final FrameworkMethod method, final String role, final boolean failWithAccessException) {
    final Object test = newTestInstance();
    Statement statement = methodInvoker(method, test);
    statement = possiblyExpectingAccessException(statement, failWithAccessException);
    // specified in @Test
    statement = possiblyExpectingExceptions(method, test, statement);
    statement = withPotentialTimeout(method, test, statement);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    final TestContext context = runner.newTestContext(method.getMethod(), role);
    return new ContextWrapperStatement(context, statement, test);
}
Also used : Statement(org.junit.runners.model.Statement) ContextWrapperStatement(org.apache.openejb.junit.context.ContextWrapperStatement) ContextWrapperStatement(org.apache.openejb.junit.context.ContextWrapperStatement) TestContext(org.apache.openejb.junit.context.TestContext)

Aggregations

ContextWrapperStatement (org.apache.openejb.junit.context.ContextWrapperStatement)2 TestContext (org.apache.openejb.junit.context.TestContext)2 Statement (org.junit.runners.model.Statement)2