tomakehurst/wiremock — pull request #60 by neilg (2013-10-15 06:09:55+00:00)
Title: Rule stubbing

This branch introduces methods on WireMockRule and WireMockClassRule for stubbing, delaying, and verifying. This makes using multiple WireMock rules within a test a little simpler, as there is no need to use WireMock.configureFor() to switch between instances.

e.g.

@ClassRule
public static WireMockClassRule firstService = new WireMockClassRule(9080);

@ClassRule
public static WireMockClassRule secondService = new WireMockClassRule(10080);

@Test
public void checkSomething() {
firstService.stubFor(get(urlEqualTo("/things/4321"))
.willReturn(aResponse().withStatus(404)))
secondService.stubFor(put(urlEqualTo("/items/4321"))
.willReturn(aResponse().withStatus(201)))

runSomething();

firstService.verify(getRequestedFor(urlEqualTo("/things/4321")));
secondService.verify(0, putRequestedFor(urlMatching(".*")));
}