Search in sources :

Example 1 with JsonFileMappingsSource

use of com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource in project wiremock by wiremock.

the class MappingsLoaderAcceptanceTest method loadsStubMappingsFromAMixtureOfSingleAndMultiStubFiles.

@Test
public void loadsStubMappingsFromAMixtureOfSingleAndMultiStubFiles() {
    buildWireMock(configuration);
    wireMockServer.resetMappings();
    wireMockServer.loadMappingsUsing(new JsonFileMappingsSource(new SingleRootFileSource(filePath("multi-stub"))));
    List<StubMapping> stubs = wireMockServer.listAllStubMappings().getMappings();
    assertThat(stubs.size(), is(4));
    assertThat(stubs, hasItem(stubMappingWithUrl("/single/1")));
    assertThat(stubs, hasItem(stubMappingWithUrl("/multi/1")));
    assertThat(stubs, hasItem(stubMappingWithUrl("/multi/2")));
    assertThat(stubs, hasItem(stubMappingWithUrl("/multi/3")));
}
Also used : JsonFileMappingsSource(com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource) StubMapping(com.github.tomakehurst.wiremock.stubbing.StubMapping) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource) Test(org.junit.jupiter.api.Test)

Example 2 with JsonFileMappingsSource

use of com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource in project wiremock by wiremock.

the class MappingsLoaderAcceptanceTest method mappingsLoadedFromJsonFiles.

@Test
public void mappingsLoadedFromJsonFiles() {
    buildWireMock(configuration);
    wireMockServer.loadMappingsUsing(new JsonFileMappingsSource(new SingleRootFileSource(filePath("test-requests"))));
    WireMockResponse response = testClient.get("/canned/resource/1");
    assertThat(response.statusCode(), is(200));
    response = testClient.get("/canned/resource/2");
    assertThat(response.statusCode(), is(401));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) JsonFileMappingsSource(com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource) Test(org.junit.jupiter.api.Test)

Aggregations

SingleRootFileSource (com.github.tomakehurst.wiremock.common.SingleRootFileSource)2 JsonFileMappingsSource (com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource)2 Test (org.junit.jupiter.api.Test)2 StubMapping (com.github.tomakehurst.wiremock.stubbing.StubMapping)1 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)1