我正在尝试测试 POST 路由(在 Playframework 2.1/Java 上)并不断收到错误请求 - 无效的 JSON 响应。
请让我知道我做错了什么。我的测试代码如下。
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");
}
});