スプレーのテストを書いてみます
class FullTestKitExampleSpec extends Specification with Specs2RouteTest with UserController with HttpService {
def actorRefFactory = system
"The service" should {
"return a greeting for GET requests to the root path" in {
Get("/user") ~> `Accept-Encoding`(gzip) ~> userRoute ~> check {
val responsex = response
responseAs[String] must contain("Test1")
}
}
}
}
私はフォロールーターを持っています
trait UserController extends HttpService with Json4sSupport with CORSSupport{
override implicit def json4sFormats: Formats = DefaultFormats
val userRoute = {
cors {
compressResponse(Gzip) {
path("user") {
get {
complete {
"Test1"
}
} ~
post {
entity(as[UserRegister]) { person =>
complete {
println(person.name)
person.name
}
}
}
}
}
}
}
}
レスポンスにはGZIP圧縮を使用していますが、
アサーションのタイプ「java.lang.String」への応答を非整列化できませんでした
responseAs
: MalformedContent(unknown token Near: ,Some(org.json4s.ParserUtil$ParseException: unknown token Near: ))
autodecode GZIP HttpResponse を文字列に設定するには?