A simulated response from the async-http-client.
Mock implementation for the play.api.libs.ws.WS client.
Mock implementation for the play.api.libs.ws.WS client. Usage:
val ws = MockWS { case ("GET", "/") => Action { Ok("index") } case ("GET", "/hi") => Action { Ok("world") } }
MockWS.Routes is a partial function. It is also possible to combine routes together:
val index = MockWS.Routes { case ("GET", "/") => Action { Ok("index") } } val hiWorld = MockWS.Routes { case ("GET", "/hi") => Action { Ok("world") } } val ws = MockWS(index orElse hiWorld)
traces whether a route was called and how many times.
traces whether a route was called and how many times. Usage:
val route1 = Route { case (GET, "/route1") => Action { Ok("") } } val route2 = Route { case (GET, "/route2") => Action { Ok("") } } val ws = MockWS(route1 orElse route2) await(ws.url("/route1").get()) route1.called == true route2.called == false
A simulated response from the async-http-client.
The play.api.libs.ws.ahc.AhcWSResponse is intended to wrap this.
Implementation is mostly based of org.asynchttpclient.netty.NettyResponse.
We're faking at this level as opposed to the play.api.libs.ws.WSResponse level to preserve any behavior specific to the NingWSResponse which is likely to be used in the real (non-fake) WSClient.