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/09/08 15:38:28 UTC

[camel] branch camel-2.22.x updated (39bf705 -> d2bcf62)

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

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


    from 39bf705  CAMEL-12782 - More specific error message for unresolved model classes. (#2509)
     new 8818078  Polished
     new 06ed507  CAMEL-12114: Have XmlLineNumberParser respecting namespace uri also for anonymous namespaces (without prefix) from its parent+ tag
     new 454698b  Fixed CS
     new d2bcf62  Polished

The 4 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/parser/helper/XmlLineNumberParser.java   | 26 +++++++++++++++++---
 .../camel/parser/java/SimpleProcessorTest.java     |  1 +
 .../camel/parser/java/SplitTokenizeTest.java       |  1 +
 .../XmlLineNumberParserTest.java}                  | 28 +++++++++-------------
 4 files changed, 36 insertions(+), 20 deletions(-)
 copy tooling/camel-route-parser/src/test/java/org/apache/camel/parser/{xml/FindElementInRoutesTest.java => java/XmlLineNumberParserTest.java} (57%)


[camel] 01/04: Polished

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

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

commit 88180787440b07b43931d1730b45f51d8074183f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Sep 8 17:36:18 2018 +0200

    Polished
---
 .../main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java    | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
index 33397b5..bdc7890 100644
--- a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
@@ -29,7 +29,6 @@ import javax.xml.parsers.SAXParserFactory;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;


[camel] 03/04: Fixed CS

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

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

commit 454698baa101acb60b778d474457a052e675e208
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Sep 8 17:35:21 2018 +0200

    Fixed CS
---
 .../src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java  | 1 +
 .../src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
index 4df4363..fb1a609 100644
--- a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SimpleProcessorTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 public class SimpleProcessorTest extends CamelTestSupport {
 
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
index 4243dff..1d72376 100644
--- a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/SplitTokenizeTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.parser.java;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 public class SplitTokenizeTest extends CamelTestSupport {
 


[camel] 02/04: CAMEL-12114: Have XmlLineNumberParser respecting namespace uri also for anonymous namespaces (without prefix) from its parent+ tag

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

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

commit 06ed50793fb21131be76c89b351dfd66bb3586ef
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Sep 8 17:34:27 2018 +0200

    CAMEL-12114: Have XmlLineNumberParser respecting namespace uri also for anonymous namespaces (without prefix) from its parent+ tag
---
 .../camel/parser/helper/XmlLineNumberParser.java   | 29 ++++++++++++++--
 .../camel/parser/java/XmlLineNumberParserTest.java | 39 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
index bdc7890..edf8312 100644
--- a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
@@ -19,8 +19,15 @@ package org.apache.camel.parser.helper;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Deque;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Stack;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -102,6 +109,7 @@ public final class XmlLineNumberParser {
             private Locator locator;
             private boolean found;
             private final Map<String, String> localNs = new HashMap<>();
+            private final Map<String, String> anonymousNs = new LinkedHashMap<>();
 
             @Override
             public void setDocumentLocator(final Locator locator) {
@@ -146,6 +154,19 @@ public final class XmlLineNumberParser {
                                     ns = localNs.get(prefix);
                                 }
                             }
+                        } else {
+                            // maybe there is an anonymous namespace (xmlns)
+                            if (attributes != null) {
+                                ns = attributes.getValue("xmlns");
+                                if (ns != null) {
+                                    anonymousNs.put(qName, ns);
+                                } else if (!anonymousNs.isEmpty()) {
+                                    // grab latest anonymous namespace to use as the namespace as
+                                    // this child tag should use the parents+ namespace
+                                    List<String> values = new ArrayList<>(anonymousNs.values());
+                                    ns = values.get(values.size() - 1);
+                                }
+                            }
                         }
                         if (ns != null) {
                             el = doc.createElementNS(ns, qName);
@@ -154,8 +175,10 @@ public final class XmlLineNumberParser {
                         }
                     }
 
-                    for (int i = 0; i < attributes.getLength(); i++) {
-                        el.setAttribute(attributes.getQName(i), attributes.getValue(i));
+                    if (attributes != null) {
+                        for (int i = 0; i < attributes.getLength(); i++) {
+                            el.setAttribute(attributes.getQName(i), attributes.getValue(i));
+                        }
                     }
 
                     el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
@@ -185,6 +208,8 @@ public final class XmlLineNumberParser {
                     closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
                     closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
                 }
+
+                anonymousNs.remove(qName);
             }
 
             @Override
diff --git a/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/XmlLineNumberParserTest.java b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/XmlLineNumberParserTest.java
new file mode 100644
index 0000000..bec0696
--- /dev/null
+++ b/tooling/camel-route-parser/src/test/java/org/apache/camel/parser/java/XmlLineNumberParserTest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.parser.java;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import org.apache.camel.parser.helper.XmlLineNumberParser;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class XmlLineNumberParserTest {
+
+    @Test
+    public void testRespectNamespace() throws Exception {
+        InputStream is = new FileInputStream("src/test/resources/org/apache/camel/parser/xml/mycamel.xml");
+        Document parsedXml = XmlLineNumberParser.parseXml(is);
+        NodeList fromCamelWithNamespace = parsedXml.getElementsByTagNameNS("http://camel.apache.org/schema/spring", "from");
+        assertEquals(1, fromCamelWithNamespace.getLength());
+    }
+}


[camel] 04/04: Polished

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

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

commit d2bcf62e516559aa81d6e1635a25b793f94c933f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Sep 8 17:37:19 2018 +0200

    Polished
---
 .../main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
index edf8312..9b544fb 100644
--- a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
+++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java
@@ -19,15 +19,11 @@ package org.apache.camel.parser.helper;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
-import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Deque;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Queue;
 import java.util.Stack;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;