use of org.apache.cxf.jaxrs.utils.ParameterizedCollectionType in project camel by apache.
the class CxfRsAsyncProducerTest method testGetCustomersWithHttpCentralClientAPI.
@Test
public void testGetCustomersWithHttpCentralClientAPI() {
Exchange exchange = template.send("direct://proxy", newExchange -> {
newExchange.setPattern(ExchangePattern.InOut);
Message inMessage = newExchange.getIn();
inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/");
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, List.class);
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_GENERIC_TYPE, new ParameterizedCollectionType(Customer.class));
inMessage.setBody(null);
});
// get the response message
List<Customer> response = CastUtils.cast((List<?>) exchange.getOut().getBody());
assertNotNull("The response should not be null ", response);
assertTrue("Dan is missing!", response.contains(new Customer(113, "Dan")));
assertTrue("John is missing!", response.contains(new Customer(123, "John")));
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
}
Aggregations