You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/07/27 18:08:14 UTC

svn commit: r979762 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/processor/exceptionpo...

Author: davsclaus
Date: Tue Jul 27 16:08:13 2010
New Revision: 979762

URL: http://svn.apache.org/viewvc?rev=979762&view=rev
Log:
CAMEL-2972: Fixed issue with route scoped OnException potentially being pickup up from another route.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueReverseTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java   (contents, props changed)
      - copied, changed from r979591, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnException.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnException.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml   (contents, props changed)
      - copied, changed from r979591, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefReverseOnException.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandler.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/FailedToCreateConsumerException.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/FailedToCreateConsumerException.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/FailedToCreateConsumerException.java Tue Jul 27 16:08:13 2010
@@ -31,6 +31,11 @@ public class FailedToCreateConsumerExcep
         this.uri = endpoint.getEndpointUri();
     }
 
+    public FailedToCreateConsumerException(Endpoint endpoint, String message) {
+        super("Failed to create Consumer for endpoint: " + endpoint + ". Reason: " + message);
+        this.uri = endpoint.getEndpointUri();
+    }
+
     public FailedToCreateConsumerException(Endpoint endpoint, String message, Throwable cause) {
         super("Failed to create Consumer for endpoint: " + endpoint + ". Reason: " + message, cause);
         this.uri = endpoint.getEndpointUri();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java Tue Jul 27 16:08:13 2010
@@ -54,6 +54,9 @@ public class DefaultUnitOfWork implement
     private final Stack<RouteContext> routeContextStack = new Stack<RouteContext>();
 
     public DefaultUnitOfWork(Exchange exchange) {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("UnitOfWork created for ExchangeId: " + exchange.getExchangeId() + " with " + exchange);
+        }
         tracedRouteNodes = new DefaultTracedRouteNodes();
 
         // TODO: the copy on facade strategy will help us here in the future
@@ -132,7 +135,7 @@ public class DefaultUnitOfWork implement
 
             if (handover) {
                 if (LOG.isTraceEnabled()) {
-                    LOG.trace("Handover synchronization " + synchronization + " to Exchange: " + target);
+                    LOG.trace("Handover synchronization " + synchronization + " to: " + target);
                 }
                 target.addOnCompletion(synchronization);
                 // remove it if its handed over
@@ -147,6 +150,10 @@ public class DefaultUnitOfWork implement
 
     @SuppressWarnings("unchecked")
     public void done(Exchange exchange) {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("UnitOfWork done for ExchangeId: " + exchange.getExchangeId() + " with " + exchange);
+        }
+
         boolean failed = exchange.isFailed();
 
         // fire event to signal the exchange is done
@@ -170,8 +177,14 @@ public class DefaultUnitOfWork implement
             for (Synchronization synchronization : synchronizations) {
                 try {
                     if (failed) {
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("Invoking synchronization.onFailure: " + synchronization + " with " + exchange);
+                        }
                         synchronization.onFailure(exchange);
                     } else {
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("Invoking synchronization.onComplete: " + synchronization + " with " + exchange);
+                        }
                         synchronization.onComplete(exchange);
                     }
                 } catch (Exception e) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java Tue Jul 27 16:08:13 2010
@@ -61,8 +61,8 @@ import static org.apache.camel.util.Obje
  * Implements the Multicast pattern to send a message exchange to a number of
  * endpoints, each endpoint receiving a copy of the message exchange.
  *
- * @see Pipeline
  * @version $Revision$
+ * @see Pipeline
  */
 public class MulticastProcessor extends ServiceSupport implements AsyncProcessor, Navigate<Processor>, Traceable {
 
@@ -130,7 +130,7 @@ public class MulticastProcessor extends 
     public MulticastProcessor(CamelContext camelContext, Collection<Processor> processors, AggregationStrategy aggregationStrategy) {
         this(camelContext, processors, aggregationStrategy, false, null, false, false);
     }
-    
+
     public MulticastProcessor(CamelContext camelContext, Collection<Processor> processors, AggregationStrategy aggregationStrategy,
                               boolean parallelProcessing, ExecutorService executorService, boolean streaming, boolean stopOnException) {
         notNull(camelContext, "camelContext");
@@ -152,7 +152,7 @@ public class MulticastProcessor extends 
     public String getTraceLabel() {
         return "multicast";
     }
-    
+
     public CamelContext getCamelContext() {
         return camelContext;
     }
@@ -469,10 +469,10 @@ public class MulticastProcessor extends 
      * when using the asynchronous routing engine. And therefore we want the logic in one method instead
      * of being scattered.
      *
-     * @param original      the original exchange
-     * @param subExchange   the current sub exchange, can be <tt>null</tt> for the synchronous part
-     * @param callback      the callback
-     * @param doneSync      the <tt>doneSync</tt> parameter to call on callback
+     * @param original    the original exchange
+     * @param subExchange the current sub exchange, can be <tt>null</tt> for the synchronous part
+     * @param callback    the callback
+     * @param doneSync    the <tt>doneSync</tt> parameter to call on callback
      */
     protected void doDone(Exchange original, Exchange subExchange, AsyncCallback callback, boolean doneSync) {
         // cleanup any per exchange aggregation strategy
@@ -494,7 +494,7 @@ public class MulticastProcessor extends 
      * Aggregate the {@link Exchange} with the current result
      *
      * @param strategy the aggregation strategy to use
-     * @param result the current result
+     * @param result   the current result
      * @param exchange the exchange to be added to the result
      */
     protected synchronized void doAggregate(AggregationStrategy strategy, AtomicExchange result, Exchange exchange) {
@@ -521,8 +521,7 @@ public class MulticastProcessor extends 
 
         int index = 0;
         for (Processor processor : processors) {
-            Exchange copy = exchange.copy();
-            result.add(createProcessorExchangePair(index++, processor, copy));
+            result.add(createProcessorExchangePair(index++, processor, exchange));
         }
 
         return result;
@@ -534,15 +533,18 @@ public class MulticastProcessor extends 
      * You <b>must</b> use this method to create the instances of {@link ProcessorExchangePair} as they
      * need to be specially prepared before use.
      *
-     * @param processor  the processor
-     * @param exchange   the exchange
+     * @param processor the processor
+     * @param exchange  the exchange
      * @return prepared for use
      */
     protected ProcessorExchangePair createProcessorExchangePair(int index, Processor processor, Exchange exchange) {
         Processor prepared = processor;
 
+        // copy exchange, and do not share the unit of work
+        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
+
         // set property which endpoint we send to
-        setToEndpoint(exchange, prepared);
+        setToEndpoint(copy, prepared);
 
         // rework error handling to support fine grained error handling
         if (exchange.getUnitOfWork() != null && exchange.getUnitOfWork().getRouteContext() != null) {
@@ -556,12 +558,14 @@ public class MulticastProcessor extends 
             // instead of using ProcessorDefinition.wrapInErrorHandler)
             try {
                 prepared = builder.createErrorHandler(routeContext, prepared);
+                // and wrap in unit of work processor so the copy exchange also can run under UoW
+                prepared = new UnitOfWorkProcessor(prepared);
             } catch (Exception e) {
                 throw ObjectHelper.wrapRuntimeCamelException(e);
             }
         }
 
-        return new DefaultProcessorExchangePair(index, processor, prepared, exchange);
+        return new DefaultProcessorExchangePair(index, processor, prepared, copy);
     }
 
     protected void doStart() throws Exception {
@@ -594,7 +598,7 @@ public class MulticastProcessor extends 
 
     /**
      * Is the multicast processor working in streaming mode?
-     * 
+     * <p/>
      * In streaming mode:
      * <ul>
      * <li>we use {@link Iterable} to ensure we can send messages as soon as the data becomes available</li>

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java Tue Jul 27 16:08:13 2010
@@ -173,8 +173,7 @@ public class RecipientListProcessor exte
             }
 
             // then create the exchange pair
-            Exchange copy = exchange.copy();
-            result.add(createProcessorExchangePair(index++, endpoint, producer, copy));
+            result.add(createProcessorExchangePair(index++, endpoint, producer, exchange));
         }
 
         return result;
@@ -186,8 +185,11 @@ public class RecipientListProcessor exte
     protected ProcessorExchangePair createProcessorExchangePair(int index, Endpoint endpoint, Producer producer, Exchange exchange) {
         Processor prepared = producer;
 
+        // copy exchange, and do not share the unit of work
+        Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
+
         // set property which endpoint we send to
-        setToEndpoint(exchange, prepared);
+        setToEndpoint(copy, prepared);
 
         // rework error handling to support fine grained error handling
         if (exchange.getUnitOfWork() != null && exchange.getUnitOfWork().getRouteContext() != null) {
@@ -201,12 +203,14 @@ public class RecipientListProcessor exte
             // instead of using ProcessorDefinition.wrapInErrorHandler)
             try {
                 prepared = builder.createErrorHandler(routeContext, prepared);
+                // and wrap in unit of work processor so the copy exchange also can run under UoW
+                prepared = new UnitOfWorkProcessor(prepared);
             } catch (Exception e) {
                 throw ObjectHelper.wrapRuntimeCamelException(e);
             }
         }
 
-        return new RecipientProcessorExchangePair(index, producerCache, endpoint, producer, prepared, exchange);
+        return new RecipientProcessorExchangePair(index, producerCache, endpoint, producer, prepared, copy);
     }
 
     protected static Endpoint resolveEndpoint(Exchange exchange, Object recipient) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java Tue Jul 27 16:08:13 2010
@@ -35,6 +35,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.processor.aggregate.UseOriginalAggregationStrategy;
 import org.apache.camel.util.CollectionHelper;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
@@ -183,6 +184,9 @@ public class Splitter extends MulticastP
     @Override
     protected void updateNewExchange(Exchange exchange, int index, Iterable<ProcessorExchangePair> allPairs,
                                      Iterator<ProcessorExchangePair> it) {
+        // do not share unit of work
+        exchange.setUnitOfWork(null);
+
         exchange.setProperty(Exchange.SPLIT_INDEX, index);
         if (allPairs instanceof Collection) {
             exchange.setProperty(Exchange.SPLIT_SIZE, ((Collection<?>)allPairs).size());

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java Tue Jul 27 16:08:13 2010
@@ -23,6 +23,8 @@ import java.util.TreeMap;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.model.OnExceptionDefinition;
+import org.apache.camel.model.ProcessorDefinitionHelper;
+import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -85,8 +87,8 @@ public class DefaultExceptionPolicyStrat
 
 
     private boolean findMatchedExceptionPolicy(Map<ExceptionPolicyKey, OnExceptionDefinition> exceptionPolicies,
-                                                             Exchange exchange, Throwable exception,
-                                                             Map<Integer, OnExceptionDefinition> candidates) {
+                                               Exchange exchange, Throwable exception,
+                                               Map<Integer, OnExceptionDefinition> candidates) {
         if (LOG.isTraceEnabled()) {
             LOG.trace("Finding best suited exception policy for thrown exception " + exception.getClass().getName());
         }
@@ -104,6 +106,19 @@ public class DefaultExceptionPolicyStrat
             Class<?> clazz = entry.getKey().getExceptionClass();
             OnExceptionDefinition type = entry.getValue();
 
+            // if OnException is route scoped then the current route (Exchange) must match
+            // so we will not pick an OnException from another route
+            if (exchange != null && exchange.getUnitOfWork() != null) {
+                RouteDefinition route = exchange.getUnitOfWork().getRouteContext() != null ? exchange.getUnitOfWork().getRouteContext().getRoute() : null;
+                RouteDefinition typeRoute = ProcessorDefinitionHelper.getRoute(type);
+                if (route != null && typeRoute != null && route != typeRoute) {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("The type is scoped for route: " + typeRoute.getId() + " however Exchange is at route: " + route.getId());
+                    }
+                    continue;
+                }
+            }
+
             if (filter(type, clazz, exception)) {
 
                 // must match

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueReverseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueReverseTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueReverseTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueReverseTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,68 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class OnExceptionAndDLCErrorHandlerIssueReverseTest extends ContextTestSupport {
+
+    public void testNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:foo").routeId("foo")
+                    .to("mock:foo")
+                    .throwException(new IllegalArgumentException("Damn"));
+
+                from("direct:bar").routeId("bar")
+                    .onException(IllegalArgumentException.class)
+                        .handled(true)
+                        .to("mock:handled")
+                    .end()
+                    .to("mock:bar")
+                    .throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionAndDLCErrorHandlerIssueTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,68 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class OnExceptionAndDLCErrorHandlerIssueTest extends ContextTestSupport {
+
+    public void testNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:bar").routeId("bar")
+                    .onException(IllegalArgumentException.class)
+                        .handled(true)
+                        .to("mock:handled")
+                    .end()
+                    .to("mock:bar")
+                    .throwException(new IllegalArgumentException("Damn"));
+
+                from("direct:foo").routeId("foo")
+                    .to("mock:foo")
+                    .throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,74 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class OnExceptionGlobalAndDLCErrorHandlerIssueReverseTest extends ContextTestSupport {
+
+    public void testNoOnGlobalException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:global").expectedMessageCount(1);
+        getMockEndpoint("mock:local").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOnRouteException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:global").expectedMessageCount(0);
+        getMockEndpoint("mock:local").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                onException(Exception.class)
+                    .handled(true)
+                    .to("mock:global");
+
+                from("direct:foo").routeId("foo")
+                    .to("mock:foo")
+                    .throwException(new IllegalArgumentException("Damn"));
+
+                from("direct:bar").routeId("bar")
+                    .onException(IllegalArgumentException.class)
+                        .handled(true)
+                        .to("mock:local")
+                    .end()
+                    .to("mock:bar")
+                    .throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalAndDLCErrorHandlerIssueTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,74 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class OnExceptionGlobalAndDLCErrorHandlerIssueTest extends ContextTestSupport {
+
+    public void testNoOnGlobalException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:global").expectedMessageCount(1);
+        getMockEndpoint("mock:local").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOnRouteException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:global").expectedMessageCount(0);
+        getMockEndpoint("mock:local").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                onException(Exception.class)
+                    .handled(true)
+                    .to("mock:global");
+
+                from("direct:bar").routeId("bar")
+                    .onException(IllegalArgumentException.class)
+                        .handled(true)
+                        .to("mock:local")
+                    .end()
+                    .to("mock:bar")
+                    .throwException(new IllegalArgumentException("Damn"));
+
+                from("direct:foo").routeId("foo")
+                    .to("mock:foo")
+                    .throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+}

Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java?rev=979762&r1=979761&r2=979762&view=diff
==============================================================================
--- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java Tue Jul 27 16:08:13 2010
@@ -273,6 +273,9 @@ public abstract class AbstractCamelConte
         // using route builders. So we have here a little custom code to fix the JAXB gaps
         for (RouteDefinition route : getRoutes()) {
 
+            // at first init the parent
+            initParent(route);
+
             // abstracts is the cross cutting concerns
             List<ProcessorDefinition> abstracts = new ArrayList<ProcessorDefinition>();
 
@@ -295,11 +298,8 @@ public abstract class AbstractCamelConte
 
             // rebuild route as upper + lower
             route.clearOutput();
-            route.getOutputs().addAll(upper);
             route.getOutputs().addAll(lower);
-
-            // configure parents
-            initParent(route);
+            route.getOutputs().addAll(0, upper);
         }
 
         if (getDataFormats() != null) {
@@ -356,6 +356,10 @@ public abstract class AbstractCamelConte
         // add global on exceptions if any
         List<OnExceptionDefinition> onExceptions = getOnExceptions();
         if (onExceptions != null && !onExceptions.isEmpty()) {
+            // init the parent
+            for (OnExceptionDefinition global : onExceptions) {
+                initParent(global);
+            }
             abstracts.addAll(onExceptions);
         }
 
@@ -373,6 +377,8 @@ public abstract class AbstractCamelConte
         // configure intercept
         for (InterceptDefinition intercept : getIntercepts()) {
             intercept.afterPropertiesSet();
+            // init the parent
+            initParent(intercept);
             // add as first output so intercept is handled before the actual route and that gives
             // us the needed head start to init and be able to intercept all the remaining processing steps
             upper.add(0, intercept);
@@ -395,6 +401,8 @@ public abstract class AbstractCamelConte
 
             if (match) {
                 intercept.afterPropertiesSet();
+                // init the parent
+                initParent(intercept);
                 // add as first output so intercept is handled before the actual route and that gives
                 // us the needed head start to init and be able to intercept all the remaining processing steps
                 upper.add(0, intercept);
@@ -404,6 +412,8 @@ public abstract class AbstractCamelConte
         // configure intercept send to endpoint
         for (InterceptSendToEndpointDefinition intercept : getInterceptSendToEndpoints()) {
             intercept.afterPropertiesSet();
+            // init the parent
+            initParent(intercept);
             // add as first output so intercept is handled before the actual route and that gives
             // us the needed head start to init and be able to intercept all the remaining processing steps
             upper.add(0, intercept);
@@ -423,6 +433,10 @@ public abstract class AbstractCamelConte
         // only add global onCompletion if there are no route already
         if (completions.isEmpty()) {
             completions = getOnCompletions();
+            // init the parent
+            for (OnCompletionDefinition global : completions) {
+                initParent(global);
+            }
         }
 
         // are there any completions to init at all?

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandlerTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandlerTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class OneRouteRefOnExceptionAndDLCErrorHandlerTest extends SpringTestSupport {
+
+    public void testOneRouteRefNoOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOneRouteRefOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,54 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class OneRouteRefOnExceptionAndTwoDLCErrorHandlerTest extends SpringTestSupport {
+
+    public void testOneRouteRefNoOnExceptionAndTwoDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:dead2").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOneRouteRefOnExceptionAndTwoDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:dead2").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefOnExceptionTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class OneRouteRefOnExceptionTest extends SpringTestSupport {
+
+    public void testOneRouteRefNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:foo", "Hello World");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Damn", e.getCause().getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOneRouteRefOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OneRouteRefOnException.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class OneRouteRefReverseOnExceptionAndDLCErrorHandlerTest extends SpringTestSupport {
+
+    public void testOneRouteRefReverseNoOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOneRouteRefReverseOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class OneRouteRefReverseOnExceptionTest extends SpringTestSupport {
+
+    public void testOneRouteRefReverseNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:foo", "Hello World");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Damn", e.getCause().getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testOneRouteRefReverseOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/OneRouteRefReverseOnException.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandlerTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandlerTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class TwoRouteRefOnExceptionAndDLCErrorHandlerTest extends SpringTestSupport {
+
+    public void testTwoRouteRefNoOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testTwoRouteRefOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml");
+    }
+}

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java (from r979591, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefTest.java&r1=979591&r2=979762&rev=979762&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java Tue Jul 27 16:08:13 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.spring.config;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.spring.SpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -23,26 +24,34 @@ import org.springframework.context.suppo
 /**
  * @version $Revision$
  */
-public class RouteRefTest extends SpringTestSupport {
+public class TwoRouteRefOnExceptionTest extends SpringTestSupport {
 
-    public void testRouteRefInside() throws Exception {
-        getMockEndpoint("mock:inside").expectedMessageCount(1);
-
-        template.sendBody("direct:inside", "Hello World");
+    public void testTwoRouteRefNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:foo", "Hello World");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Damn", e.getCause().getMessage());
+        }
 
         assertMockEndpointsSatisfied();
     }
 
-    public void testRouteRefOutside() throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(1);
+    public void testTwoRouteRefOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
 
-        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:bar", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
 
     @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteRefTest.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/TwoRouteRefOnException.xml");
     }
 }

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefOnExceptionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class TwoRouteRefReverseOnExceptionAndDLCErrorHandlerTest extends SpringTestSupport {
+
+    public void testTwoRouteRefReverseNoOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testTwoRouteRefReverseOnExceptionAndDLCErrorHandler() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionAndDLCErrorHandler.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionTest.java?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/TwoRouteRefReverseOnExceptionTest.java Tue Jul 27 16:08:13 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.config;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 938471 $
+ */
+public class TwoRouteRefReverseOnExceptionTest extends SpringTestSupport {
+
+    public void testTwoRouteRefReverseNoOnException() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+
+        try {
+            template.sendBody("direct:foo", "Hello World");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("Damn", e.getCause().getMessage());
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testTwoRouteRefReverseOnException() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/TwoRouteRefReverseOnException.xml");
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnException.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnException.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnException.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnException.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="oneRoutes" xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+
+        <route id="bar">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <routeContextRef ref="oneRoutes"/>
+    </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndDLCErrorHandler.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="oneRoutes" xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo" errorHandlerRef="dlc">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+
+        <route id="bar" errorHandlerRef="dlc">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <errorHandler id="dlc" deadLetterUri="mock:dead" type="DeadLetterChannel"/>
+        <routeContextRef ref="oneRoutes"/>
+    </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefOnExceptionAndTwoDLCErrorHandler.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="oneRoutes" xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo" errorHandlerRef="dlc2">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+
+        <route id="bar" errorHandlerRef="dlc">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <errorHandler id="dlc" deadLetterUri="mock:dead" type="DeadLetterChannel"/>
+        <errorHandler id="dlc2" deadLetterUri="mock:dead2" type="DeadLetterChannel"/>
+        <routeContextRef ref="oneRoutes"/>
+    </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnException.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnException.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnException.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnException.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="oneRoutes" xmlns="http://camel.apache.org/schema/spring">
+        <route id="bar">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+
+        <route id="foo">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <routeContextRef ref="oneRoutes"/>
+    </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/OneRouteRefReverseOnExceptionAndDLCErrorHandler.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="oneRoutes" xmlns="http://camel.apache.org/schema/spring">
+        <route id="bar" errorHandlerRef="dlc">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+
+        <route id="foo" errorHandlerRef="dlc">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <errorHandler id="dlc" deadLetterUri="mock:dead" type="DeadLetterChannel"/>
+        <routeContextRef ref="oneRoutes"/>
+    </camelContext>
+
+</beans>

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml (from r979591, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefTest.xml&r1=979591&r2=979762&rev=979762&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml Tue Jul 27 16:08:13 2010
@@ -22,25 +22,34 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: e1 -->
-    <routeContext id="myCoolRoute" xmlns="http://camel.apache.org/schema/spring">
-        <route id="cool">
-            <from uri="direct:start"/>
-            <to uri="mock:result"/>
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="fooRoute" xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
         </route>
     </routeContext>
 
-    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
-
-        <!-- refer to a given route context to be included  -->
-        <routeContextRef ref="myCoolRoute"/>
-
-        <!-- we can of course still use routes inside camelContext -->
-        <route id="inside">
-            <from uri="direct:inside"/>
-            <to uri="mock:inside"/>
+    <routeContext id="barRoute" xmlns="http://camel.apache.org/schema/spring">
+        <route id="bar">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
         </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <routeContextRef ref="fooRoute"/>
+        <routeContextRef ref="barRoute"/>
     </camelContext>
-    <!-- END SNIPPET: e1 -->
 
 </beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnException.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml?rev=979762&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/TwoRouteRefOnExceptionAndDLCErrorHandler.xml Tue Jul 27 16:08:13 2010
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <routeContext id="fooRoute" xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo" errorHandlerRef="dlc">
+            <from uri="direct:foo"/>
+            <to uri="mock:foo"/>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <routeContext id="barRoute" xmlns="http://camel.apache.org/schema/spring">
+        <route id="bar" errorHandlerRef="dlc">
+            <from uri="direct:bar"/>
+            <to uri="mock:bar"/>
+            <onException>
+                <exception>java.lang.IllegalArgumentException</exception>
+                <handled><constant>true</constant></handled>
+                <to uri="mock:handled"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+        <errorHandler id="dlc" deadLetterUri="mock:dead" type="DeadLetterChannel"/>
+        <routeContextRef ref="fooRoute"/>
+        <routeContextRef ref="barRoute"/>
+    </camelContext>
+
+</beans>