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 2018/12/17 12:41:46 UTC

[camel] branch master updated (e5adb02 -> 8073fde)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from e5adb02  Upgrade Json Schema Validator to version 0.1.25
     new 3785c8c  CAMEL-12994: Added unit tests
     new 8073fde  CAMEL-12994: Fixed issue in camel-saxon to skip reservered namespace prefix according to the XQuery spec.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/xquery/XQueryBuilder.java       |  9 +++++++--
 .../saxon/SpringXQueryTransformIssueTest.java}      | 21 +++++++++++----------
 .../builder/saxon/XQueryTransformIssueTest.java     | 20 +++++++++++++-------
 .../camel-saxon/src/test/resources/myinput.xml      |  9 ++++++++-
 .../saxon/SpringXQueryTransformIssueTest.xml}       |  7 +++----
 5 files changed, 42 insertions(+), 24 deletions(-)
 copy components/{camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterLenientTest.java => camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java} (70%)
 copy connectors/examples/beverage-component/src/test/java/org/beverage/BeverageTest.java => components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java (66%)
 copy camel-core/src/test/data/bar.xml => components/camel-saxon/src/test/resources/myinput.xml (88%)
 copy components/{camel-spring/src/test/resources/org/apache/camel/spring/processor/transformWithExpressionContext.xml => camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml} (89%)


[camel] 01/02: CAMEL-12994: Added unit tests

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3785c8c964913c3750a207adccc509c08514d3b1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 17 13:27:03 2018 +0100

    CAMEL-12994: Added unit tests
---
 .../saxon/SpringXQueryTransformIssueTest.java      | 44 ++++++++++++++++++
 .../builder/saxon/XQueryTransformIssueTest.java    | 52 ++++++++++++++++++++++
 .../camel-saxon/src/test/resources/myinput.xml     | 27 +++++++++++
 .../saxon/SpringXQueryTransformIssueTest.xml       | 38 ++++++++++++++++
 4 files changed, 161 insertions(+)

diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java
new file mode 100644
index 0000000..4389ff9
--- /dev/null
+++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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.builder.saxon;
+
+import java.io.FileInputStream;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringXQueryTransformIssueTest extends CamelSpringTestSupport {
+
+    @Test
+    public void testTransform() throws Exception {
+        String data = IOHelper.loadText(new FileInputStream("src/test/resources/myinput.xml"));
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("123TestConcat");
+
+        template.sendBody("direct:start", data);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml");
+    }
+}
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java
new file mode 100644
index 0000000..e6a883e
--- /dev/null
+++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java
@@ -0,0 +1,52 @@
+/**
+ * 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.builder.saxon;
+
+import java.io.FileInputStream;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.junit.Test;
+
+public class XQueryTransformIssueTest extends CamelTestSupport {
+
+    @Test
+    public void testTransform() throws Exception {
+        String data = IOHelper.loadText(new FileInputStream("src/test/resources/myinput.xml"));
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("123TestConcat");
+
+        template.sendBody("direct:start", data);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .transform().xquery("concat(/Envelope/Body/getEmployee/EmpId/text(),\"TestConcat\")", String.class)
+                    .to("log:info")
+                    .to("mock:result");
+            }
+        };
+    }
+}
diff --git a/components/camel-saxon/src/test/resources/myinput.xml b/components/camel-saxon/src/test/resources/myinput.xml
new file mode 100644
index 0000000..d7ca32e
--- /dev/null
+++ b/components/camel-saxon/src/test/resources/myinput.xml
@@ -0,0 +1,27 @@
+<?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.
+
+-->
+<Envelope>
+  <Header/>
+  <Body>
+    <getEmployee>
+      <EmpId>123</EmpId>
+    </getEmployee>
+  </Body>
+</Envelope>
\ No newline at end of file
diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml b/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml
new file mode 100644
index 0000000..ce68485
--- /dev/null
+++ b/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml
@@ -0,0 +1,38 @@
+<?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">
+    <route>
+      <from uri="direct:start"/>
+      <transform>
+        <xquery type="String">concat(/Envelope/Body/getEmployee/EmpId/text(),"TestConcat")</xquery>
+      </transform>
+      <to uri="log:info"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+</beans>


[camel] 02/02: CAMEL-12994: Fixed issue in camel-saxon to skip reservered namespace prefix according to the XQuery spec.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8073fde61d91a7d32669905ea10b9b0f649604dc
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 17 13:39:33 2018 +0100

    CAMEL-12994: Fixed issue in camel-saxon to skip reservered namespace prefix according to the XQuery spec.
---
 .../java/org/apache/camel/component/xquery/XQueryBuilder.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
index 179793f..8890a94 100644
--- a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
+++ b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
@@ -722,8 +722,13 @@ public abstract class XQueryBuilder implements Expression, Predicate, NamespaceA
             for (Map.Entry<String, String> entry : entries) {
                 String prefix = entry.getKey();
                 String uri = entry.getValue();
-                staticQueryContext.declareNamespace(prefix, uri);
-                staticQueryContext.setInheritNamespaces(true);
+                // skip invalid prefix or uri according to XQuery spec
+                boolean invalid = "xml".equals(prefix) || "xmlns".equals(prefix);
+                if (!invalid) {
+                    LOG.debug("Declaring namespace [prefix: {}, uri: {}]", prefix, uri);
+                    staticQueryContext.declareNamespace(prefix, uri);
+                    staticQueryContext.setInheritNamespaces(true);
+                }
             }
             expression = createQueryExpression(staticQueryContext);