Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4837B200B71 for ; Wed, 31 Aug 2016 19:44:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4639A160AB4; Wed, 31 Aug 2016 17:44:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66523160AA7 for ; Wed, 31 Aug 2016 19:44:16 +0200 (CEST) Received: (qmail 64381 invoked by uid 500); 31 Aug 2016 17:44:15 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 64372 invoked by uid 99); 31 Aug 2016 17:44:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2016 17:44:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7A784E0159; Wed, 31 Aug 2016 17:44:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chirino@apache.org To: commits@camel.apache.org Message-Id: <9ae29f321522443aa33e5092ab183e1d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: Fix for CAMEL-10279 - Can't use @ImportResource and configure() in the same SB app. Date: Wed, 31 Aug 2016 17:44:15 +0000 (UTC) archived-at: Wed, 31 Aug 2016 17:44:17 -0000 Repository: camel Updated Branches: refs/heads/master 04fa8fe52 -> 9ac4768ee Fix for CAMEL-10279 - Can't use @ImportResource and configure() in the same SB app. This assumes there is always a RouteBuilder in a SB app. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9ac4768e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9ac4768e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9ac4768e Branch: refs/heads/master Commit: 9ac4768eedacd7ec89cbf7faf80dab35f3154481 Parents: 04fa8fe Author: Hiram Chirino Authored: Wed Aug 31 11:48:09 2016 -0400 Committer: Hiram Chirino Committed: Wed Aug 31 13:43:58 2016 -0400 ---------------------------------------------------------------------- components/camel-spring-boot/pom.xml | 13 +++++++++++++ .../camel/spring/boot/CamelAutoConfiguration.java | 1 + .../fatjarroutertests/JUnitFatJarRouterTest.java | 13 ++++++++++++- .../StandaloneFatJarRouterTest.java | 14 +++++++++++++- .../boot/fatjarroutertests/TestFatJarRouter.java | 2 ++ .../src/test/resources/test-camel-context.xml | 17 +++++++++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml index 4ce1580..86097d4 100644 --- a/components/camel-spring-boot/pom.xml +++ b/components/camel-spring-boot/pom.xml @@ -106,4 +106,17 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + + + + + http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java index d9ed0a0..4ae9308 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java @@ -185,6 +185,7 @@ public class CamelAutoConfiguration { @Bean CamelSpringBootApplicationController applicationController(ApplicationContext applicationContext, CamelContext camelContext) { + SpringCamelContext.setNoStart(true); return new CamelSpringBootApplicationController(applicationContext, camelContext); } http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/JUnitFatJarRouterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/JUnitFatJarRouterTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/JUnitFatJarRouterTest.java index 2c1611c..828bc72 100644 --- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/JUnitFatJarRouterTest.java +++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/JUnitFatJarRouterTest.java @@ -17,7 +17,9 @@ package org.apache.camel.spring.boot.fatjarroutertests; import java.io.IOException; +import java.lang.management.ManagementFactory; import java.net.URL; +import java.util.Set; import org.apache.commons.io.IOUtils; import org.junit.Assert; @@ -28,6 +30,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.SocketUtils; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + @RunWith(SpringRunner.class) @SpringBootTest(classes = TestFatJarRouter.class, properties = "spring.main.sources=org.apache.camel.spring.boot.fatjarroutertests") public class JUnitFatJarRouterTest extends Assert { @@ -40,10 +46,15 @@ public class JUnitFatJarRouterTest extends Assert { } @Test - public void shouldStartCamelRoute() throws InterruptedException, IOException { + public void shouldStartCamelRoute() throws InterruptedException, IOException, MalformedObjectNameException { String response = IOUtils.toString(new URL("http://localhost:" + port)); assertEquals("stringBean", response); + + // There should be 3 routes running.. + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + Set objectNames = mbs.queryNames(new ObjectName("org.apache.camel:type=routes,*"), null); + assertEquals(3, objectNames.size()); } } http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/StandaloneFatJarRouterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/StandaloneFatJarRouterTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/StandaloneFatJarRouterTest.java index 5c6394d..79f3c9e 100644 --- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/StandaloneFatJarRouterTest.java +++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/StandaloneFatJarRouterTest.java @@ -17,8 +17,10 @@ package org.apache.camel.spring.boot.fatjarroutertests; import java.io.IOException; +import java.lang.management.ManagementFactory; import java.net.ConnectException; import java.net.URL; +import java.util.Set; import java.util.concurrent.Callable; import static java.util.concurrent.TimeUnit.MINUTES; @@ -30,12 +32,17 @@ import org.junit.Assert; import org.junit.Test; import org.springframework.util.SocketUtils; +import javax.management.MBeanServer; +import javax.management.MBeanServerConnection; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + import static com.jayway.awaitility.Awaitility.await; public class StandaloneFatJarRouterTest extends Assert { @Test - public void shouldStartCamelRoute() throws InterruptedException, IOException { + public void shouldStartCamelRoute() throws InterruptedException, IOException, MalformedObjectNameException { // Given final int port = SocketUtils.findAvailableTcpPort(20000); final URL httpEndpoint = new URL("http://localhost:" + port); @@ -62,6 +69,11 @@ public class StandaloneFatJarRouterTest extends Assert { // Then assertEquals("stringBean", response); + + // There should be 3 routes running.. + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + Set objectNames = mbs.queryNames(new ObjectName("org.apache.camel:type=routes,*"), null); + assertEquals(3, objectNames.size()); } } http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/TestFatJarRouter.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/TestFatJarRouter.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/TestFatJarRouter.java index ed44d5c..1609f49 100644 --- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/TestFatJarRouter.java +++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/fatjarroutertests/TestFatJarRouter.java @@ -19,8 +19,10 @@ package org.apache.camel.spring.boot.fatjarroutertests; import org.apache.camel.spring.boot.FatJarRouter; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ImportResource; @SpringBootApplication +@ImportResource({"classpath:test-camel-context.xml"}) public class TestFatJarRouter extends FatJarRouter { @Override http://git-wip-us.apache.org/repos/asf/camel/blob/9ac4768e/components/camel-spring-boot/src/test/resources/test-camel-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/test/resources/test-camel-context.xml b/components/camel-spring-boot/src/test/resources/test-camel-context.xml new file mode 100644 index 0000000..a21e380 --- /dev/null +++ b/components/camel-spring-boot/src/test/resources/test-camel-context.xml @@ -0,0 +1,17 @@ + + + + + + + + Hello World from camel-contex.xml + + + + +