// A binary and some key=value pairs
// In the @Test
Http.MultipartFormData.DataPart dp = new Http.MultipartFormData.DataPart("name", "new stuff");
Source<ByteString, ?> src = FileIO.fromFile(ImageTestUtils.getTestImageFile());
Http.MultipartFormData.FilePart<Source<ByteString, ?>> fp = new Http.MultipartFormData.FilePart<>("pic", "pic.png", "application/octet-stream", src);
// Note: if the test extends WithApplication, then a "protected Materializer mat" is available
//Materializer mat = app.injector().instanceOf(Materializer.class);
Helpers.route(Helpers.fakeRequest("POST", "/")).bodyMultipart(Arrays.asList(dp, fp), mat);
// Then, in the controller..
Http.MultipartFormData<File> multipartFormData = request().body().asMultipartFormData();
Map<String, String[]> parameters = multipartFormData.asFormUrlEncoded();
String[] name = parameters.get("name"); // often [0]
Http.MultipartFormData.FilePart<File> filePart = multipartFormData.getFile("image");