You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2015/06/02 16:57:48 UTC

[1/2] camel git commit: CAMEL-8801 Make spring-boot auto-configuration defer to existing beans

Repository: camel
Updated Branches:
  refs/heads/master f91155ed8 -> 803cf77d6


CAMEL-8801 Make spring-boot auto-configuration defer to existing beans


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/89da3536
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/89da3536
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/89da3536

Branch: refs/heads/master
Commit: 89da35368e75f7b18172444a79b5bb2067b9f36c
Parents: 5e10eba
Author: Chris Pimlott <ch...@spartansoftwareinc.com>
Authored: Tue May 26 12:10:27 2015 -0700
Committer: Chris Pimlott <ch...@spartansoftwareinc.com>
Committed: Fri May 29 16:31:27 2015 -0700

----------------------------------------------------------------------
 .../spring/boot/CamelAutoConfiguration.java     |  3 +
 .../boot/CamelNonInvasiveCamelContextTest.java  | 83 ++++++++++++++++++++
 .../src/test/resources/externalCamelContext.xml | 19 +++++
 3 files changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/89da3536/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 0f444ac..9034f09 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
@@ -43,6 +43,7 @@ public class CamelAutoConfiguration {
      * context.
      */
     @Bean
+    @ConditionalOnMissingBean(CamelContext.class)
     CamelContext camelContext(ApplicationContext applicationContext,
                               CamelConfigurationProperties configurationProperties) {
         CamelContext camelContext = new SpringCamelContext(applicationContext);
@@ -75,6 +76,7 @@ public class CamelAutoConfiguration {
      * Default producer template for the bootstrapped Camel context.
      */
     @Bean
+    @ConditionalOnMissingBean(ProducerTemplate.class)
     ProducerTemplate producerTemplate(CamelContext camelContext,
                                       CamelConfigurationProperties configurationProperties) {
         return camelContext.createProducerTemplate(configurationProperties.getProducerTemplateCacheSize());
@@ -84,6 +86,7 @@ public class CamelAutoConfiguration {
      * Default consumer template for the bootstrapped Camel context.
      */
     @Bean
+    @ConditionalOnMissingBean(ConsumerTemplate.class)
     ConsumerTemplate consumerTemplate(CamelContext camelContext,
                                       CamelConfigurationProperties configurationProperties) {
         return camelContext.createConsumerTemplate(configurationProperties.getConsumerTemplateCacheSize());

http://git-wip-us.apache.org/repos/asf/camel/blob/89da3536/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelNonInvasiveCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelNonInvasiveCamelContextTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelNonInvasiveCamelContextTest.java
new file mode 100644
index 0000000..26c8562
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/CamelNonInvasiveCamelContextTest.java
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.annotation.Resource;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.spring.boot.CamelNonInvasiveCamelContextTest.TestApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@EnableAutoConfiguration
+@SpringApplicationConfiguration(classes = { TestApplication.class, CamelNonInvasiveCamelContextTest.class })
+public class CamelNonInvasiveCamelContextTest {
+
+    // Collaborators fixtures
+
+    @Autowired
+    CamelContext camelContext;
+
+    @Autowired
+    ProducerTemplate producerTemplate;
+
+    @Resource(name = "xmlProducerTemplate")
+    ProducerTemplate xmlProducerTemplate;
+
+    @Autowired
+    ConsumerTemplate consumerTemplate;
+
+    @Resource(name = "xmlConsumerTemplate")
+    ConsumerTemplate xmlConsumerTemplate;
+
+    // Tests
+
+    @Test
+    public void shouldUseCamelContextFromXml() {
+        assertNotNull(camelContext);
+        assertEquals("xmlCamelContext", camelContext.getName());
+    }
+
+    @Test
+    public void shouldUseProducerTemplateFromXml() {
+        assertNotNull(producerTemplate);
+        assertEquals(xmlProducerTemplate, producerTemplate);
+    }
+
+    @Test
+    public void shouldUseConsumerTemplateFromXml() {
+        assertNotNull(consumerTemplate);
+        assertEquals(xmlConsumerTemplate, consumerTemplate);
+    }
+
+    @ImportResource(value = { "classpath:externalCamelContext.xml" })
+    public static class TestApplication {
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/89da3536/components/camel-spring-boot/src/test/resources/externalCamelContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/resources/externalCamelContext.xml b/components/camel-spring-boot/src/test/resources/externalCamelContext.xml
new file mode 100644
index 0000000..08f0e5c
--- /dev/null
+++ b/components/camel-spring-boot/src/test/resources/externalCamelContext.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+
+  <camelContext id="xmlCamelContext" xmlns="http://camel.apache.org/schema/spring">
+    <template id="xmlProducerTemplate"/>
+    <consumerTemplate id="xmlConsumerTemplate"/>
+
+    <route>
+      <from uri="direct:input"/>
+      <to uri="mock:output"/>
+    </route>
+  </camelContext>
+
+</beans>


[2/2] camel git commit: Merge branch 'master' of https://github.com/pimlottc/camel

Posted by he...@apache.org.
Merge branch 'master' of https://github.com/pimlottc/camel


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/803cf77d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/803cf77d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/803cf77d

Branch: refs/heads/master
Commit: 803cf77d6de15537ef41e7a2352b8d1c5e91c846
Parents: f91155e 89da353
Author: Henryk Konsek <he...@gmail.com>
Authored: Tue Jun 2 16:52:55 2015 +0200
Committer: Henryk Konsek <he...@gmail.com>
Committed: Tue Jun 2 16:52:55 2015 +0200

----------------------------------------------------------------------
 .../spring/boot/CamelAutoConfiguration.java     |  3 +
 .../boot/CamelNonInvasiveCamelContextTest.java  | 83 ++++++++++++++++++++
 .../src/test/resources/externalCamelContext.xml | 19 +++++
 3 files changed, 105 insertions(+)
----------------------------------------------------------------------