camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1441905 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/RuntimeConfiguration.java test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java
Date Sun, 03 Feb 2013 12:10:55 GMT
Author: davsclaus
Date: Sun Feb  3 12:10:55 2013
New Revision: 1441905

URL: http://svn.apache.org/viewvc?rev=1441905&view=rev
Log:
CAMEL-5876: Added test and improved javadoc about autoStartup=false on CamelContext.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java?rev=1441905&r1=1441904&r2=1441905&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java Sun Feb
 3 12:10:55 2013
@@ -88,6 +88,10 @@ public interface RuntimeConfiguration {
      * <p/>
      * <b>Important:</b> Currently only routes can be disabled, as {@link CamelContext}s
are always started.
      * <br/>
+     * <b>Note:</b> When setting auto startup <tt>false</tt> on {@link
CamelContext} then that takes precedence
+     * and <i>no</i> routes is started. You would need to start {@link CamelContext}
explicit using
+     * the {@link org.apache.camel.CamelContext#start()} method, to start the context and
the routes.
+     * <p/>
      * Default is <tt>true</tt> to always start up.
      *
      * @param autoStartup whether to start up automatically.

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java?rev=1441905&r1=1441904&r2=1441905&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java
Sun Feb  3 12:10:55 2013
@@ -119,4 +119,40 @@ public class DefaultCamelContextAutoStar
         
         camel.stop();
     }
+
+    public void testAutoStartupFalseRouteOverride() throws Exception {
+        DefaultCamelContext camel = new DefaultCamelContext(new SimpleRegistry());
+        camel.disableJMX();
+        camel.setAutoStartup(false);
+
+        camel.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId("foo").autoStartup(true).to("mock:result");
+            }
+        });
+        camel.start();
+
+        // this is special, when you have auto startup=false on CamelContext, then NO routes
is started
+
+        assertEquals(true, camel.isStarted());
+        assertEquals(1, camel.getRoutes().size());
+        assertEquals(true, camel.getRouteStatus("foo").isStopped());
+        assertEquals(false, camel.getRouteStatus("foo").isStarted());
+
+        // now start camel again, to get it to start the routes
+        camel.start();
+
+        assertEquals(true, camel.getRouteStatus("foo").isStarted());
+
+        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
+        mock.expectedMessageCount(1);
+
+        camel.createProducerTemplate().sendBody("direct:start", "Hello World");
+
+        mock.assertIsSatisfied();
+
+        camel.stop();
+    }
+
 }



Mime
View raw message