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}}