tomakehurst/wiremock — pull request #83 by rowanhill (2013-12-26 19:15:18+00:00)
Title: Fix intermittent StandaloneAcceptanceTest#canBeShutDownRemote() test

Hi,

Following on from #79, I think this should fix the intermittent test that accidentally added.

I'd previously been thinking I must have introduced some horrid threading issue that was interacting with Jetty in some way, but on taking a step back I realised it probably wasn't that complicated: the test repeatedly polled WireMock over HTTP asking for it's status (/__admin), but Jetty's shutdown isn't graceful, so sometimes the requests would get picked up by Jetty, but then not serviced (because Jetty shut down in that instant), leaving the test client to timeout.

Things this patch does:
* Reduces the sleep time of the graceful shutdown thread to 100ms - empirically, this appears to be more than enough, so we may as well keep it nice and small.
* Exposes the WireMockServer's isRunning() state on WireMockServerRunner. This is purely for the benefit of the tests, but I'm assuming this is okay, because a) it's already been done (c.f. run() and stop()), and b) the only code that should have a reference to WireMockServerRunner is the tests.
* Tests the newly exposed isRunning() method, rather than going over HTTP, removing the opportunity for an HTTP request to time out.

Things this patch does NOT do:
* Remove the (fairly small, I think) chance that when WireMock is shutdown (via any mechanism, not just the remote shutdown command) a request might time out.

Hopefully that's acceptable. Also, can you sanity check my above argument - I'm fairly confident in it, but I've been wrong here once before, so it's worth double checking my thinking! :)

Thanks,
Rowan