Search in sources :

Example 6 with Slf4jNotifier

use of com.github.tomakehurst.wiremock.common.Slf4jNotifier in project spring-cloud-contract by spring-cloud.

the class PortAndMappings method start.

@Override
public HttpServerStub start(HttpServerStubConfiguration configuration) {
    if (isRunning()) {
        if (log.isTraceEnabled()) {
            log.trace("The server is already running at port [" + port() + "]");
        }
        return this;
    }
    int port = configuration.port;
    WireMockConfiguration wireMockConfiguration = config().port(port).notifier(new Slf4jNotifier(true));
    if (configuration.configurer.isAccepted(wireMockConfiguration)) {
        @SuppressWarnings("unchecked") HttpServerStubConfigurer<WireMockConfiguration> configurer = configuration.configurer;
        wireMockConfiguration = configurer.configure(wireMockConfiguration, configuration);
    }
    this.wireMockConfiguration = wireMockConfiguration;
    this.https = wireMockConfiguration.httpsSettings().enabled();
    port = this.https ? wireMockConfiguration.httpsSettings().port() : wireMockConfiguration.portNumber();
    this.wireMockServer = new WireMockServer(wireMockConfiguration);
    this.wireMockServer.start();
    if (log.isDebugEnabled()) {
        log.debug("For " + configuration.toColonSeparatedDependencyNotation() + " Started WireMock at [" + (this.https ? "https" : "http") + "] port [" + port + "]");
    }
    cacheStubServer(configuration.randomPort, port);
    return this;
}
Also used : WireMockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier)

Example 7 with Slf4jNotifier

use of com.github.tomakehurst.wiremock.common.Slf4jNotifier in project sugoi-api by InseeFr.

the class WebhookReceiverService method startServer.

public static boolean startServer() {
    WireMockServer webhookServer = new WireMockServer(WireMockConfiguration.wireMockConfig().port(8089).notifier(new Slf4jNotifier(true)).threadPoolFactory(new ThreadPoolFactory() {

        @Override
        public ThreadPool buildThreadPool(Options options) {
            ThreadPool tp = new QueuedDaemonThreadPool(options.containerThreads());
            return tp;
        }
    }));
    webhookServer.start();
    webhookServer.stubFor(post("/spoc/send").willReturn(aResponse().withStatus(200)));
    return true;
}
Also used : Options(com.github.tomakehurst.wiremock.core.Options) ThreadPool(wiremock.org.eclipse.jetty.util.thread.ThreadPool) QueuedDaemonThreadPool(fr.insee.sugoi.app.service.utils.QueuedDaemonThreadPool) ThreadPoolFactory(com.github.tomakehurst.wiremock.http.ThreadPoolFactory) QueuedDaemonThreadPool(fr.insee.sugoi.app.service.utils.QueuedDaemonThreadPool) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier)

Example 8 with Slf4jNotifier

use of com.github.tomakehurst.wiremock.common.Slf4jNotifier in project cf-ops-automation-broker by orange-cloudfoundry.

the class WireMockTestFixture method startWireMock.

@PostConstruct
void startWireMock() {
    wireMockServer = new WireMockServer(options().port(8088).httpsPort(8089).notifier(new Slf4jNotifier(true)));
    wireMockServer.start();
}
Also used : WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier) PostConstruct(javax.annotation.PostConstruct)

Example 9 with Slf4jNotifier

use of com.github.tomakehurst.wiremock.common.Slf4jNotifier in project cf-ops-automation-broker by orange-cloudfoundry.

the class WireMockTestFixture method startWireMock.

@PostConstruct
void startWireMock() {
    wireMockServer = new WireMockServer(options().port(8088).httpsPort(8089).notifier(new Slf4jNotifier(true)));
    wireMockServer.start();
}
Also used : WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier) PostConstruct(javax.annotation.PostConstruct)

Example 10 with Slf4jNotifier

use of com.github.tomakehurst.wiremock.common.Slf4jNotifier in project wiremock by wiremock.

the class WireMockWebContextListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    boolean verboseLoggingEnabled = Boolean.parseBoolean(firstNonNull(context.getInitParameter("verboseLoggingEnabled"), "true"));
    WireMockApp wireMockApp = new WireMockApp(new WarConfiguration(context), new NotImplementedContainer());
    context.setAttribute(APP_CONTEXT_KEY, wireMockApp);
    context.setAttribute(StubRequestHandler.class.getName(), wireMockApp.buildStubRequestHandler());
    context.setAttribute(AdminRequestHandler.class.getName(), wireMockApp.buildAdminRequestHandler());
    context.setAttribute(Notifier.KEY, new Slf4jNotifier(verboseLoggingEnabled));
}
Also used : WireMockApp(com.github.tomakehurst.wiremock.core.WireMockApp) StubRequestHandler(com.github.tomakehurst.wiremock.http.StubRequestHandler) AdminRequestHandler(com.github.tomakehurst.wiremock.http.AdminRequestHandler) ServletContext(javax.servlet.ServletContext) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier)

Aggregations

Slf4jNotifier (com.github.tomakehurst.wiremock.common.Slf4jNotifier)17 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)15 WireMock (com.github.tomakehurst.wiremock.client.WireMock)10 BeforeMethod (org.testng.annotations.BeforeMethod)10 PostConstruct (javax.annotation.PostConstruct)2 HttpBitbucketServerApiClient (org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient)2 BitbucketServerOAuthAuthenticator (org.eclipse.che.security.oauth1.BitbucketServerOAuthAuthenticator)2 Options (com.github.tomakehurst.wiremock.core.Options)1 WireMockApp (com.github.tomakehurst.wiremock.core.WireMockApp)1 WireMockConfiguration (com.github.tomakehurst.wiremock.core.WireMockConfiguration)1 ResponseTemplateTransformer (com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer)1 AdminRequestHandler (com.github.tomakehurst.wiremock.http.AdminRequestHandler)1 StubRequestHandler (com.github.tomakehurst.wiremock.http.StubRequestHandler)1 ThreadPoolFactory (com.github.tomakehurst.wiremock.http.ThreadPoolFactory)1 QueuedDaemonThreadPool (fr.insee.sugoi.app.service.utils.QueuedDaemonThreadPool)1 PostConstruct (jakarta.annotation.PostConstruct)1 ServletContext (javax.servlet.ServletContext)1 BeforeClass (org.junit.BeforeClass)1 ThreadPool (wiremock.org.eclipse.jetty.util.thread.ThreadPool)1