|
Play Framework/Scala example source code file (WSTestClient.scala)
The WSTestClient.scala Play Framework example source codepackage play.api.test import play.api.libs.ws._ import play.api.mvc.Call trait WsTestClient { type Port = Int /** * Constructs a WS request holder for the given reverse route. Optionally takes a WSClient. Note that the WS client used * by default requires a running Play application (use WithApplication for tests). * * For example: * {{{ * "work" in new WithApplication() { implicit app => * wsCall(controllers.routes.Application.index()).get() * } * }}} */ def wsCall(call: Call)(implicit port: Port, client: WSClient = WS.client(play.api.Play.current)): WSRequestHolder = wsUrl(call.url) /** * Constructs a WS request holder for the given relative URL. Optionally takes a port and WSClient. Note that the WS client used * by default requires a running Play application (use WithApplication for tests). */ def wsUrl(url: String)(implicit port: Port, client: WSClient = WS.client(play.api.Play.current)) = { WS.clientUrl("http://localhost:" + port + url) } } Other Play Framework source code examplesHere is a short list of links related to this Play Framework WSTestClient.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.