camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r981014 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ components/camel-spring/src/test/java/org/apache/camel/spring/config/ components/camel-spring/src/test/resources/org/apache/camel/spring/config/
Date Sat, 31 Jul 2010 07:53:34 GMT
Author: davsclaus
Date: Sat Jul 31 07:53:34 2010
New Revision: 981014

URL: http://svn.apache.org/viewvc?rev=981014&view=rev
Log:
CAMEL-3008: Routes with noAutoStartup will be warmed up and enlisted in JMX.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml

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=981014&r1=981013&r2=981014&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 Sat
Jul 31 07:53:34 2010
@@ -40,7 +40,6 @@ import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.Endpoint;
-import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.FailedToStartRouteException;
 import org.apache.camel.IsSingleton;
 import org.apache.camel.MultipleConsumersSupport;
@@ -128,7 +127,7 @@ public class DefaultCamelContext extends
     private final AtomicInteger endpointKeyCounter = new AtomicInteger();
     private final List<EndpointStrategy> endpointStrategies = new ArrayList<EndpointStrategy>();
     private final Map<String, Component> components = new HashMap<String, Component>();
-    private List<Route> routes;
+    private Set<Route> routes;
     private final List<Service> servicesToClose = new ArrayList<Service>();
     private final Set<StartupListener> startupListeners = new LinkedHashSet<StartupListener>();
     private TypeConverter typeConverter;
@@ -493,7 +492,7 @@ public class DefaultCamelContext extends
 
     public synchronized List<Route> getRoutes() {
         if (routes == null) {
-            routes = new ArrayList<Route>();
+            routes = new LinkedHashSet<Route>();
         }
 
         // lets return a copy of the collection as objects are removed later
@@ -510,8 +509,8 @@ public class DefaultCamelContext extends
         return null;
     }
 
+    @Deprecated
     public void setRoutes(List<Route> routes) {
-        this.routes = routes;
         throw new UnsupportedOperationException("Overriding existing routes is not supported
yet, use addRoutes instead");
     }
 
@@ -523,7 +522,7 @@ public class DefaultCamelContext extends
 
     synchronized void addRouteCollection(Collection<Route> routes) throws Exception
{
         if (this.routes == null) {
-            this.routes = new ArrayList<Route>();
+            this.routes = new LinkedHashSet<Route>();
         }
 
         if (routes != null) {

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java?rev=981014&r1=981013&r2=981014&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
Sat Jul 31 07:53:34 2010
@@ -20,8 +20,6 @@ import junit.framework.TestCase;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spring.SpringCamelContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -30,27 +28,23 @@ import org.springframework.context.suppo
  */
 public class CamelContextAutoStartupTest extends TestCase {
 
-    private static final transient Log LOG = LogFactory.getLog(CamelContextAutoStartupTest.class);
-
     public void testAutoStartupFalse() throws Exception {
         ApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml");
 
         SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel");
         assertEquals("myCamel", camel.getName());
-        assertEquals(false, camel.isStarted());
+        assertEquals(true, camel.isStarted());
         assertEquals(Boolean.FALSE, camel.isAutoStartup());
-        assertEquals(0, camel.getRoutes().size());
+        assertEquals(1, camel.getRoutes().size());
 
-        // now start Camel
-        LOG.info("******** now starting Camel manually *********");
-        camel.start();
+        assertEquals(false, camel.getRouteStatus("foo").isStarted());
+
+        // now starting route manually
+        camel.startRoute("foo");
 
-        // now its started
-        assertEquals(true, camel.isStarted());
-        // but auto startup is still fasle
         assertEquals(Boolean.FALSE, camel.isAutoStartup());
-        // but now we have one route
         assertEquals(1, camel.getRoutes().size());
+        assertEquals(true, camel.getRouteStatus("foo").isStarted());
 
         // and now we can send a message to the route and see that it works
         MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java?rev=981014&r1=981013&r2=981014&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
Sat Jul 31 07:53:34 2010
@@ -34,6 +34,7 @@ import org.springframework.core.io.Class
  * @version $Revision$
  */
 public class CamelContextFactoryBeanTest extends XmlConfigTestSupport {
+
     public void testClassPathRouteLoading() throws Exception {
         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
 
@@ -95,12 +96,14 @@ public class CamelContextFactoryBeanTest
         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
 
         SpringCamelContext context = (SpringCamelContext) applicationContext.getBean("camel4");
-        assertNotNull("No context found!", context);        
-        assertFalse("The context should not start yet", context.isAutoStartup());
-        assertEquals("There should have not route", context.getRoutes().size(), 0);
+        assertFalse(context.isAutoStartup());
+        // there is 1 route but its not started
+        assertEquals(1, context.getRoutes().size());
+
         context = (SpringCamelContext) applicationContext.getBean("camel3");
-        assertTrue("The context should started",  context.isAutoStartup());
-        assertEquals("There should have one route", context.getRoutes().size(), 1);
+        assertTrue(context.isAutoStartup());
+        // there is 1 route but and its started
+        assertEquals(1, context.getRoutes().size());
     }
 
 }

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml?rev=981014&r1=981013&r2=981014&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml
Sat Jul 31 07:53:34 2010
@@ -23,7 +23,7 @@
     ">
 
     <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
-        <route>
+        <route id="foo">
             <from uri="direct:start"/>
             <to uri="mock:result"/>
         </route>



Mime
View raw message