I want to test http request/response. So I use WireMock.
I want to stub response for specific request: Here code:
public class WireMockPersons { @Rule public WireMockRule wireMockRule = new WireMockRule(8089); @Test public void exactUrlOnly() { stubFor(get(urlEqualTo("/some/thing")) .willReturn(aResponse() .withHeader("Content-Type", "text/plain") .withBody("Hello world!"))); assertThat(testClient.get("/some/thing").statusCode(), is(200)); assertThat(testClient.get("/some/thing/else").statusCode(), is(404)); }
Code is not compile because no object testClient. How I can get testClient object?