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 2008/07/03 12:08:43 UTC
svn commit: r673643 -
/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Author: ningjiang
Date: Thu Jul 3 03:08:43 2008
New Revision: 673643
URL: http://svn.apache.org/viewvc?rev=673643&view=rev
Log:
Changed the CxfConsumerTest to show using choice to implement operation based routing
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java?rev=673643&r1=673642&r2=673643&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java Thu Jul 3 03:08:43 2008
@@ -47,24 +47,28 @@
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(SIMPLE_ENDPOINT_URI).process(new Processor() {
+ from(SIMPLE_ENDPOINT_URI).choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
public void process(final Exchange exchange) {
Message in = exchange.getIn();
// Get the parameter list
List parameter = in.getBody(List.class);
// Get the operation name
String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);
- Object result = null;
- if (operation.equals(ECHO_OPERATION)) {
- result = operation + " " + (String)parameter.get(0);
- }
- if (operation.equals(ECHO_BOOLEAN_OPERATION)) {
- result = (Boolean)parameter.get(0);
- }
+ Object result = operation + " " + (String)parameter.get(0);
// Put the result back
exchange.getOut().setBody(result);
}
+ })
+ .when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_BOOLEAN_OPERATION)).process(new Processor() {
+ public void process(final Exchange exchange) {
+ Message in = exchange.getIn();
+ // Get the parameter list
+ List parameter = in.getBody(List.class);
+ // Put the result back
+ exchange.getOut().setBody((Boolean)parameter.get(0));
+ }
});
+
}
};
}