camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8498 CamelContextFactoryBean missing setEndpoints method
Date Tue, 17 Mar 2015 07:04:41 GMT
Repository: camel
Updated Branches:
  refs/heads/master 245b41126 -> 676ad3324


CAMEL-8498 CamelContextFactoryBean missing setEndpoints method


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

Branch: refs/heads/master
Commit: d1f7154709addbc8bb040735171c7e13139b6dbf
Parents: 245b411
Author: Keith Babo <kbabo@redhat.com>
Authored: Mon Mar 16 17:46:04 2015 -0400
Committer: Keith Babo <kbabo@redhat.com>
Committed: Mon Mar 16 17:46:04 2015 -0400

----------------------------------------------------------------------
 components/camel-spring/pom.xml                 |  6 +++
 .../camel/spring/CamelContextFactoryBean.java   |  4 ++
 .../spring/CamelContextFactoryBeanTest.java     | 43 ++++++++++++++++++++
 .../META-INF/spring/context-with-endpoint.xml   | 28 +++++++++++++
 4 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d1f71547/components/camel-spring/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/pom.xml b/components/camel-spring/pom.xml
index 1e83875..00958e2 100644
--- a/components/camel-spring/pom.xml
+++ b/components/camel-spring/pom.xml
@@ -166,6 +166,12 @@
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <version>${xmlunit-version}</version>
+      <scope>test</scope>
+    </dependency>
 
       <!-- for testing Spring AOP at class level -->
       <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f71547/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index a93f61c..1c02e5f 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -426,6 +426,10 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
         return endpoints;
     }
 
+    public void setEndpoints(List<CamelEndpointFactoryBean> endpoints) {
+        this.endpoints = endpoints;
+    }
+
     public List<CamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies() {
         return redeliveryPolicies;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f71547/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
index cbfff08..6119d56 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
@@ -16,11 +16,22 @@
  */
 package org.apache.camel.spring;
 
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+
 import junit.framework.TestCase;
 
 import org.apache.camel.impl.ActiveMQUuidGenerator;
 import org.apache.camel.impl.SimpleUuidGenerator;
 import org.apache.camel.spi.UuidGenerator;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
 import org.springframework.context.support.StaticApplicationContext;
 
 /**
@@ -56,4 +67,36 @@ public class CamelContextFactoryBeanTest extends TestCase {
         
         assertTrue(uuidGenerator instanceof SimpleUuidGenerator);
     }
+
+    public void testSetEndpoints() throws Exception {
+        // Create a new Camel context and add an endpoint
+        CamelContextFactoryBean camelContext = new CamelContextFactoryBean();
+        List<CamelEndpointFactoryBean> endpoints = new LinkedList<CamelEndpointFactoryBean>();
+        CamelEndpointFactoryBean endpoint = new CamelEndpointFactoryBean();
+        endpoint.setId("endpoint1");
+        endpoint.setUri("mock:end");
+        endpoints.add(endpoint);
+        camelContext.setEndpoints(endpoints);
+
+        // Compare the new context with our reference context
+        Reader expectedContext = null;
+        try {
+            expectedContext = new InputStreamReader(getClass().getResourceAsStream(
+                    "/META-INF/spring/context-with-endpoint.xml"));
+            String createdContext = contextAsString(camelContext);
+            XMLUnit.setIgnoreWhitespace(true);
+            XMLAssert.assertXMLEqual(expectedContext, new StringReader(createdContext));
+        } finally {
+            if (expectedContext != null) {
+                expectedContext.close();
+            }
+        }
+    }
+
+    private String contextAsString(CamelContextFactoryBean context) throws Exception {
+        StringWriter stringOut = new StringWriter();
+        JAXBContext jaxb = JAXBContext.newInstance(CamelContextFactoryBean.class);
+        jaxb.createMarshaller().marshal(context, stringOut);
+        return stringOut.toString();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f71547/components/camel-spring/src/test/resources/META-INF/spring/context-with-endpoint.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/META-INF/spring/context-with-endpoint.xml
b/components/camel-spring/src/test/resources/META-INF/spring/context-with-endpoint.xml
new file mode 100644
index 0000000..d731405
--- /dev/null
+++ b/components/camel-spring/src/test/resources/META-INF/spring/context-with-endpoint.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!--
+
+  An example Camel Context which can be used to test marshalling and
+  unmarshalling with CamelContextFactoryBean.
+
+ -->
+
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+    <endpoint id="endpoint1" uri="mock:end"/>
+</camelContext>


Mime
View raw message