camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r774261 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/processor/ components/camel-jms/src/test/java/org/apache/camel/component/jms/ components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/
Date Wed, 13 May 2009 09:03:17 GMT
Author: davsclaus
Date: Wed May 13 09:03:17 2009
New Revision: 774261

URL: http://svn.apache.org/viewvc?rev=774261&view=rev
Log:
Fixed CS. Added unit test in camel-jms for CAMEL-1604

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsOnCompletionTest.java
      - copied, changed from r774235, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsUseOriginalBodyTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalBodyTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java?rev=774261&r1=774260&r2=774261&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelHandledPolicyTest.java
Wed May 13 09:03:17 2009
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.processor;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Processor;
 import org.apache.camel.Exchange;
-import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 
 /**

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java?rev=774261&r1=774260&r2=774261&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionTest.java
Wed May 13 09:03:17 2009
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.processor;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsOnCompletionTest.java
(from r774235, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsUseOriginalBodyTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsOnCompletionTest.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsOnCompletionTest.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsUseOriginalBodyTest.java&r1=774235&r2=774261&rev=774261&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsUseOriginalBodyTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsOnCompletionTest.java
Wed May 13 09:03:17 2009
@@ -23,30 +23,35 @@
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.builder.DeadLetterChannelBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
+import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * Unit test for useOriginalBody unit test
  */
-public class JmsUseOriginalBodyTest extends ContextTestSupport {
+public class JmsOnCompletionTest extends ContextTestSupport {
+
+    public void testSynchronizeComplete() throws Exception {
+        getMockEndpoint("mock:sync").expectedBodiesReceived("Bye World");
+        getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
 
-    public void testUseOriginalBody() throws Exception {
-        MockEndpoint dead = getMockEndpoint("mock:a");
-        dead.expectedBodiesReceived("Hello");
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Bye World");
 
-        template.sendBody("activemq:queue:a", "Hello");
+        template.sendBody("activemq:queue:start", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
 
-    public void testDoNotUseOriginalBody() throws Exception {
-        MockEndpoint dead = getMockEndpoint("mock:b");
-        dead.expectedBodiesReceived("Hello World");
+    public void testSynchronizeFailure() throws Exception {
+        getMockEndpoint("mock:sync").expectedMessageCount(1);
+        getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
 
-        template.sendBody("activemq:queue:b", "Hello");
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(0);
+
+        template.sendBody("activemq:queue:start", "Kabom");
 
         assertMockEndpointsSatisfied();
     }
@@ -56,35 +61,33 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                // will use original
-                DeadLetterChannelBuilder a = deadLetterChannel("mock:a")
-                    .maximumRedeliveries(2).delay(0).logStackTrace(false).useOriginalBody().handled(true);
-
-                // will NOT use original
-                DeadLetterChannelBuilder b = deadLetterChannel("mock:b")
-                    .maximumRedeliveries(2).delay(0).logStackTrace(false).handled(true);
-
-                from("activemq:queue:a")
-                    .errorHandler(a)
-                    .setBody(body().append(" World"))
-                    .process(new MyThrowProcessor());
-
-                from("activemq:queue:b")
-                    .errorHandler(b)
-                    .setBody(body().append(" World"))
-                    .process(new MyThrowProcessor());
+                // START SNIPPET: e1
+                from("activemq:queue:start")
+                    .onCompletion()
+                        // this route is only invoked when the original route is complete
as a kind
+                        // of completion callback
+                        .to("log:sync")
+                        .to("mock:sync")
+                    // must use end to denote the end of the onCompletion route
+                    .end()
+                    // here the original route contiues
+                    .process(new MyProcessor())
+                    .to("mock:result");
+                // END SNIPPET: e1
             }
         };
     }
 
-    public static class MyThrowProcessor implements Processor {
+    public static class MyProcessor implements Processor {
 
-        public MyThrowProcessor() {
+        public MyProcessor() {
         }
 
         public void process(Exchange exchange) throws Exception {
-            assertEquals("Hello World", exchange.getIn().getBody(String.class));
-            throw new IllegalArgumentException("Forced");
+            if ("Kabom".equals(exchange.getIn().getBody())) {
+                throw new IllegalArgumentException("Kabom");
+            }
+            exchange.getIn().setBody("Bye World");
         }
     }
 

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalBodyTest.java?rev=774261&r1=774260&r2=774261&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalBodyTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionFromChoiceUseOriginalBodyTest.java
Wed May 13 09:03:17 2009
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.spring.processor.onexception;
 
-import org.apache.camel.processor.onexception.OnExceptionFromChoiceUseOriginalBodyTest;
 import org.apache.camel.CamelContext;
+import org.apache.camel.processor.onexception.OnExceptionFromChoiceUseOriginalBodyTest;
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
 /**



Mime
View raw message