https://www.playframework.com/documentation/2.6.x/ScalaWS를 살펴보면 WSClient를 

Injection해서 사용하고 있다.


WSClient를 Injection없이 바로 써서 테스트하고 싶다면 다음 예제를 활용한다. 



import play.api.libs.ws.ahc.AhcWSClient
import akka.stream.ActorMaterializer
import akka.actor.ActorSystem
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}

implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val ws = AhcWSClient()

val result = ws.url("https://www.google.com")
.withRequestTimeout(10000.millis)
.get()
.map{
resp => resp.body
}(system.dispatcher)

val response = Await.result(result, atMost = 5.second)

println(response)


Posted by 김용환 '김용환'