Author: davsclaus
Date: Thu Feb 16 07:42:06 2012
New Revision: 1244873

URL: http://svn.apache.org/viewvc?rev=1244873&view=rev
Log:
Added test based on user forum issue

Added:
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
      - copied, changed from r1244841, 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.java
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml
      - copied, changed from r1244841, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml

Copied: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
 (from r1244841, 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.java&r1=1244841&r2=1244873&rev=1244873&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
 Thu Feb 16 07:42:06 2012
@@ -17,13 +17,29 @@
 package org.apache.camel.spring.processor;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.processor.TryProcessorHandledTest;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.FailedToCreateRouteException;
+
 import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringTryProcessorHandledTest extends TryProcessorHandledTest {
+public class SpringTryCatchMustHaveExceptionConfiguredTest extends 
ContextTestSupport {
 
     protected CamelContext createCamelContext() throws Exception {
+        try {
+            CamelContext answer = createSpringCamelContext(this, 
"org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml");
+            fail("Should have thrown exception");
+        } catch (Exception e) {
+            assertIsInstanceOf(FailedToCreateRouteException.class, 
e.getCause());
+            assertIsInstanceOf(IllegalArgumentException.class, 
e.getCause().getCause());
+            assertEquals("At least one Exception must be configured to catch", 
e.getCause().getCause().getMessage());
+        }
+
+        // return a working context instead, to let this test pass
         return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml");
     }
 
+    public void testTryCatchMustHaveExceptionConfigured() {
+        // noop
+    }
+
 }
\ No newline at end of file

Copied: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml
 (from r1244841, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml&r1=1244841&r2=1244873&rev=1244873&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml
 Thu Feb 16 07:42:06 2012
@@ -23,32 +23,15 @@
     ">
 
     <camelContext xmlns="http://camel.apache.org/schema/spring";>
-        <!-- START SNIPPET: e1 -->
         <route>
             <from uri="direct:start"/>
-            <!-- here the try starts. its a try .. catch .. finally just as 
regular java code -->
             <doTry>
-                <process ref="processorFail"/>
                 <to uri="mock:result"/>
                 <doCatch>
-                    <!-- catch IOExcption that we do not want to handle, eg 
the caller should get the error back -->
-                    <exception>java.io.IOException</exception>
-                    <!-- mark this as NOT handled, eg the caller will also get 
the exception -->
-                    <handled>
-                        <constant>false</constant>
-                    </handled>
-                    <to uri="mock:io"/>
-                </doCatch>
-                <doCatch>
-                    <!-- and catch all other exceptions they are handled by 
default (ie handled = true) -->
-                    <exception>java.lang.Exception</exception>
-                    <to uri="mock:error"/>
+                    <to uri="mock:fail"/>
                 </doCatch>
             </doTry>
         </route>
-        <!-- END SNIPPET: e1 -->
     </camelContext>
 
-    <bean id="processorFail" 
class="org.apache.camel.processor.TryProcessorHandledTest$ProcessorFail"/>
-
 </beans>


Reply via email to