camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-7707: More tests
Date Mon, 01 Sep 2014 10:54:44 GMT
CAMEL-7707: More tests


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3a4822c1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3a4822c1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3a4822c1

Branch: refs/heads/master
Commit: 3a4822c1969810c1acfb68737c314b200cad499c
Parents: 4bcfaac
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Sep 1 12:54:32 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Sep 1 12:54:32 2014 +0200

----------------------------------------------------------------------
 .../camel/issues/OnCompletionIssueTest.java     | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3a4822c1/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
index 98d0fc7..1509753 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.issues;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -27,12 +28,22 @@ public class OnCompletionIssueTest extends ContextTestSupport {
         end.expectedMessageCount(1);
 
         MockEndpoint complete = getMockEndpoint("mock:complete");
-        complete.expectedBodiesReceivedInAnyOrder("finish", "stop", "faulted", "except");
+        complete.expectedBodiesReceivedInAnyOrder("finish", "stop", "ile");
+
+        MockEndpoint failed = getMockEndpoint("mock:failed");
+        failed.expectedBodiesReceivedInAnyOrder("faulted", "npe");
 
         template.sendBody("direct:input", "finish");
         template.sendBody("direct:input", "stop");
         template.sendBody("direct:input", "fault");
-        template.sendBody("direct:input", "except");
+        template.sendBody("direct:input", "ile");
+
+        try {
+            template.sendBody("direct:input", "npe");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            assertEquals("Darn NPE", e.getCause().getMessage());
+        }
 
         setAssertPeriod(2000);
 
@@ -44,12 +55,16 @@ public class OnCompletionIssueTest extends ContextTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onCompletion().parallelProcessing()
+                onCompletion().onFailureOnly().parallelProcessing()
+                    .log("failing ${body}")
+                    .to("mock:failed");
+
+                onCompletion().onCompleteOnly().parallelProcessing()
                     .log("completing ${body}")
                     .to("mock:complete");
 
                 from("direct:input")
-                    .onException(Exception.class)
+                    .onException(IllegalArgumentException.class)
                         .handled(true)
                     .end()
                     .choice()
@@ -59,9 +74,12 @@ public class OnCompletionIssueTest extends ContextTestSupport {
                         .when(simple("${body} == 'fault'"))
                             .log("faulting")
                             .setFaultBody(constant("faulted"))
-                        .when(simple("${body} == 'except'"))
+                        .when(simple("${body} == 'ile'"))
+                            .log("excepting")
+                            .throwException(new IllegalArgumentException("Exception requested"))
+                        .when(simple("${body} == 'npe'"))
                             .log("excepting")
-                            .throwException(new Exception("Exception requested"))
+                            .throwException(new NullPointerException("Darn NPE"))
                         .end()
                         .log("finishing")
                         .to("mock:end");


Mime
View raw message