Serializing Multipart Form requests for testing on Play 2.1

喜你入骨 提交于 2019-12-02 00:50:05
  • You have two options, searializing MultiPartFormData which is (as far as I can tell) quite tricky to do. This post might help: https://groups.google.com/forum/?fromgroups=#!topic/play-framework/MPtQlX-cWMQ
  • You can skip going though the route method. If you want to test the Action in your controller, you can simply bypass the route. See Testing your Controllers in the documentation. If you do not go through the router, you don't need to supply a Writable. It is rarely needed to go through the router which essentially let's you first write it as bytes (using Writer) and then (using the body parser) convert it back to something Play understands.

If you don't want to skip route, you need a Writeable[AnyContentAsMultipartFormData], which turns MultipartFormData[TemporaryFile] into Array[Byte].

There's a Writeable[AnyContentAsMultipartFormData] here: http://tech.fongmun.com/post/125479939452/test-multipartformdata-in-play

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!