camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r807109 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/processor/ test/java/org/apache/camel/issues/ test/java/org/apache/camel/processor/ test/java/org/apache/camel/processor/onexception/
Date Mon, 24 Aug 2009 07:45:43 GMT
Author: davsclaus
Date: Mon Aug 24 07:45:42 2009
New Revision: 807109

URL: http://svn.apache.org/viewvc?rev=807109&view=rev
Log:
CAMEL-1929: try...catch now also have access to caught exception as exchange property.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java?rev=807109&r1=807108&r2=807109&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java Mon
Aug 24 07:45:42 2009
@@ -121,9 +121,7 @@
                         + " caused by: " + caught.getMessage());
                 }
 
-                if (handled) {
-                    localExchange.removeProperty(Exchange.EXCEPTION_CAUGHT);
-                } else {
+                if (!handled) {
                     // put exception back as it was not handled
                     if (localExchange.getException() == null) {
                         localExchange.setException(localExchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class));

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java?rev=807109&r1=807108&r2=807109&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
Mon Aug 24 07:45:42 2009
@@ -30,7 +30,8 @@
     public void testSplitWithErrorIsHandled() throws Exception {
         MockEndpoint error = getMockEndpoint("mock:error");
         error.expectedBodiesReceived("James");
-        error.message(0).property(Exchange.EXCEPTION_CAUGHT).isNull();
+        error.message(0).property(Exchange.EXCEPTION_CAUGHT).isNotNull();
+        error.message(0).property(Exchange.EXCEPTION_CAUGHT).convertTo(String.class).isEqualTo("This
is a dummy error James!");
 
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedBodiesReceived("Hi Claus", "Hi Willem");

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java?rev=807109&r1=807108&r2=807109&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithMultipleHandlesTest.java
Mon Aug 24 07:45:42 2009
@@ -26,6 +26,8 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
+                context.setTracing(true);
+
                 from("direct:start")
                     .doTry()
                         .process(validator)
@@ -35,7 +37,7 @@
                     .doTry()
                         .process(validator).to("mock:valid")
                     .doCatch(ValidationException.class)
-                        .pipeline("direct:a", "mock:invalid");
+                        .pipeline("seda:a", "mock:invalid");
             }
         };
     }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java?rev=807109&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
Mon Aug 24 07:45:42 2009
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.onexception;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class OnCatchHandledTest extends OnExceptionHandledTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .doTry()
+                        .throwException(new IllegalArgumentException("Forced"))
+                    .doCatch(IllegalArgumentException.class).handled(true)
+                        .to("log:foo?showAll=true").to("mock:handled")
+                    .end();
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnCatchHandledTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java?rev=807109&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
Mon Aug 24 07:45:42 2009
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.onexception;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class OnExceptionHandledTest extends ContextTestSupport {
+
+    public void testHandled() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:handled");
+        mock.expectedBodiesReceived("Hello World");
+        mock.message(0).property(Exchange.EXCEPTION_CAUGHT).isNotNull();
+        mock.message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+        mock.message(0).property(Exchange.EXCEPTION_CAUGHT).convertTo(String.class).isEqualTo("Forced");
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(IllegalArgumentException.class).handled(true)
+                    .to("log:foo?showAll=true").to("mock:handled");
+
+                from("direct:start").throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message