You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/06/05 11:21:56 UTC
svn commit: r781957 - in
/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs:
CxfRsConsumerTest.java CxfRsProducerTest.java
Author: ningjiang
Date: Fri Jun 5 09:21:54 2009
New Revision: 781957
URL: http://svn.apache.org/viewvc?rev=781957&view=rev
Log:
CAMEL-1672 Added the wiki tags
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java?rev=781957&r1=781956&r2=781957&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java Fri Jun 5 09:21:54 2009
@@ -32,6 +32,8 @@
public class CxfRsConsumerTest extends ContextTestSupport {
private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:9000?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService";
+
+ // START SNIPPET: example
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
@@ -39,12 +41,15 @@
public void process(Exchange exchange) throws Exception {
Message inMessage = exchange.getIn();
+ // Get the operation name from in message
String operationName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class);
+ // The parameter of the invocation is stored in the body of in message
String id = (String) inMessage.getBody(Object[].class)[0];
if ("getCustomer".equals(operationName)) {
Customer customer = new Customer();
customer.setId(Long.parseLong(id));
customer.setName("Willem");
+ // We just put the response Object into the out message body
exchange.getOut().setBody(customer);
}
}
@@ -53,6 +58,7 @@
}
};
}
+ // END SNIPPET: example
public void testGetCustomer() throws Exception {
URL url = new URL("http://localhost:9000/customerservice/customers/126");
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java?rev=781957&r1=781956&r2=781957&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java Fri Jun 5 09:21:54 2009
@@ -34,21 +34,28 @@
}
public void testGetConstumer() {
+ // START SNIPPET: example
Exchange exchange = template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message inMessage = exchange.getIn();
+ // set the operation name
inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer");
+ // set the parameters , if you just have one parameter
+ // camel will put this object into an Object[] itself
inMessage.setBody("123");
}
});
-
+
+ // 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");
+ // END SNIPPET: example
}