scalatestingfinatra

finatra - getting the response data


I'm trying to extract the response data\context. I have a server which listens to incoming get requests and I'm sending back a plain text. the server is running and when I sending get request from my browser I see good results, but I want to create tests for my server. the test is creating an HttpRequest and the promise gives me back the HttpResponse when I'm trying to compare my expected result to the response all i get is:

HTTP/1.1 200 OK

Content-Type: text/plain

Content-Length: 11

Thanks, Dana


Solution

  • this is one way: https://github.com/twitter/finatra/blob/master/src/test/scala/com/twitter/finatra/ExampleSpec.scala

    another approach: val result = Await.result(f) val response = result.getContent.toString(Charsets.UTF_8)