camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] camel git commit: CAMEL-10009: Fixed Spring XML DSL to not fail when using <to> with both id and ref attribute.
Date Fri, 03 Jun 2016 08:45:55 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 613435705 -> b3843f9d4
  refs/heads/camel-2.17.x 34d37c385 -> 533cb0f89
  refs/heads/master 60950daee -> 5d0989680


CAMEL-10009: Fixed Spring XML DSL to not fail when using <to> with both id and ref attribute.


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

Branch: refs/heads/master
Commit: 5d09896801d3ddb31c170819c2af832b861b0fb5
Parents: 60950da
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jun 3 10:43:51 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jun 3 10:44:54 2016 +0200

----------------------------------------------------------------------
 .../camel/spring/CamelEndpointFactoryBean.java  | 13 +++++++
 .../camel/spring/EndpointToIdRefTest.java       | 36 ++++++++++++++++++++
 .../apache/camel/spring/EndpointToIdRefTest.xml | 36 ++++++++++++++++++++
 3 files changed, 85 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5d098968/components/camel-spring/src/main/java/org/apache/camel/spring/CamelEndpointFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelEndpointFactoryBean.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelEndpointFactoryBean.java
index ace1ccd..e0c28b9 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelEndpointFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelEndpointFactoryBean.java
@@ -40,6 +40,11 @@ import org.springframework.context.ApplicationContextAware;
 public class CamelEndpointFactoryBean extends AbstractCamelEndpointFactoryBean implements
FactoryBean<Endpoint>, ApplicationContextAware {
     @XmlTransient
     private ApplicationContext applicationContext;
+    // ref is needed as transient as namespace parser registerEndpointsWithIdsDefinedInFromOrToTypes
+    // will discover <endpoint>, <to> etc and parse those eager and would attempt
to call setRef on
+    // this factory bean for a <to id="foo" ref="bar"/> that is using both id and ref.
+    @XmlTransient
+    private String ref;
 
     @Override
     protected CamelContext getCamelContextWithId(String camelContextId) {
@@ -55,4 +60,12 @@ public class CamelEndpointFactoryBean extends AbstractCamelEndpointFactoryBean
i
         Endpoint answer = super.getObject();
         return answer;
     }
+
+    public String getRef() {
+        return ref;
+    }
+
+    public void setRef(String ref) {
+        this.ref = ref;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5d098968/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointToIdRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointToIdRefTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointToIdRefTest.java
new file mode 100644
index 0000000..bc08679
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointToIdRefTest.java
@@ -0,0 +1,36 @@
+/**
+ * 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;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class EndpointToIdRefTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/EndpointToIdRefTest.xml");
+    }
+
+    public void testEndpoint() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/5d098968/components/camel-spring/src/test/resources/org/apache/camel/spring/EndpointToIdRefTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/EndpointToIdRefTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/EndpointToIdRefTest.xml
new file mode 100644
index 0000000..a3f1cc4
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/EndpointToIdRefTest.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       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.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <endpoint id="result" uri="mock:result"/>
+
+    <route>
+      <from uri="direct:start"/>
+      <to id="foo" ref="result"/>
+    </route>
+
+  </camelContext>
+
+</beans>


Mime
View raw message