Test asynchronous behavior using WireMock
<p>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.</p>

<p>In the following use case a POST request is made to my Spray server which should send a request to an external service:</p>

<pre><code>stubFor(get(urlEqualTo("/external-service"))
    .willReturn(aResponse()
      .withStatus(200)
      .withBodyFile("response-body.json")));

myService ! Post("/my-service", FormData(Seq("id" -&gt; "1")))

Thread.sleep(1000)

verify(postRequestedFor(urlEqualTo("/services/harvesterService")))
</code></pre>

<p>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.</p>

<p>Is it possible to avoid this? Can WireMock wait for the request to the external service? Possibly with some timeout...</p>