Assume I have made a simple client in my application that uses a remote web service that is exposing a RESTful API at some URI /foo/bar/{baz}
. Now I wish to uni
Best method is to use WireMock. Add the following dependencies:
com.github.tomakehurst
wiremock
2.4.1
org.igniterealtime.smack
smack-core
4.0.6
Define and use the wiremock as shown below
@Rule
public WireMockRule wireMockRule = new WireMockRule(8089);
String response ="Hello world";
StubMapping responseValid = stubFor(get(urlEqualTo(url)).withHeader("Content-Type", equalTo("application/json"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(response)));