Search in sources :

Example 1 with DefaultResponseLocator

use of org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator in project component-runtime by Talend.

the class JUnit4HttpApiPerMethodConfigurator method apply.

@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            final ResponseLocator responseLocator = server.getResponseLocator();
            if (DefaultResponseLocator.class.isInstance(responseLocator)) {
                final DefaultResponseLocator defaultResponseLocator = DefaultResponseLocator.class.cast(responseLocator);
                defaultResponseLocator.setTest(description.getClassName() + "_" + description.getMethodName());
            }
            try {
                base.evaluate();
            } finally {
                if (DefaultResponseLocator.class.isInstance(responseLocator)) {
                    if (Handlers.isActive("capture")) {
                        final DefaultResponseLocator defaultResponseLocator = DefaultResponseLocator.class.cast(responseLocator);
                        defaultResponseLocator.flush(Handlers.getBaseCapture());
                    }
                }
            }
        }
    };
}
Also used : DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) Statement(org.junit.runners.model.Statement) DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) ResponseLocator(org.talend.sdk.component.junit.http.api.ResponseLocator)

Aggregations

Statement (org.junit.runners.model.Statement)1 ResponseLocator (org.talend.sdk.component.junit.http.api.ResponseLocator)1 DefaultResponseLocator (org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator)1