Invalid JSON in Playframework 2.1 Test POST Request

I am trying to check the POST route (on Playframework 2.1 / Java) and continue to receive an invalid request - an invalid JSON response.

Please let me know what I am doing wrong. My test code is below.

running(fakeApplication(), new Runnable() { public void run() { Map map = new HashMap(); map.put("key1", "val1"); map.put("key2", 2); map.put("key3", true); JsonNode df= Json.toJson(map); Result result = route (fakeRequest(POST, "/item").withHeader("Content-Type", "application/json").withSession(AccountTest.USER_KEY, "some key") .withSession(AccountTest.PROVIDER_KEY, "facebook").withJsonBody(df)); Logger.debug("result is " + contentAsString(result)); System.out.println("result is " + contentAsString(result)); assertThat(result).isNotNull(); // assertThat(result).isNotNull(); // assertThat(result).isEqualTo("hello"); } }); 
+3
source share
1 answer

This is a reported bug in Play 2.1 (Java). Please refer to the error here and git-pull request https://play.lighthouseapp.com/projects/82401/tickets/984-adding-json-body-to-play-21-java-returns-invalid-json-message # ticket-984-8

+2
source

Source: https://habr.com/ru/post/1480287/


All Articles