camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r881357 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/CamelContext.java main/java/org/apache/camel/impl/DefaultCamelContext.java test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java
Date Tue, 17 Nov 2009 16:25:12 GMT
Author: davsclaus
Date: Tue Nov 17 16:25:12 2009
New Revision: 881357

URL: http://svn.apache.org/viewvc?rev=881357&view=rev
Log:
CAMEL-2184: Added method on CamelContext to get a route def by id so its nicer to use with
adviceWith

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java
      - copied, changed from r881350, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=881357&r1=881356&r2=881357&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Tue Nov 17 16:25:12
2009
@@ -252,6 +252,14 @@
     List<RouteDefinition> getRouteDefinitions();
 
     /**
+     * Gets the route definition with the given id
+     *
+     * @param id id of the route
+     * @return the route definition or <tt>null</tt> if not found
+     */
+    RouteDefinition getRouteDefinition(String id);
+
+    /**
      * Returns the current routes in this context
      *
      * @return the current routes

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=881357&r1=881356&r2=881357&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Tue
Nov 17 16:25:12 2009
@@ -779,6 +779,15 @@
         return routeDefinitions;
     }
 
+    public RouteDefinition getRouteDefinition(String id) {
+        for (RouteDefinition route : routeDefinitions) {
+            if (route.getId().equals(id)) {
+                return route;
+            }
+        }
+        return null;
+    }
+
     public List<InterceptStrategy> getInterceptStrategies() {
         return interceptStrategies;
     }

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java
(from r881350, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java&r1=881350&r2=881357&rev=881357&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithRouteIdTest.java
Tue Nov 17 16:25:12 2009
@@ -16,25 +16,15 @@
  */
 package org.apache.camel.processor.interceptor;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version $Revision$
  */
-public class AdviceWithTest extends ContextTestSupport {
-
-    public void testNoAdvised() throws Exception {
-        getMockEndpoint("mock:foo").expectedMessageCount(1);
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-
-        template.sendBody("direct:start", "Hello World");
-
-        assertMockEndpointsSatisfied();
-    }
+public class AdviceWithRouteIdTest extends AdviceWithTest {
 
     public void testAdvised() throws Exception {
-        context.getRouteDefinitions().get(0).adviceWith(new RouteBuilder() {
+        context.getRouteDefinition("myRoute").adviceWith(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 interceptSendToEndpoint("mock:foo")
@@ -58,8 +48,10 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("mock:foo").to("mock:result");
+                from("direct:start").routeId("myRoute").to("mock:foo").to("mock:result");
+
+                from("direct:bar").to("mock:bar");
             }
         };
     }
-}
+}
\ No newline at end of file



Mime
View raw message