use of org.apache.camel.component.cxf.jaxrs.testbean.Customer in project camel by apache.
the class CxfRsProducerTest method testGetCustomerWithHttpCentralClientAPI.
@Test
public void testGetCustomerWithHttpCentralClientAPI() {
// START SNIPPET: HttpExample
Exchange exchange = template.send("direct://http", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message inMessage = exchange.getIn();
setupDestinationURL(inMessage);
// using the http central client API
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
// set the Http method
inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
// set the relative path
inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123");
// Specify the response class , cxfrs will use InputStream as the response object type
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
// set a customer header
inMessage.setHeader("key", "value");
// since we use the Get method, so we don't need to set the message body
inMessage.setBody(null);
}
});
// get the response message
Customer response = (Customer) exchange.getOut().getBody();
assertNotNull("The response should not be null ", response);
assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
assertEquals("Get a wrong customer name", response.getName(), "John");
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
// END SNIPPET: HttpExample
}
use of org.apache.camel.component.cxf.jaxrs.testbean.Customer in project camel by apache.
the class CxfRsSslAsyncProducerTest method testCorrectTrustStore.
@Test
public void testCorrectTrustStore() {
Exchange exchange = template.send("direct://trust", new MyProcessor());
// get the response message
Customer response = (Customer) exchange.getOut().getBody();
assertNotNull("The response should not be null ", response);
assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
assertEquals("Get a wrong customer name", response.getName(), "John");
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
}
use of org.apache.camel.component.cxf.jaxrs.testbean.Customer in project camel by apache.
the class CxfRsSslProducerTest method testCorrectTrustStore.
@Test
public void testCorrectTrustStore() {
Exchange exchange = template.send("direct://trust", new MyProcessor());
// get the response message
Customer response = (Customer) exchange.getOut().getBody();
assertNotNull("The response should not be null ", response);
assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
assertEquals("Get a wrong customer name", response.getName(), "John");
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
}
Aggregations