1
我想测试一个特定的球衣资源,但球衣客户端正在返回InboundJaxrsResponse
而我期待OutboundJaxrsResponse
。我不明白这种行为。测试泽西REST资源(无效回报响应)
我确实调查过调试器,资源按预期返回OutboundJaxrsResponse
,这意味着球衣客户端正在进行包装/转换,但我不明白为什么。
如果我没有做得对,你可以告诉我一个比较响应的好方法。
我正在使用dropwizard。
@Test
public void itShouldRetrieveListOfComputations() {
List<Computation> computations = new ArrayList<Computation>();
computations.add(new Computation("name1", "description1", "expression1"));
computations.add(new Computation("name2", "description2", "expression2"));
when(computationDAO.findAll()).thenReturn(computations);
Response expected = Response.ok(computations).build();
assertThat(resource.client().target("/computations").request().get()).isEqualTo(expected);
verify(computationDAO).findAll();
}
资源被测
@GET
@UnitOfWork
@Timed
public Response list() {
List<Computation> computations = computationDAO.findAll();
Response response = Response.ok(computations).build();
return response;
}
后果
org.junit.ComparisonFailure:
Expected :OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false}
Actual :InboundJaxrsResponse{context=ClientResponse{method=GET, uri=/computations, status=200, reason=OK}}