camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r673643 - /activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Date Thu, 03 Jul 2008 10:08:43 GMT
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));
+                    }
                 });
+
             }
         };
     }



Mime
View raw message