You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/11/21 08:31:42 UTC

svn commit: r719524 - in /activemq/camel/trunk/components/camel-spring/src: main/java/org/apache/camel/spring/ test/java/org/apache/camel/spring/config/ test/resources/org/apache/camel/spring/

Author: ningjiang
Date: Thu Nov 20 23:31:42 2008
New Revision: 719524

URL: http://svn.apache.org/viewvc?rev=719524&view=rev
Log:
CAMEL-1049 Applied patch with thanks to Andreas

Modified:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=719524&r1=719523&r2=719524&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Thu Nov 20 23:31:42 2008
@@ -436,6 +436,13 @@
         this.errorHandlerRef = errorHandlerRef;
     }
 
+    public Boolean getShouldStartContext() {
+        return shouldStartContext;
+    }
+
+    public void setShouldStartContext(Boolean shouldStartContext) {
+        this.shouldStartContext = shouldStartContext;
+    }
 
     // Implementation methods
     // -------------------------------------------------------------------------

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java?rev=719524&r1=719523&r2=719524&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java Thu Nov 20 23:31:42 2008
@@ -23,6 +23,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.camel.spring.SpringCamelContext;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -80,4 +81,17 @@
             assertEndpointUri(key, "seda:test.c");
         }
     }
+
+    public void testShouldStartContext() throws Exception {
+        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.getShouldStartContext());
+        assertEquals("There should have not route", context.getRoutes().size(), 0);
+        context = (SpringCamelContext) applicationContext.getBean("camel3");
+        assertTrue("The context should started",  context.getShouldStartContext());
+        assertEquals("There should have one route", context.getRoutes().size(), 1);
+    }
+
 }

Modified: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml?rev=719524&r1=719523&r2=719524&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml Thu Nov 20 23:31:42 2008
@@ -42,4 +42,11 @@
     <package>org.apache.camel.spring.example</package>
   </camelContext>
   <!-- END SNIPPET: example3 -->
+  
+  <!-- START SNIPPET: example4 -->
+  <camelContext id="camel4" xmlns="http://activemq.apache.org/camel/schema/spring" shouldStartContext="false">
+    <package>org.apache.camel.spring.example</package>
+  </camelContext>
+  <!-- END SNIPPET: example3 -->
+  
 </beans>