camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1143669 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/DefaultCamelContext.java test/java/org/apache/camel/impl/RouteRemove2Test.java
Date Thu, 07 Jul 2011 06:25:42 GMT
Author: davsclaus
Date: Thu Jul  7 06:25:41 2011
New Revision: 1143669

URL: http://svn.apache.org/viewvc?rev=1143669&view=rev
Log:
CAMEL-4181: Removing a route should remove the route from the internal startup route list
of DefaultCamelContext.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java

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=1143669&r1=1143668&r2=1143669&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 Thu
Jul  7 06:25:41 2011
@@ -819,6 +819,14 @@ public class DefaultCamelContext extends
                 removeRouteDefinition(routeId);
                 ServiceHelper.stopAndShutdownServices(routeService);
                 routeServices.remove(routeId);
+                // remove route from startup order as well, as it was removed
+                Iterator<RouteStartupOrder> it = routeStartupOrder.iterator();
+                while (it.hasNext()) {
+                    RouteStartupOrder order = it.next();
+                    if (order.getRoute().getId().equals(routeId)) {
+                        it.remove();
+                    }
+                }
                 return true;
             } else {
                 return false;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java?rev=1143669&r1=1143668&r2=1143669&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java Thu Jul
 7 06:25:41 2011
@@ -26,6 +26,12 @@ import org.apache.camel.component.mock.M
 public class RouteRemove2Test extends ContextTestSupport {
 
     public void testRemove() throws Exception {
+        DefaultCamelContext defaultContext = (DefaultCamelContext) context;
+        assertEquals("2 routes to start with", 2, context.getRoutes().size());
+        assertEquals("2 routes to start with", 2, context.getRouteDefinitions().size());
+        assertEquals("2 routes to start with", 2, defaultContext.getRouteStartupOrder().size());
+        assertEquals("2 routes to start with", 2, defaultContext.getRouteServices().size());
+
         getMockEndpoint("mock:foo").expectedMessageCount(1);
         getMockEndpoint("mock:bar").expectedMessageCount(1);
         template.sendBody("seda:foo", "Hello World");
@@ -58,6 +64,11 @@ public class RouteRemove2Test extends Co
         getMockEndpoint("mock:bar").expectedMessageCount(1);
         template.sendBody("seda:bar", "Hello World");
         assertMockEndpointsSatisfied();
+
+        assertEquals("1 routes to end with", 1, context.getRoutes().size());
+        assertEquals("1 routes to end with", 1, context.getRouteDefinitions().size());
+        assertEquals("1 routes to end with", 1, defaultContext.getRouteStartupOrder().size());
+        assertEquals("1 routes to end with", 1, defaultContext.getRouteServices().size());
     }
 
     @Override



Mime
View raw message