将字符串(Json)转换为Rest Assured Response

时间:2016-09-22 20:16:11

标签: java json httpclient httpresponse rest-assured

我有一个JSON正文作为Java String。我想将此String转换为RestAssured Response。这可能吗?

或者

是否可以将apache HttpResponse转换为RestAssured Response

HttpClient httpClient = HttpClientBuilder.create().build();
            HttpPost httpPost = new HttpPost(url);
            org.apache.http.entity.StringEntity entity = new org.apache.http.entity.StringEntity(body);
            httpPost.setEntity(entity);
            httpPost.setHeader("Accept", "application/json");
            httpPost.setHeader("Content-type", "application/json");
            HttpResponse httpResponse = httpClient.execute(httpPost);

我想将httpResponse转换为RestAssured Response

1 个答案:

答案 0 :(得分:0)

Response Javadoc说" REST保证请求的响应。"。所以,不,我不认为这是可能的。无论如何,我会以RestAssurred提出请求,我觉得更容易。

参考:http://static.javadoc.io/com.jayway.restassured/rest-assured/1.2.3/com/jayway/restassured/response/Response.html