camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] git commit: CAMEL-7544: Fixed XML DSL with customId attribute set cannot be read by Camel
Date Thu, 26 Jun 2014 14:08:11 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 91f7e0d10 -> b69abf49e
  refs/heads/master a76f818a9 -> d00f44409


CAMEL-7544: Fixed XML DSL with customId attribute set cannot be read by Camel


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

Branch: refs/heads/camel-2.13.x
Commit: 6818b5a5a261898ca8d27e681377d4a5e7abe259
Parents: 91f7e0d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jun 26 15:47:01 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jun 26 16:07:43 2014 +0200

----------------------------------------------------------------------
 .../core/xml/AbstractCamelFactoryBean.java      | 10 ++++
 .../camel/spring/issues/CustomIdIssuesTest.java | 59 ++++++++++++++++++++
 .../camel/spring/issues/CustomIdIssueTest.xml   | 47 ++++++++++++++++
 3 files changed, 116 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6818b5a5/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
index d24d7a1..cae7a71 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelFactoryBean.java
@@ -33,6 +33,8 @@ public abstract class AbstractCamelFactoryBean<T> extends IdentifiedType
impleme
     private String camelContextId;
     @XmlTransient
     private CamelContext camelContext;
+    @XmlTransient
+    private Boolean customId;
 
     public abstract T getObject() throws Exception;
 
@@ -82,6 +84,14 @@ public abstract class AbstractCamelFactoryBean<T> extends IdentifiedType
impleme
         this.camelContextId = camelContextId;
     }
 
+    public Boolean getCustomId() {
+        return customId;
+    }
+
+    public void setCustomId(Boolean customId) {
+        this.customId = customId;
+    }
+
     public boolean isSingleton() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6818b5a5/components/camel-spring/src/test/java/org/apache/camel/spring/issues/CustomIdIssuesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/CustomIdIssuesTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/CustomIdIssuesTest.java
new file mode 100644
index 0000000..43b6f02
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/CustomIdIssuesTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.LogDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.WhenDefinition;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class CustomIdIssuesTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/issues/CustomIdIssueTest.xml");
+    }
+
+    public void testCustomId() {
+        RouteDefinition route = context.getRouteDefinition("myRoute");
+        assertNotNull(route);
+        assertTrue(route.hasCustomIdAssigned());
+
+        FromDefinition from = route.getInputs().get(0);
+        assertEquals("fromFile", from.getId());
+        assertTrue(from.hasCustomIdAssigned());
+
+        ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
+        assertEquals("myChoice", choice.getId());
+        assertTrue(choice.hasCustomIdAssigned());
+
+        WhenDefinition when = choice.getWhenClauses().get(0);
+        assertTrue(when.hasCustomIdAssigned());
+        assertEquals("UK", when.getId());
+
+        LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
+        assertFalse(log.hasCustomIdAssigned());
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/6818b5a5/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
new file mode 100644
index 0000000..9c7b4fa
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
@@ -0,0 +1,47 @@
+<?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"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       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">
+    <route customId="true" id="myRoute">
+      <description>here is a sample which processes the input files
+        (leaving them in place - see the 'noop' flag)
+        then performs content based routing on the message using XPath</description>
+      <from uri="file:src/data?noop=true" customId="true" id="fromFile">
+        <description/>
+      </from>
+      <choice customId="true" id="myChoice">
+        <when customId="true" id="UK">
+          <xpath>/person/city = 'London'</xpath>
+          <log message="UK message" customId="true" id="ukLog"/>
+          <to uri="file:target/messages/uk" customId="true" id="ukOutput"/>
+        </when>
+        <otherwise>
+          <log message="Other message"/>
+          <to uri="file:target/messages/others"/>
+        </otherwise>
+      </choice>
+    </route>
+  </camelContext>
+
+</beans>
\ No newline at end of file


Mime
View raw message