camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1143471 - /camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java
Date Wed, 06 Jul 2011 15:46:46 GMT
Author: davsclaus
Date: Wed Jul  6 15:46:46 2011
New Revision: 1143471

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

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java
      - copied, changed from r1143372, camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemoveTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java (from
r1143372, camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemoveTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemoveTest.java&r1=1143372&r2=1143471&rev=1143471&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemoveTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/RouteRemove2Test.java Wed Jul
 6 15:46:46 2011
@@ -23,32 +23,41 @@ import org.apache.camel.component.mock.M
 /**
  * @version 
  */
-public class RouteRemoveTest extends ContextTestSupport {
+public class RouteRemove2Test extends ContextTestSupport {
 
     public void testRemove() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("A");
-
-        template.sendBody("seda:foo", "A");
-        
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        template.sendBody("seda:foo", "Hello World");
         assertMockEndpointsSatisfied();
 
         assertEquals("Started", context.getRouteStatus("foo").name());
-        assertEquals(1, context.getRoutes().size());
+        assertEquals("Started", context.getRouteStatus("bar").name());
 
-        // must be stopped so we cant remove
-        boolean removed = context.removeRoute("foo");
-        assertFalse(removed);
+        // stop foo route
+        context.stopRoute("foo");
+        assertEquals("Stopped", context.getRouteStatus("foo").name());
+        assertEquals("Started", context.getRouteStatus("bar").name());
 
-        assertEquals(1, context.getRoutes().size());
-        assertEquals("Started", context.getRouteStatus("foo").name());
+        resetMocks();
 
-        // remove route then
-        context.stopRoute("foo");
-        removed = context.removeRoute("foo");
-        assertTrue(removed);
-        assertEquals(0, context.getRoutes().size());
-        assertNull(context.getRouteStatus("foo"));
+        getMockEndpoint("mock:foo").expectedMessageCount(0);
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        template.sendBody("seda:bar", "Hello World");
+        assertMockEndpointsSatisfied();
+
+        // remove foo route and bar should continue to be functional
+        context.removeRoute("foo");
+        assertEquals("There should be no foo route anymore", null, context.getRouteStatus("foo"));
+        assertEquals("Started", context.getRouteStatus("bar").name());
+
+        resetMocks();
+
+        // the bar route should still be started and work
+        getMockEndpoint("mock:foo").expectedMessageCount(0);
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        template.sendBody("seda:bar", "Hello World");
+        assertMockEndpointsSatisfied();
     }
 
     @Override
@@ -56,7 +65,9 @@ public class RouteRemoveTest extends Con
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:foo").routeId("foo").to("log:foo").to("mock:result");
+                from("seda:foo").routeId("foo").to("seda:bar").to("mock:foo");
+
+                from("seda:bar").routeId("bar").to("mock:bar");
             }
         };
     }



Mime
View raw message