Wiremock stub receive connection refused in second call in second class

48 Views Asked by At

I am stubbing and http call in my integration test twice by using wiremock scenario states. If I make http request in same class then everything works good but in my case second call is made by different class/thread in my application and it receives connection refused. How I stub request is:

 stubFor(get(urlEqualTo("/user/" + userId))
            .willReturn(aResponse()
                    .withHeader("Content-Type", "application/json")
                    .withStatus(HttpStatus.SC_OK)
                    .withBody(jsonObjectMapper.writeValueAsString(user))))

Why am I getting this error in second call?

0

There are 0 best solutions below