【发布时间】:2016-04-12 16:33:17
【问题描述】:
我有一个巨大的 JSON 文件要 POST 作为用于测试目的的 rest api 调用的有效负载。我试过类似的东西:
public void RestTest() throws Exception {
File file = new File("/Users/bmishra/Code_Center/stash/experiments/src/main/resources/Search.json");
String content = null;
given().body(file).with().contentType("application/json").then().expect().
statusCode(200).
body(equalTo("true")).when().post("http://devsearch");
}
并得到错误:
java.lang.UnsupportedOperationException: Internal error: Can't encode /Users/bmishra/Code_Center/stash/experiments/src/main/resources/Search.json to JSON.
我可以通过读取文件并将正文作为字符串传递来运行,这可行,但我看到我可以直接传递文件对象,但这不起作用。
经过充分研究,似乎它不起作用。我已经打开了放心的问题。 https://github.com/jayway/rest-assured/issues/674
【问题讨论】:
-
只是从文件中读取并将读取的内容发送给解析器。
标签: java json rest junit rest-assured