I have an Unfiltered Netty server that I need to shutdown and restart after every test.
val mockService = unfiltered.netty.Server.http(mockServicePort).handler(mockServicePlan)
before {
proxyServer.start()
}
after {
proxyServer.stop()
}
Currently, this is not working, and I am fairly certain that is because the stop()
function is non-blocking and so the following start()
function gets called to early.
I looked for a way to block or get notified on server closure, but it would not appear to be surfaced through the current API.
Is there a better way of achieving what I am trying to achieve?
Easy answer: replace your Unfiltered Netty server with a HTTP4S Blaze server.
There's also an
awaitShutdown
that blocks until the server shuts down. But sinceshutdown
is aTask
, it's easy to get notified when it has finished. JustflatMap
that shit.