Author: davsclaus
Date: Thu May 12 06:44:15 2011
New Revision: 1102180
URL: http://svn.apache.org/viewvc?rev=1102180&view=rev
Log:
CAMEL-3960: create per test is now also supported by CamelSpringTestSupport.
Modified:
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Modified:
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java?rev=1102180&r1=1102179&r2=1102180&view=diff
==============================================================================
---
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
(original)
+++
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
Thu May 12 06:44:15 2011
@@ -142,8 +142,11 @@ public abstract class CamelTestSupport e
log.debug("Using created route builder: " + builder);
context.addRoutes(builder);
}
- startCamelContext();
- log.debug("Routing Rules are: " + context.getRoutes());
+ if
(!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
+ startCamelContext();
+ } else {
+ log.info("Skipping starting CamelContext as system property
skipStartingCamelContext is set to be true.");
+ }
} else {
log.debug("Using route builder from the created context: " +
context);
}
Modified:
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java?rev=1102180&r1=1102179&r2=1102180&view=diff
==============================================================================
---
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
(original)
+++
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
Thu May 12 06:44:15 2011
@@ -31,7 +31,7 @@ import org.apache.camel.spring.SpringCam
import org.apache.camel.util.CastUtils;
import org.apache.camel.util.ObjectHelper;
import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
@@ -41,31 +41,33 @@ import org.springframework.context.suppo
* @version
*/
public abstract class CamelSpringTestSupport extends CamelTestSupport {
- protected AbstractApplicationContext applicationContext;
+ protected static AbstractApplicationContext applicationContext;
protected abstract AbstractApplicationContext createApplicationContext();
@Override
- @Before
- public void setUp() throws Exception {
- if
(!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
- // tell camel-spring it should not trigger starting CamelContext,
since we do that later
- // after we are finished setting up the unit test
- System.setProperty("maybeStartCamelContext", "false");
- applicationContext = createApplicationContext();
- assertNotNull("Should have created a valid spring context",
applicationContext);
- super.setUp();
- System.clearProperty("maybeStartCamelContext");
- } else {
- log.info("Skipping starting CamelContext as system property
skipStartingCamelContext is set to be true.");
- }
+ public void doSetUp() throws Exception {
+ applicationContext = createApplicationContext();
+ super.doSetUp();
}
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
+
+ if (!isCreateCamelContextPerClass()) {
+ if (applicationContext != null) {
+ applicationContext.destroy();
+ applicationContext = null;
+ }
+ }
+ }
+
+ @AfterClass
+ public static void tearSpringDownAfterClass() throws Exception {
if (applicationContext != null) {
applicationContext.destroy();
+ applicationContext = null;
}
}
Modified:
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1102180&r1=1102179&r2=1102180&view=diff
==============================================================================
---
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
(original)
+++
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Thu May 12 06:44:15 2011
@@ -178,8 +178,11 @@ public abstract class CamelTestSupport e
log.debug("Using created route builder: " + builder);
context.addRoutes(builder);
}
- startCamelContext();
- log.debug("Routing Rules are: " + context.getRoutes());
+ if
(!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
+ startCamelContext();
+ } else {
+ log.info("Skipping starting CamelContext as system property
skipStartingCamelContext is set to be true.");
+ }
} else {
log.debug("Using route builder from the created context: " +
context);
}