Testen Sie MultipartFormData in Play 2.0 FakeRequest

Ich versuche, einen Funktionstest für einen Play 2-Controller zu erstellen, der mehrteilige Formulardaten als Eingabe verwendet. Derzeit gibt es in FakeRequest keine Methode zur Unterstützung von mehrteiligem POST. Welche anderen Möglichkeiten zum Testen dieses Controllers?

Map<String, Object> map = new HashMap<String, Object>();
map.put("param1", "test-1");
map.put("param2", "test-2");
map.put("file", file)
Result result = routeAndCall(fakeRequest(POST, "/register").withFormUrlEncodedBody(map));// NO SUCH METHOD

EDIT: Dies ist die Problemumgehung, die ich zum Testen von Multipart durchgeführt habe.

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://localhost:3333/blobupload");

    FileBody imageFile = new FileBody(new File("test/resources/test-1.jpg"));
    StringBody guid1 = null;
    StringBody guid2 = null;
    try {
        guid1 = new StringBody("GUID-1");

    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }

    MultipartEntity reqEntity = new MultipartEntity();
    reqEntity.addPart("key1", imageFile);
    reqEntity.addPart("key2", guid1);

    httppost.setEntity(reqEntity);

    HttpResponse response;
    try {
        response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();

        assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
} catch (IOException e) {
        e.printStackTrace();
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage