freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [2/2] incubator-freemarker git commit: Added some more @@..._sibling_element tests.
Date Thu, 12 Jan 2017 18:09:09 GMT
Added some more @@..._sibling_element tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/4101072e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/4101072e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/4101072e

Branch: refs/heads/2.3-gae
Commit: 4101072e636156ad36b069aa869e87641507b5a2
Parents: 1dcd21d
Author: ddekany <ddekany@apache.org>
Authored: Thu Jan 12 19:08:56 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Thu Jan 12 19:08:56 2017 +0100

----------------------------------------------------------------------
 src/test/java/freemarker/ext/dom/DOMTest.java | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4101072e/src/test/java/freemarker/ext/dom/DOMTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/ext/dom/DOMTest.java b/src/test/java/freemarker/ext/dom/DOMTest.java
index 0d4e7de..8c7f35e 100644
--- a/src/test/java/freemarker/ext/dom/DOMTest.java
+++ b/src/test/java/freemarker/ext/dom/DOMTest.java
@@ -101,6 +101,10 @@ public class DOMTest extends TemplateTest {
         addToDataModel("doc", NodeModel.parse(new InputSource(new StringReader(xml))));
     }
 
+    private void addDocToDataModelNoSimplification(String xml) throws SAXException, IOException,
ParserConfigurationException {
+        addToDataModel("doc", NodeModel.parse(new InputSource(new StringReader(xml)), false,
false));
+    }
+    
     private void addNSUnawareDocToDataModel(String xml) throws ParserConfigurationException,
SAXException, IOException {
         DocumentBuilderFactory newFactory = DocumentBuilderFactory.newInstance();
         newFactory.setNamespaceAware(false);
@@ -121,4 +125,37 @@ public class DOMTest extends TemplateTest {
         assertErrorContains("${doc.r.multipleMatches.@@attributes_markup}", "single XML node",
"@@attributes_markup");
     }
     
+    @Test
+    public void testAtAtSiblingElement() throws Exception {
+        addDocToDataModel("<r><a/><b/></r>");
+        assertOutput("${doc.r.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.@@next_sibling_element?size}", "0");
+        assertOutput("${doc.r.a.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.a.@@next_sibling_element.@@qname}", "b");
+        assertOutput("${doc.r.b.@@previous_sibling_element.@@qname}", "a");
+        assertOutput("${doc.r.b.@@next_sibling_element?size}", "0");
+        
+        addDocToDataModel("<r>\r\n\t <a/>\r\n\t <b/>\r\n\t </r>");
+        assertOutput("${doc.r.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.@@next_sibling_element?size}", "0");
+        assertOutput("${doc.r.a.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.a.@@next_sibling_element.@@qname}", "b");
+        assertOutput("${doc.r.b.@@previous_sibling_element.@@qname}", "a");
+        assertOutput("${doc.r.b.@@next_sibling_element?size}", "0");
+        
+        addDocToDataModel("<r>t<a/>t<b/>t</r>");
+        assertOutput("${doc.r.a.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.a.@@next_sibling_element?size}", "0");
+        assertOutput("${doc.r.b.@@previous_sibling_element?size}", "0");
+        assertOutput("${doc.r.b.@@next_sibling_element?size}", "0");
+        
+        addDocToDataModelNoSimplification("<r><a/> <!-- --><?pi?>&#x20;<b/></r>");
+        assertOutput("${doc.r.a.@@next_sibling_element.@@qname}", "b");
+        assertOutput("${doc.r.b.@@previous_sibling_element.@@qname}", "a");
+        
+        addDocToDataModelNoSimplification("<r><a/> <!-- -->t<!-- -->
<b/></r>");
+        assertOutput("${doc.r.a.@@next_sibling_element?size}", "0");
+        assertOutput("${doc.r.b.@@previous_sibling_element?size}", "0");
+    }
+    
 }


Mime
View raw message