|
Play Framework/Scala example source code file (ContentNegotiationSpec.scala)
The ContentNegotiationSpec.scala Play Framework example source code
/*
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package play.it.action
import play.api.test.{FakeRequest, PlaySpecification}
import play.api.mvc.{Action, Controller}
import scala.concurrent.Future
object ContentNegotiationSpec extends PlaySpecification with Controller {
"rendering" should {
"work with simple results" in {
status(Action { implicit req =>
render {
case Accepts.Json() => Ok
}
}(FakeRequest().withHeaders(ACCEPT -> "application/json"))) must_== 200
}
"work with simple results in an async action" in {
status(Action.async { implicit req =>
Future.successful(render {
case Accepts.Json() => Ok
})
}(FakeRequest().withHeaders(ACCEPT -> "application/json"))) must_== 200
}
"work with async results" in {
status(Action.async { implicit req =>
render.async {
case Accepts.Json() => Future.successful(Ok)
}
}(FakeRequest().withHeaders(ACCEPT -> "application/json"))) must_== 200
}
}
}
Other Play Framework source code examplesHere is a short list of links related to this Play Framework ContentNegotiationSpec.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.