camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1058879 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/test/java/org/apache/camel/spring/config/ components/camel-spring/src/test/resources/org/apache/camel/spring/config/
Date Fri, 14 Jan 2011 07:47:00 GMT
Author: davsclaus
Date: Fri Jan 14 07:46:59 2011
New Revision: 1058879

URL: http://svn.apache.org/viewvc?rev=1058879&view=rev
Log:
CAMEL-3541: OnException should require at least one exception class has been set.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java
      - copied, changed from r1058855, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml
      - copied, changed from r1058855, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=1058879&r1=1058878&r2=1058879&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
Fri Jan 14 07:46:59 2011
@@ -54,21 +54,21 @@ import static org.apache.camel.builder.P
 @XmlAccessorType(XmlAccessType.FIELD)
 public class OnExceptionDefinition extends ProcessorDefinition<OnExceptionDefinition>
{
 
-    @XmlElement(name = "exception")
+    @XmlElement(name = "exception", required = true)
     private List<String> exceptions = new ArrayList<String>();
-    @XmlElement(name = "onWhen", required = false)
+    @XmlElement(name = "onWhen")
     private WhenDefinition onWhen;
-    @XmlElement(name = "retryWhile", required = false)
+    @XmlElement(name = "retryWhile")
     private ExpressionSubElementDefinition retryWhile;
-    @XmlElement(name = "redeliveryPolicy", required = false)
+    @XmlElement(name = "redeliveryPolicy")
     private RedeliveryPolicyDefinition redeliveryPolicy;
-    @XmlElement(name = "handled", required = false)
+    @XmlElement(name = "handled")
     private ExpressionSubElementDefinition handled;
-    @XmlElement(name = "continued", required = false)
+    @XmlElement(name = "continued")
     private ExpressionSubElementDefinition continued;
-    @XmlAttribute(name = "onRedeliveryRef", required = false)
+    @XmlAttribute(name = "onRedeliveryRef")
     private String onRedeliveryRef;
-    @XmlAttribute(name = "useOriginalMessage", required = false)
+    @XmlAttribute(name = "useOriginalMessage")
     private Boolean useOriginalMessagePolicy;
     @XmlElementRef
     private List<ProcessorDefinition> outputs = new ArrayList<ProcessorDefinition>();
@@ -169,7 +169,12 @@ public class OnExceptionDefinition exten
             handle = handled.createPredicate(routeContext);
         }
 
-        return new CatchProcessor(getExceptionClasses(), childProcessor, when, handle);
+        List<Class> exceptions = getExceptionClasses();
+        if (exceptions.isEmpty()) {
+            throw new IllegalArgumentException("At least one exception must be configured
on " + this);
+        }
+
+        return new CatchProcessor(exceptions, childProcessor, when, handle);
     }
 
     // Fluent API

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java?rev=1058879&r1=1058878&r2=1058879&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
Fri Jan 14 07:46:59 2011
@@ -31,6 +31,7 @@ public class ErrorHandlerCamelContextRef
     protected void setUp() throws Exception {
         try {
             super.setUp();
+            fail("Should have thrown an exception");
         } catch (RuntimeCamelException e) {
             FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class,
e.getCause());
             IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class,
cause.getCause());

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java
(from r1058855, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java&r1=1058855&r2=1058879&rev=1058879&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java
Fri Jan 14 07:46:59 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.spring.config;
 
-import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spring.SpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -25,22 +23,21 @@ import org.springframework.context.suppo
 /**
  * @version $Revision$
  */
-public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport {
+public class OnExceptionNoExceptionConfiguredTest extends SpringTestSupport {
 
     @Override
     protected void setUp() throws Exception {
         try {
             super.setUp();
-        } catch (RuntimeCamelException e) {
-            FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class,
e.getCause());
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class,
cause.getCause());
-            assertEquals("ErrorHandlerBuilder with id foo not found in registry.", iae.getMessage());
+            fail("Should have thrown an exception");
+        } catch (Exception e) {
+            // expected
         }
     }
 
     @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml");
     }
     
     public void testDummy() {

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml
(from r1058855, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml&r1=1058855&r2=1058879&rev=1058879&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.xml
Fri Jan 14 07:46:59 2011
@@ -22,15 +22,20 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <camelContext errorHandlerRef="foo" xmlns="http://camel.apache.org/schema/spring">
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+        <onException>
+            <handled>
+                <constant>true</constant>
+            </handled>
+            <to uri="mock:error"/>
+        </onException>
+
         <route>
             <from uri="seda:a"/>
             <to uri="seda:b"/>
         </route>
-        <route>
-            <from uri="direct:c"/>
-            <to uri="direct:d"/>
-        </route>
+
     </camelContext>
 
 </beans>



Mime
View raw message