This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.20.x by this push:
     new 244f815  CAMEL-11955: Fixed @RunWith(CamelSpringBoot) to startup 
CamelContext like the other @RunWith runner. It started CamelContext to eager 
before, which causes testing with advice with etc not working.
244f815 is described below

commit 244f8151c2fa3109265dfe039dacd43a94b1349e
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Oct 27 12:54:32 2017 +0200

    CAMEL-11955: Fixed @RunWith(CamelSpringBoot) to startup CamelContext like 
the other @RunWith runner. It started CamelContext to eager before, which 
causes testing with advice with etc not working.
---
 .../org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java | 6 ++++++
 .../apache/camel/test/spring/CamelSpringBootExecutionListener.java | 7 +++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
index ccf2bf0..ef5c3ea 100644
--- 
a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
+++ 
b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
@@ -28,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import static org.junit.Assert.assertFalse;
+
 @RunWith(CamelSpringBootRunner.class)
 @UseAdviceWith
 @SpringBootApplication
@@ -42,6 +44,9 @@ public class AdviceWithTest {
 
     @Test
     public void shouldMockEndpoints() throws Exception {
+        // context should not be started because we enabled @UseAdviceWith
+        assertFalse(camelContext.getStatus().isStarted());
+
         camelContext.getRouteDefinitions().get(0).adviceWith(camelContext, new 
AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
@@ -50,6 +55,7 @@ public class AdviceWithTest {
             }
         });
 
+        // manual start camel
         camelContext.start();
 
         MockEndpoint mock = camelContext.getEndpoint("mock:result", 
MockEndpoint.class);
diff --git 
a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
 
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
index 546462d..ce6253e 100644
--- 
a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
+++ 
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
@@ -39,6 +39,7 @@ public class CamelSpringBootExecutionListener extends 
AbstractTestExecutionListe
         // is added to Spring ApplicationContext, so we set the flag
         // not to start it just yet
         SpringCamelContext.setNoStart(true);
+        System.setProperty("skipStartingCamelContext", "true");
         ConfigurableApplicationContext context = 
(ConfigurableApplicationContext) testContext.getApplicationContext();
 
         // Post CamelContext(s) instantiation but pre CamelContext(s) start 
setup
@@ -47,11 +48,9 @@ public class CamelSpringBootExecutionListener extends 
AbstractTestExecutionListe
         CamelAnnotationsHandler.handleMockEndpoints(context, testClass);
         CamelAnnotationsHandler.handleMockEndpointsAndSkip(context, testClass);
         
CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context,
 testClass);
-        SpringCamelContext.setNoStart(false);
-        CamelContext camelContext = context.getBean(CamelContext.class);
 
-        // after our customizations we should start the CamelContext
-        camelContext.start();
+        System.clearProperty("skipStartingCamelContext");
+        SpringCamelContext.setNoStart(false);
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to