Search in sources :

Example 1 with WireMockApp

use of com.github.tomakehurst.wiremock.core.WireMockApp 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)

Example 2 with WireMockApp

use of com.github.tomakehurst.wiremock.core.WireMockApp in project styx by ExpediaGroup.

the class MockOriginServer method create.

public static MockOriginServer create(String appId, String originId, int adminPort, HttpConnectorConfig httpConfig) {
    WireMockApp wireMockApp = wireMockApp();
    InetServer adminServer = createAdminServer(originId, adminPort, wireMockApp);
    InetServer mockServer = HttpServers.createHttpServer("mock-stub-" + originId, httpConfig, mockHandler(originId, wireMockApp, new WireMockConfiguration()));
    int serverPort = httpConfig.port();
    return new MockOriginServer(appId, originId, adminPort, serverPort, adminServer, mockServer);
}
Also used : WireMockApp(com.github.tomakehurst.wiremock.core.WireMockApp) WireMockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration) InetServer(com.hotels.styx.InetServer)

Example 3 with WireMockApp

use of com.github.tomakehurst.wiremock.core.WireMockApp in project styx by ExpediaGroup.

the class MockOriginServer method create.

public static MockOriginServer create(String appId, String originId, int adminPort, HttpsConnectorConfig httpsConfig) {
    WireMockApp wireMockApp = wireMockApp();
    InetServer adminServer = createAdminServer(originId, adminPort, wireMockApp);
    InetServer mockServer = HttpServers.createHttpsServer("mock-stub-" + originId, httpsConfig, mockHandler(originId, wireMockApp, new WireMockConfiguration()));
    int serverPort = httpsConfig.port();
    return new MockOriginServer(appId, originId, adminPort, serverPort, adminServer, mockServer);
}
Also used : WireMockApp(com.github.tomakehurst.wiremock.core.WireMockApp) WireMockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration) InetServer(com.hotels.styx.InetServer)

Aggregations

WireMockApp (com.github.tomakehurst.wiremock.core.WireMockApp)3 WireMockConfiguration (com.github.tomakehurst.wiremock.core.WireMockConfiguration)2 InetServer (com.hotels.styx.InetServer)2 Slf4jNotifier (com.github.tomakehurst.wiremock.common.Slf4jNotifier)1 AdminRequestHandler (com.github.tomakehurst.wiremock.http.AdminRequestHandler)1 StubRequestHandler (com.github.tomakehurst.wiremock.http.StubRequestHandler)1 ServletContext (javax.servlet.ServletContext)1