camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r712821 - in /activemq/camel/trunk: camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml
Date Mon, 10 Nov 2008 20:17:36 GMT
Author: janstey
Date: Mon Nov 10 12:17:36 2008
New Revision: 712821

URL: http://svn.apache.org/viewvc?rev=712821&view=rev
Log:
CAMEL-1071 - Simplify the normalizer example a bit

Modified:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java?rev=712821&r1=712820&r2=712821&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java
Mon Nov 10 12:17:36 2008
@@ -29,18 +29,20 @@
 import static org.apache.camel.component.mock.MockEndpoint.expectsMessageCount;
 
 public class NormalizerTest extends ContextTestSupport {
-    protected MockEndpoint result;
-    protected MyNormalizer myNormalizer = new MyNormalizer();
-    
+   
     public void testSendToFirstWhen() throws Exception {
         String employeeBody1 = "<employee><name>Jon</name></employee>";
         String employeeBody2 = "<employee><name>Hadrian</name></employee>";
         String employeeBody3 = "<employee><name>Claus</name></employee>";
       
         String customerBody = "<customer name=\"James\"/>";
+
+        MockEndpoint result = getMockEndpoint("mock:result");
         
-        // expect only one person named Jon
-        result.expectedMessageCount(1);
-        result.expectedBodiesReceived("<person name=\"Jon\"/>");
+        result.expectedMessageCount(4);
+        result.expectedBodiesReceivedInAnyOrder("<person name=\"Jon\"/>",
+                                                "<person name=\"Hadrian\"/>",
+                                                "<person name=\"Claus\"/>",
+                                                "<person name=\"James\"/>");
 
         template.sendBody("direct:start", employeeBody1);
         template.sendBody("direct:start", employeeBody2);
@@ -49,18 +51,11 @@
         
         assertMockEndpointsSatisfied();
     }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        result = getMockEndpoint("mock:result");
-    }
     
     @Override
     protected Context createJndiContext() throws Exception {
         JndiContext answer = new JndiContext();
-        answer.bind("normalizer", myNormalizer);
+        answer.bind("normalizer", new MyNormalizer());
         return answer;
     }
     
@@ -68,13 +63,10 @@
         return new RouteBuilder() {
             public void configure() {
                 // START SNIPPET: example                
-                // before we can filter, we need to normalize the incoming messages
+                // we need to normalize two types of incoming messages
                 from("direct:start").choice()
-                  .when().xpath("/employee").to("bean:normalizer?method=employeeToPerson").to("seda:queue")
-                  .when().xpath("/customer").to("bean:normalizer?method=customerToPerson").to("seda:queue");
-                
-                // filter the normalized messages
-                from("seda:queue").filter().xpath("/person[@name='Jon']").to("mock:result");
+                  .when().xpath("/employee").to("bean:normalizer?method=employeeToPerson").to("mock:result")
+                  .when().xpath("/customer").to("bean:normalizer?method=customerToPerson").to("mock:result");
              
                 // END SNIPPET: example
             }
         };

Modified: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml?rev=712821&r1=712820&r2=712821&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml
Mon Nov 10 12:17:36 2008
@@ -30,22 +30,15 @@
         <when>
           <xpath>/employee</xpath>
           <to uri="bean:normalizer?method=employeeToPerson"/>
-          <to uri="seda:queue"/>
+          <to uri="mock:result"/>
         </when>
         <when>
           <xpath>/customer</xpath>
           <to uri="bean:normalizer?method=customerToPerson"/>
-          <to uri="seda:queue"/>
+          <to uri="mock:result"/>
         </when>
       </choice>
-    </route>
-    <route>
-      <from uri="seda:queue"/>
-      <filter>
-        <xpath>/person[@name='Jon']</xpath>
-        <to uri="mock:result"/>
-      </filter>
-    </route>    
+    </route> 
   </camelContext>
 
   <bean id="normalizer" class="org.apache.camel.processor.MyNormalizer"/>



Mime
View raw message