I am using Akka actor system with Spray and WireMock for stubbing web services. I want to also verify that the external http request was already made.
In the following use case a POST request is made to my Spray server which should send a request to an external service:
stubFor(get(urlEqualTo("/external-service"))
.willReturn(aResponse()
.withStatus(200)
.withBodyFile("response-body.json")));
myService ! Post("/my-service", FormData(Seq("id" -> "1")))
Thread.sleep(1000)
verify(postRequestedFor(urlEqualTo("/services/harvesterService")))
In various examples I have seen the Thread.sleep technique, because otherwise the ActorSystem is shut down and my service will never make the http request for the external service.
Is it possible to avoid this? Can WireMock wait for the request to the external service? Possibly with some timeout...