com.github.tomakehurst.wiremock.core.WireMockApp Java Examples

The following examples show how to use com.github.tomakehurst.wiremock.core.WireMockApp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockOriginServer.java    From styx with Apache License 2.0 6 votes vote down vote up
private static WireMockApp wireMockApp() {
    return new WireMockApp(
            new NotImplementedRequestDelayControl(),
            false,
            stubMappings -> {

            },
            mappings -> {

            },
            false,
            absent(),
            emptyMap(),
            null,
            null
    );
}
 
Example #2
Source File: WireMockBaseTest.java    From parsec-libraries with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setupServer() throws IOException {
    String rootDirPath = "parsec_wiremock_test";
    File root = Files.createTempDirectory(rootDirPath).toFile();
    new File(root, WireMockApp.MAPPINGS_ROOT).mkdirs();
    new File(root, WireMockApp.FILES_ROOT).mkdirs();
    wireMockServer = new WireMockServer(
            WireMockConfiguration.options()
                    .dynamicPort()
                    .fileSource(new SingleRootFileSource(rootDirPath))
    );

    wireMockServer.start();
    wireMockBaseUrl = "http://localhost:"+wireMockServer.port();
    WireMock.configureFor(wireMockServer.port());
}
 
Example #3
Source File: MockOriginServer.java    From styx with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #4
Source File: MockOriginServer.java    From styx with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: MockOriginServer.java    From styx with Apache License 2.0 5 votes vote down vote up
private static HttpHandler mockHandler(String originId, WireMockApp wireMockApp, WireMockConfiguration defaultConfig) {
    return newHandler(originId, new StubRequestHandler(
            wireMockApp,
            new StubResponseRenderer(
                    defaultConfig.filesRoot().child(FILES_ROOT),
                    wireMockApp.getGlobalSettingsHolder(),
                    new ProxyResponseRenderer(
                            defaultConfig.proxyVia(),
                            defaultConfig.httpsSettings().trustStore(),
                            defaultConfig.shouldPreserveHostHeader(),
                            defaultConfig.proxyHostHeader()
                    )
            )
    ));
}
 
Example #6
Source File: MockOriginServer.java    From styx with Apache License 2.0 4 votes vote down vote up
private static InetServer createAdminServer(String originId, int adminPort, WireMockApp wireMockApp) {
    return HttpServers.createHttpServer(
            "mock-admin-" + originId,
            new HttpConnectorConfig(adminPort),
            adminHandler(wireMockApp));
}
 
Example #7
Source File: MockOriginServer.java    From styx with Apache License 2.0 4 votes vote down vote up
private static HttpHandler adminHandler(WireMockApp wireMockApp) {
    return newHandler(new AdminRequestHandler(wireMockApp, new BasicResponseRenderer()));
}