I am new to WireMock and trying to get my first unit test to work with it. Now, following the docs on wiremock.org, I wrote this
WireMockConfiguration config = wireMockConfig().port(9089).httpsPort(8443);
m_wireMockServer = new WireMockServer(config);
m_wireMockServer.start();
WireMock.configureFor("localhost", 9089);
givenThat(get(urlEqualTo("/some/thing"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello world!")));
I expects this to make any http request to /some/thing to be caught. It gives me the following exception on the giventhat call:
com.github.tomakehurst.wiremock.client.VerificationException: Expected status 201 for http://localhost:9089/__admin/mappings/new but was 200
at com.github.tomakehurst.wiremock.client.HttpAdminClient.postJsonAssertOkAndReturnBody(HttpAdminClient.java:151)
at com.github.tomakehurst.wiremock.client.HttpAdminClient.addStubMapping(HttpAdminClient.java:65)
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:130)
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:126)
at com.github.tomakehurst.wiremock.client.WireMock.givenThat(WireMock.java:65)
What did I miss? What is wrong in the creation of the stub?
Aucun commentaire:
Enregistrer un commentaire