我的控制器方法:
def postCategory = Action(parse.tolerantText) { request => Ok("") }
这是我的考验:
val result = categoryController.postCategory.apply(FakeRequest()) status(result) mustEqual OK //error this line
我有这个错误:
Error:(63,14) type mismatch; found :
play.api.libs.streams.Accumulator[akka.util.ByteString,play.api.mvc.Result]
required: scala.concurrent.Future[play.api.mvc.Result]
status(result) mustEqual OK
^
似乎使用自定义解析器解析.*使得它返回Accumulator而不是Future [Result]
我正在玩2.5-RC2
解决方法
你应该使用result.run获取Materializer的实例与Guice
看起来像:
import akka.stream.Materializer //... def mockApp = new GuiceApplicationBuilder().build() val mtrlzr = mockApp.injector.instanceOf[Materializer] val result: Accumulator[ByteString,Result] = controller.accessToken()(FakeRequest()) val runResult: Future[Result] = result.run()(mtrlzr)