[Play 2.4.x JAVA] How to unit test controller with multipart/form-data?

75 views
Skip to first unread message

Christian Schmitt

unread,
Aug 21, 2015, 6:37:55 AM8/21/15
to play-framework
Hello, how could I unit test a controller which has input with multipart/form-data?

Currently getting the controller instance is really straigth forward with extends WithApplication and then app.injecter().instanceOf(Controller.class);
However that only works with GET requests without any body.

However then things gets wierd, we need to statically import route from import static play.test.Helpers.*;

so we have the following:

WSroute(fakeRequest(POST, "url")) now we could add something to fakeRequest, however there is no bodyAsMultipart method (all other methods, Xml, Json, Text, etc are there) do we really need to manually set it?

Christian Schmitt

unread,
Aug 21, 2015, 6:39:33 AM8/21/15
to play-framework
Also is there a way to use the controller instance and call the method with post data somehow?

Christian Schmitt

unread,
Aug 22, 2015, 4:28:33 AM8/22/15
to play-framework
Solved it via some packges inside com.ning.http
Reply all
Reply to author
Forward
0 new messages