Search in sources :

Example 1 with HandlerImpl

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

the class JUnit5HttpApi method beforeAll.

@Override
public void beforeAll(final ExtensionContext extensionContext) {
    final HttpApi config = extensionContext.getElement().map(c -> c.getAnnotation(HttpApi.class)).orElse(null);
    if (config != null) {
        setGlobalProxyConfiguration(config.globalProxyConfiguration());
        setLogLevel(config.logLevel());
        setPort(config.port());
        newInstance(config.responseLocator(), ResponseLocator.class).ifPresent(this::setResponseLocator);
        newInstance(config.headerFilter(), Predicate.class).ifPresent(this::setHeaderFilter);
        newInstance(config.executor(), Executor.class).ifPresent(this::setExecutor);
        newInstance(config.sslContext(), Supplier.class).map(s -> SSLContext.class.cast(s.get())).ifPresent(this::setSslContext);
        setSkipProxyHeaders(config.skipProxyHeaders());
        if (config.useSsl()) {
            activeSsl();
        }
    }
    extensionContext.getStore(NAMESPACE).put(HttpApiHandler.class.getName(), this);
    final HandlerImpl<JUnit5HttpApi> handler = new HandlerImpl<>(this, null, null);
    extensionContext.getStore(NAMESPACE).put(HandlerImpl.class.getName(), handler);
    handler.start();
}
Also used : SSLContext(javax.net.ssl.SSLContext) Executor(java.util.concurrent.Executor) Predicate(java.util.function.Predicate) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ResponseLocator(org.talend.sdk.component.junit.http.api.ResponseLocator) HttpApiInject(org.talend.sdk.component.junit.http.junit5.HttpApiInject) Supplier(java.util.function.Supplier) HandlerImpl(org.talend.sdk.component.junit.http.internal.impl.HandlerImpl) InvocationTargetException(java.lang.reflect.InvocationTargetException) HttpApiHandler(org.talend.sdk.component.junit.http.api.HttpApiHandler) AfterEachCallback(org.junit.jupiter.api.extension.AfterEachCallback) BeforeAllCallback(org.junit.jupiter.api.extension.BeforeAllCallback) AfterAllCallback(org.junit.jupiter.api.extension.AfterAllCallback) JUnit5InjectionSupport(org.talend.sdk.component.junit.base.junit5.JUnit5InjectionSupport) Handlers(org.talend.sdk.component.junit.http.internal.impl.Handlers) Annotation(java.lang.annotation.Annotation) BeforeEachCallback(org.junit.jupiter.api.extension.BeforeEachCallback) Optional(java.util.Optional) DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) HttpApi(org.talend.sdk.component.junit.http.junit5.HttpApi) Executor(java.util.concurrent.Executor) ResponseLocator(org.talend.sdk.component.junit.http.api.ResponseLocator) DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) HttpApiHandler(org.talend.sdk.component.junit.http.api.HttpApiHandler) HttpApi(org.talend.sdk.component.junit.http.junit5.HttpApi) HandlerImpl(org.talend.sdk.component.junit.http.internal.impl.HandlerImpl) Predicate(java.util.function.Predicate)

Aggregations

Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Optional (java.util.Optional)1 Executor (java.util.concurrent.Executor)1 Predicate (java.util.function.Predicate)1 Supplier (java.util.function.Supplier)1 SSLContext (javax.net.ssl.SSLContext)1 AfterAllCallback (org.junit.jupiter.api.extension.AfterAllCallback)1 AfterEachCallback (org.junit.jupiter.api.extension.AfterEachCallback)1 BeforeAllCallback (org.junit.jupiter.api.extension.BeforeAllCallback)1 BeforeEachCallback (org.junit.jupiter.api.extension.BeforeEachCallback)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 JUnit5InjectionSupport (org.talend.sdk.component.junit.base.junit5.JUnit5InjectionSupport)1 HttpApiHandler (org.talend.sdk.component.junit.http.api.HttpApiHandler)1 ResponseLocator (org.talend.sdk.component.junit.http.api.ResponseLocator)1 DefaultResponseLocator (org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator)1 HandlerImpl (org.talend.sdk.component.junit.http.internal.impl.HandlerImpl)1 Handlers (org.talend.sdk.component.junit.http.internal.impl.Handlers)1 HttpApi (org.talend.sdk.component.junit.http.junit5.HttpApi)1 HttpApiInject (org.talend.sdk.component.junit.http.junit5.HttpApiInject)1