LnkedTreeMap不能被误导

时间:2018-05-30 12:43:45

标签: java rest http gson

enter image description here

这是我的代码

@Test

public void getAllEmployeesTest() throws IOException {
    HttpResponse response = http.get("http://localhost:8087/employee");
    List<Employee> expectedList = new ArrayList<Employee>();
    expectedList.add(new Employee(2, "Yashwant", "Chavan", 30, true));
    Type listType = new TypeToken<ArrayList<Employee>>() {
    }.getType();
    List<Employee> actualList = gson.fromJson(EntityUtils.toString(response.getEntity()), new ArrayList<Employee>().getClass());
    //Assert.assertEquals(actualList, expectedList);
    System.out.println(expectedList.get(0).isBusy());
    System.out.println(actualList.get(0).isBusy());
}

1 个答案:

答案 0 :(得分:0)

您可以使用以下代码片段

对其进行反序列化
<int:channel id='reply.channel'>
    <int:queue capacity='10' />
</int:channel>
<int:channel id='request.channel'/>

<int:channel id='outbound.Channel'/>

<int:gateway id="outboundGateway"
    service-interface="com.bst.pm.PostGateway"
    default-request-channel="outbound.Channel">
</int:gateway>

<int:object-to-json-transformer input-channel="outbound.Channel" output-channel="request.channel"/>



<int-http:outbound-gateway id="outbound.gateway"
    request-channel="request.channel" url-expression="headers.bstUrl"
    http-method-expression="headers.bstHttpMethod" expected-response-type-expression="headers.bstExpectedResponseType"
    charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel"
    mapped-request-headers="bst*, HTTP_REQUEST_HEADERS">

</int-http:outbound-gateway>