Search in sources :

Example 66 with Statement

use of org.junit.runners.model.Statement in project restfuse by eclipsesource.

the class HttpTestStatement_Test method testRemovesProxyProperties.

@Test
public void testRemovesProxyProperties() throws Throwable {
    Statement base = mock(Statement.class);
    Description description = mock(Description.class);
    HttpTest annotation = createAnnotation();
    when(description.getAnnotation(HttpTest.class)).thenReturn(annotation);
    Object target = new Object();
    HttpTestStatement statement = new HttpTestStatement(base, description, target, "http://localhost", "http://proxy.com", 8080, null);
    statement.evaluate();
    assertNull(System.getProperty(HttpTestStatement.HTTP_PROXY_HOST));
    assertNull(System.getProperty(HttpTestStatement.HTTP_PROXY_PORT));
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest) Description(org.junit.runner.Description) Statement(org.junit.runners.model.Statement) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) Test(org.junit.Test) HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Example 67 with Statement

use of org.junit.runners.model.Statement in project restfuse by eclipsesource.

the class Destination method apply.

@Override
public /**
   * <p><b>Not meant for public use. This method will be invoked by the JUnit framework.</b></p>
   */
Statement apply(Statement base, Description description) {
    Statement result;
    if (hasAnnotation(description)) {
        requestStatement = new HttpTestStatement(base, description, testObject, baseUrl, proxyHost, proxyPort, context);
        result = requestStatement;
    } else {
        result = base;
    }
    return result;
}
Also used : HttpTestStatement(com.eclipsesource.restfuse.internal.HttpTestStatement) Statement(org.junit.runners.model.Statement) HttpTestStatement(com.eclipsesource.restfuse.internal.HttpTestStatement)

Example 68 with Statement

use of org.junit.runners.model.Statement in project restfuse by eclipsesource.

the class HttpTestStatement method doEvaluate.

private void doEvaluate() throws Throwable {
    Statement delegate = new BasicStatement(base, this);
    if (needsCallback()) {
        delegate = new CallbackStatement(base, this, description, target);
    } else if (needsPoll()) {
        delegate = new PollStatement(base, this, description, target);
    }
    delegate.evaluate();
}
Also used : Statement(org.junit.runners.model.Statement) PollStatement(com.eclipsesource.restfuse.internal.poll.PollStatement) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) PollStatement(com.eclipsesource.restfuse.internal.poll.PollStatement) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement)

Example 69 with Statement

use of org.junit.runners.model.Statement in project vert.x by eclipse.

the class RepeatRule method apply.

@Override
public Statement apply(Statement statement, Description description) {
    Statement result = statement;
    Repeat repeat = description.getAnnotation(Repeat.class);
    if (repeat != null) {
        int times = repeat.times();
        result = new RepeatStatement(times, statement);
    }
    return result;
}
Also used : Statement(org.junit.runners.model.Statement)

Example 70 with Statement

use of org.junit.runners.model.Statement in project gradle by gradle.

the class Sample method apply.

public Statement apply(final Statement base, FrameworkMethod method, Object target) {
    sampleName = getSampleName(method);
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            if (sampleName != null) {
                String hintForMissingSample = String.format("If '%s' is a new sample, try running 'gradle intTestImage'.", sampleName);
                TestFile srcDir = new IntegrationTestBuildContext().getSamplesDir().file(sampleName).assertIsDir(hintForMissingSample);
                logger.debug("Copying sample '{}' to test directory.", sampleName);
                srcDir.copyTo(getDir());
            } else {
                logger.debug("No sample specified for this test, skipping.");
            }
            base.evaluate();
        }
    };
}
Also used : Statement(org.junit.runners.model.Statement) TestFile(org.gradle.test.fixtures.file.TestFile) IntegrationTestBuildContext(org.gradle.integtests.fixtures.executer.IntegrationTestBuildContext)

Aggregations

Statement (org.junit.runners.model.Statement)129 Test (org.junit.Test)22 FrameworkMethod (org.junit.runners.model.FrameworkMethod)15 Method (java.lang.reflect.Method)10 AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)10 Fail (org.junit.internal.runners.statements.Fail)9 TestRule (org.junit.rules.TestRule)7 Description (org.junit.runner.Description)7 MethodRule (org.junit.rules.MethodRule)6 MultipleFailureException (org.junit.runners.model.MultipleFailureException)6 ExecutorService (java.util.concurrent.ExecutorService)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 ReflectiveCallable (org.junit.internal.runners.model.ReflectiveCallable)5 ArrayList (java.util.ArrayList)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 EmptyStatement (com.hazelcast.util.EmptyStatement)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 TestExecutorService (org.apache.beam.fn.harness.test.TestExecutors.TestExecutorService)3 CompositeConfiguration (org.apache.logging.log4j.core.config.composite.CompositeConfiguration)3 LoggerContextRule (org.apache.logging.log4j.junit.LoggerContextRule)3