camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1143904 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/ camel-core/src/test/java/org/apache/camel...
Date Thu, 07 Jul 2011 16:16:00 GMT
Author: davsclaus
Date: Thu Jul  7 16:15:59 2011
New Revision: 1143904

URL: http://svn.apache.org/viewvc?rev=1143904&view=rev
Log:
CAMEL-4184: Fixed adviceWith 2 or more routes and using a context scoped onException, may
cause the onException to appear route scoped. Tigthten up OnException to be aware of its initial
scope.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesContextScopedOnExceptionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesOnExceptionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesTest.java
      - copied, changed from r1143739, camel/trunk/camel-core/src/test/java/org/apache/camel/issues/AdviceWithIssueTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml
      - copied, changed from r1143739, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/delayerInterceptorTest.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=1143904&r1=1143903&r2=1143904&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
Thu Jul  7 16:15:59 2011
@@ -85,6 +85,8 @@ public class OnExceptionDefinition exten
     private Predicate retryWhilePolicy;
     @XmlTransient
     private Processor onRedelivery;
+    @XmlTransient
+    private Boolean routeScoped;
 
     public OnExceptionDefinition() {
     }
@@ -98,6 +100,11 @@ public class OnExceptionDefinition exten
         exceptionClasses.add(exceptionType);
     }
 
+    public boolean isRouteScoped() {
+        // is context scoped by default
+        return routeScoped != null ? routeScoped : false;
+    }
+
     @Override
     public String getShortName() {
         return "onException";
@@ -138,6 +145,14 @@ public class OnExceptionDefinition exten
     }
 
     public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws
Exception {
+        // assign whether this was a route scoped onException or not
+        // we need to know this later when setting the parent, as only route scoped should
have parent
+        // Note: this logic can possible be removed when the Camel routing engine decides
at runtime
+        // to apply onException in a more dynamic fashion than current code base
+        // and therefore is in a better position to decide among context/route scoped OnException
at runtime
+        if (routeScoped == null) {
+            routeScoped = super.getParent() != null;
+        }
 
         setHandledFromExpressionType(routeContext);
         setContinuedFromExpressionType(routeContext);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java?rev=1143904&r1=1143903&r2=1143904&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
Thu Jul  7 16:15:59 2011
@@ -51,8 +51,14 @@ public abstract class ErrorHandlerSuppor
         List<Class> list = exceptionType.getExceptionClasses();
 
         for (Class clazz : list) {
-            RouteDefinition route = ProcessorDefinitionHelper.getRoute(exceptionType);
-            String routeId = route != null ? route.getId() : null;
+            String routeId = null;
+            // only get the route id, if the exception type is route scoped
+            if (exceptionType.isRouteScoped()) {
+                RouteDefinition route = ProcessorDefinitionHelper.getRoute(exceptionType);
+                if (route != null) {
+                    routeId = route.getId();
+                }
+            }
             ExceptionPolicyKey key = new ExceptionPolicyKey(routeId, clazz, exceptionType.getOnWhen());
             exceptionPolicies.put(key, exceptionType);
         }

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=1143904&r1=1143903&r2=1143904&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
Thu Jul  7 16:15:59 2011
@@ -134,7 +134,7 @@ public class DefaultExceptionPolicyStrat
 
             // 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) {
+            if (exchange != null && exchange.getUnitOfWork() != null && type.isRouteScoped())
{
                 RouteDefinition route = exchange.getUnitOfWork().getRouteContext() != null
? exchange.getUnitOfWork().getRouteContext().getRoute() : null;
                 RouteDefinition typeRoute = ProcessorDefinitionHelper.getRoute(type);
                 if (route != null && typeRoute != null && route != typeRoute)
{

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesContextScopedOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesContextScopedOnExceptionTest.java?rev=1143904&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesContextScopedOnExceptionTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesContextScopedOnExceptionTest.java
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.interceptor;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class AdviceWithTwoRoutesContextScopedOnExceptionTest extends AdviceWithTwoRoutesOnExceptionTest
{
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                    .handled(true)
+                    .to("mock:error");
+
+                from("direct:a").routeId("a")
+                    .to("log:a")
+                    .to("mock:a");
+
+                from("direct:b").routeId("b")
+                    .to("log:b")
+                    .to("mock:b");
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesOnExceptionTest.java?rev=1143904&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesOnExceptionTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesOnExceptionTest.java
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,127 @@
+/**
+ * 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.interceptor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ * @version 
+ */
+public class AdviceWithTwoRoutesOnExceptionTest extends ContextTestSupport {
+
+    public void testAdviceWithA() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("a");
+        route.adviceWith(context, new AdviceWithRouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("mock://a")
+                    .skipSendToOriginalEndpoint()
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        });
+
+        getMockEndpoint("mock:a").expectedMessageCount(0);
+        getMockEndpoint("mock:error").expectedMessageCount(1);
+        getMockEndpoint("mock:error").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:a", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testAdviceWithB() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("b");
+        route.adviceWith(context, new AdviceWithRouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("mock://b")
+                    .skipSendToOriginalEndpoint()
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        });
+
+        getMockEndpoint("mock:b").expectedMessageCount(0);
+        getMockEndpoint("mock:error").expectedMessageCount(1);
+        getMockEndpoint("mock:error").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:b", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testAdviceWithAB() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("a");
+        route.adviceWith(context, new AdviceWithRouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("mock://a")
+                    .skipSendToOriginalEndpoint()
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        });
+
+        route = context.getRouteDefinition("b");
+        route.adviceWith(context, new AdviceWithRouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("mock://b")
+                    .skipSendToOriginalEndpoint()
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        });
+
+        getMockEndpoint("mock:a").expectedMessageCount(0);
+        getMockEndpoint("mock:b").expectedMessageCount(0);
+        getMockEndpoint("mock:error").expectedMessageCount(2);
+        getMockEndpoint("mock:error").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+        getMockEndpoint("mock:error").message(1).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:a", "Hello World");
+        template.sendBody("direct:b", "Bye World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:a").routeId("a")
+                    .onException(Exception.class)
+                        .handled(true)
+                        .to("mock:error")
+                    .end()
+                    .to("log:a")
+                    .to("mock:a");
+
+                from("direct:b").routeId("b")
+                        .onException(Exception.class)
+                            .handled(true)
+                            .to("mock:error")
+                        .end()
+                    .to("log:b")
+                    .to("mock:b");
+            }
+        };
+    }
+
+}

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesTest.java
(from r1143739, camel/trunk/camel-core/src/test/java/org/apache/camel/issues/AdviceWithIssueTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/issues/AdviceWithIssueTest.java&r1=1143739&r2=1143904&rev=1143904&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/AdviceWithIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTwoRoutesTest.java
Thu Jul  7 16:15:59 2011
@@ -14,11 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.issues;
+package org.apache.camel.processor.interceptor;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 import org.apache.camel.builder.AdviceWithRouteBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.RouteDefinition;
@@ -26,106 +24,73 @@ import org.apache.camel.model.RouteDefin
 /**
  * @version 
  */
-public class AdviceWithIssueTest extends ContextTestSupport {
+public class AdviceWithTwoRoutesTest extends ContextTestSupport {
 
-    public void testNoAdvice() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
-        template.sendBody("direct:start", "World");
-        try {
-            template.sendBody("direct:start", "Kaboom");
-            fail("Should have thrown exception");
-        } catch (Exception e) {
-            // expected
-        }
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testAdviceWithErrorHandler() throws Exception {
-        RouteDefinition route = context.getRouteDefinitions().get(0);
-        try {
-            route.adviceWith(context, new AdviceWithRouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    errorHandler(deadLetterChannel("mock:dead"));
-                }
-            });
-            fail("Should have thrown exception");
-        } catch (IllegalArgumentException e) {
-            assertEquals("You can not advice with error handlers. Remove the error handlers
from the route builder.", e.getMessage());
-        }
-    }
-
-    public void testAdviceWithOnException() throws Exception {
-        RouteDefinition route = context.getRouteDefinitions().get(0);
+    public void testAdviceWithA() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("a");
         route.adviceWith(context, new AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onException(IllegalArgumentException.class)
-                        .handled(true)
-                        .to("mock:error");
+                interceptSendToEndpoint("mock://a")
+                    .skipSendToOriginalEndpoint()
+                    .to("mock:detour");
             }
         });
 
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:error").expectedBodiesReceived("Kaboom");
+        getMockEndpoint("mock:a").expectedMessageCount(0);
+        getMockEndpoint("mock:detour").expectedMessageCount(1);
 
-        template.sendBody("direct:start", "World");
-        template.sendBody("direct:start", "Kaboom");
+        template.sendBody("direct:a", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
 
-    public void testAdviceWithInterceptFrom() throws Exception {
-        RouteDefinition route = context.getRouteDefinitions().get(0);
+    public void testAdviceWithB() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("b");
         route.adviceWith(context, new AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
-                interceptFrom().to("mock:from");
+                interceptSendToEndpoint("mock://b")
+                    .skipSendToOriginalEndpoint()
+                    .to("mock:detour");
             }
         });
 
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:from").expectedBodiesReceived("World");
-        getMockEndpoint("mock:from").expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT,
"direct://start");
+        getMockEndpoint("mock:b").expectedMessageCount(0);
+        getMockEndpoint("mock:detour").expectedMessageCount(1);
 
-        template.sendBody("direct:start", "World");
+        template.sendBody("direct:b", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
 
-    public void testAdviceWithInterceptSendToEndpoint() throws Exception {
-        RouteDefinition route = context.getRouteDefinitions().get(0);
+    public void testAdviceWithAB() throws Exception {
+        RouteDefinition route = context.getRouteDefinition("a");
         route.adviceWith(context, new AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
-                interceptSendToEndpoint("mock:result").to("mock:to");
+                interceptSendToEndpoint("mock://a")
+                    .skipSendToOriginalEndpoint()
+                    .to("mock:detour");
             }
         });
 
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:to").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:to").expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT,
"mock://result");
-
-        template.sendBody("direct:start", "World");
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testAdviceWithOnCompletion() throws Exception {
-        RouteDefinition route = context.getRouteDefinitions().get(0);
+        route = context.getRouteDefinition("b");
         route.adviceWith(context, new AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onCompletion().to("mock:done");
+                interceptSendToEndpoint("mock://b")
+                    .skipSendToOriginalEndpoint()
+                    .to("mock:detour");
             }
         });
 
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:done").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:a").expectedMessageCount(0);
+        getMockEndpoint("mock:b").expectedMessageCount(0);
+        getMockEndpoint("mock:detour").expectedMessageCount(2);
 
-        template.sendBody("direct:start", "World");
+        template.sendBody("direct:a", "Hello World");
+        template.sendBody("direct:b", "Bye World");
 
         assertMockEndpointsSatisfied();
     }
@@ -135,23 +100,16 @@ public class AdviceWithIssueTest extends
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start")
-                    .process(new MyProcessor())
-                    .to("mock:result");
+                from("direct:a").routeId("a")
+                    .to("log:a")
+                    .setBody(body().regexReplaceAll("\n", ""))
+                    .to("mock:a");
+
+                from("direct:b").routeId("b")
+                    .to("log:b")
+                    .to("mock:b");
             }
         };
     }
 
-    private final class MyProcessor implements Processor {
-
-        @Override
-        public void process(Exchange exchange) throws Exception {
-            String body = exchange.getIn().getBody(String.class);
-            if ("Kaboom".equals(body)) {
-                throw new IllegalArgumentException("Kaboom");
-            }
-            exchange.getIn().setBody("Hello " + body);
-        }
-    }
-
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.java?rev=1143904&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.java
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.interceptor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.interceptor.AdviceWithTwoRoutesContextScopedOnExceptionTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringAdviceWithTwoRoutesContextScopedOnExceptionTest extends AdviceWithTwoRoutesContextScopedOnExceptionTest
{
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml");
+    }
+
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java?rev=1143904&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.java
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,34 @@
+/**
+ * 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.interceptor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.interceptor.AdviceWithTwoRoutesOnExceptionTest;
+import org.apache.camel.processor.interceptor.AdviceWithTwoRoutesTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringAdviceWithTwoRoutesOnExceptionTest extends AdviceWithTwoRoutesOnExceptionTest
{
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml");
+    }
+
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.java?rev=1143904&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.java
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.interceptor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.interceptor.AdviceWithTwoRoutesTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringAdviceWithTwoRoutesTest extends AdviceWithTwoRoutesTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml");
+    }
+
+}

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml?rev=1143904&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesContextScopedOnExceptionTest.xml
Thu Jul  7 16:15:59 2011
@@ -0,0 +1,47 @@
+<?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

+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <onException>
+      <exception>java.lang.Exception</exception>
+      <handled>
+        <constant>true</constant>
+      </handled>
+      <to uri="mock:error"/>
+    </onException>
+
+    <route id="a">
+      <from uri="direct:a"/>
+      <to uri="mock:a"/>
+    </route>
+
+    <route id="b">
+      <from uri="direct:b"/>
+      <to uri="mock:b"/>
+    </route>
+
+  </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml?rev=1143904&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesOnExceptionTest.xml
Thu Jul  7 16:15:59 2011
@@ -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

+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <route id="a">
+      <from uri="direct:a"/>
+      <onException>
+        <exception>java.lang.Exception</exception>
+        <handled>
+          <constant>true</constant>
+        </handled>
+        <to uri="mock:error"/>
+      </onException>
+      <to uri="mock:a"/>
+    </route>
+
+    <route id="b">
+      <from uri="direct:b"/>
+      <onException>
+        <exception>java.lang.Exception</exception>
+        <handled>
+          <constant>true</constant>
+        </handled>
+        <to uri="mock:error"/>
+      </onException>
+      <to uri="mock:b"/>
+    </route>
+
+  </camelContext>
+
+</beans>

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml
(from r1143739, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/delayerInterceptorTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/delayerInterceptorTest.xml&r1=1143739&r2=1143904&rev=1143904&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/delayerInterceptorTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/SpringAdviceWithTwoRoutesTest.xml
Thu Jul  7 16:15:59 2011
@@ -22,11 +22,18 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd

     ">
 
-    <camelContext delayer="200" xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="direct:start"/>
-            <to uri="mock:result"/>
-        </route>
-    </camelContext>
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <route id="a">
+      <from uri="direct:a"/>
+      <to uri="mock:a"/>
+    </route>
+
+    <route id="b">
+      <from uri="direct:b"/>
+      <to uri="mock:b"/>
+    </route>
+
+  </camelContext>
 
 </beans>



Mime
View raw message