You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/03/17 08:05:23 UTC
[2/2] camel git commit: CAMEL-8498 CamelContextFactoryBean missing
setEndpoints method
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/8dd44491
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8dd44491
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8dd44491
Branch: refs/heads/camel-2.15.x
Commit: 8dd444914effd691ebc4b8fc37c5889f2d95b245
Parents: 4821940
Author: Keith Babo <kb...@redhat.com>
Authored: Mon Mar 16 17:46:04 2015 -0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 17 08:07:11 2015 +0100
----------------------------------------------------------------------
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/8dd44491/components/camel-spring/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/pom.xml b/components/camel-spring/pom.xml
index de41153..d20c27d 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/8dd44491/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/8dd44491/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/8dd44491/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>