0
Приведенный ниже код гравюр:каротаж тело ответа с spray.io
Testing started at 00:10 ...
Connected to the target VM, address: '127.0.0.1:58646', transport: 'socket'
00:10:10 INFO [lt-dispatcher-4] [a.e.s.Slf4jLogger ] - Slf4jLogger started
vazzeg GET:200 OK
Disconnected from the target VM, address: '127.0.0.1:58646', transport: 'socket'
Проблема заключается в том, что я не вижу нигде слово logged
, который был передан от сервера к клиенту (в тесте) ,
Как я могу зарегистрировать содержание ответа?
Код:
class MainSpec extends FreeSpec with Matchers with ScalatestRouteTest with SpraySampleService {
def actorRefFactory = system
def requestMethodAndResponseStatusAsInfo(req: HttpRequest): Any => Option[LogEntry] = {
case res: HttpResponse => Some(LogEntry(req.method + ":" + res.message.status, Logging.DebugLevel))
case res => Some(LogEntry("vazzeg 2"+res)) // other kind of responses
}
def printRequestMethodAndResponseStatus(req: HttpRequest)(res: Any): Unit =
println("vazzeg "+requestMethodAndResponseStatusAsInfo(req)(res).map(_.obj.toString).getOrElse(""))
val logRequestResponsePrintln = DebuggingDirectives.logRequestResponse(LoggingMagnet(printRequestMethodAndResponseStatus))
"The spraysample Route" - {
"simple" in {
Get("/") ~> logRequestResponsePrintln(complete("logged")) ~> check {
val r=responseAs[String]
r === "logged"
}
}
....
}