freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [09/13] incubator-freemarker git commit: CDATA Test cases added
Date Sun, 08 Jan 2017 21:20:28 GMT
CDATA Test cases added


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

Branch: refs/heads/2.3-gae
Commit: d40d29cb2ed40c7eeff39e48cb396da1b008756d
Parents: 321e853
Author: Pradeep <pradeep_murugesan@trimble.com>
Authored: Sun Dec 13 13:26:17 2015 +0530
Committer: Pradeep <pradeep_murugesan@trimble.com>
Committed: Mon Jan 11 19:21:00 2016 +0530

----------------------------------------------------------------------
 .../java/freemarker/ext/dom/ElementModel.java   |  3 ++-
 src/test/java/freemarker/core/SiblingTest.java  | 22 ++++++++------------
 .../freemarker/core/siblingDataModel.xml        |  4 +++-
 3 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d40d29cb/src/main/java/freemarker/ext/dom/ElementModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/ext/dom/ElementModel.java b/src/main/java/freemarker/ext/dom/ElementModel.java
index 11d1c04..628430c 100644
--- a/src/main/java/freemarker/ext/dom/ElementModel.java
+++ b/src/main/java/freemarker/ext/dom/ElementModel.java
@@ -137,7 +137,8 @@ class ElementModel extends NodeModel implements TemplateScalarModel {
         if(node != null) {
             boolean isEmpty = StringUtil.isTrimmableToEmpty(node.getTextContent().toCharArray());
             boolean isPINode = node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE;
-            significantNode = !(isEmpty || isPINode);
+            boolean isCommentNode = node.getNodeType() == Node.COMMENT_NODE;
+            significantNode = !(isEmpty || isPINode || isCommentNode);
         }
         return significantNode;
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d40d29cb/src/test/java/freemarker/core/SiblingTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/SiblingTest.java b/src/test/java/freemarker/core/SiblingTest.java
index afbb880..81158c8 100644
--- a/src/test/java/freemarker/core/SiblingTest.java
+++ b/src/test/java/freemarker/core/SiblingTest.java
@@ -47,7 +47,7 @@ public class SiblingTest extends TemplateTest {
         }
     }
 
-   @Test
+    @Test
     public void testEmptyPreviousSibling() throws IOException, TemplateException {
         String ftl = "${doc.person.name?previousSibling}";
         assertOutput(ftl, "\n    ");
@@ -80,14 +80,12 @@ public class SiblingTest extends TemplateTest {
                          "previous is null" +
                     "</#if>";
         assertOutput(ftl, "previous is null");
-
     }
 
     @Test
     public void testSignificantPreviousSibling() throws IOException, TemplateException {
         String ftl = "${doc.person.name.@@previous}";
         assertOutput(ftl, "male");
-
     }
 
 
@@ -95,7 +93,6 @@ public class SiblingTest extends TemplateTest {
     public void testSignificantNextSibling() throws IOException, TemplateException {
         String ftl = "${doc.person.name.@@next}";
         assertOutput(ftl, "12th August");
-
     }
 
     @Test
@@ -113,18 +110,17 @@ public class SiblingTest extends TemplateTest {
     public void testSkippingCommentNode() throws IOException, TemplateException {
         String ftl = "${doc.person.profession.@@previous}";
         assertOutput(ftl, "Chennai, India");
-
     }
 
     @Test
-    public void testpreviousSiblingforPINode() throws IOException, TemplateException {
-        String ftl = "${doc.person.profession?previousSibling?previousSibling}";
-        assertOutput(ftl, "Chennai, India");
+    public void testSkippingEmptyCdataNode() throws IOException, TemplateException {
+        String ftl = "${doc.person.hobby.@@previous}";
+        assertOutput(ftl, "Software Engineer");
     }
-    /*@Test
-    public void testSkippingCdataNode() throws IOException, TemplateException {
-        String ftl = "${doc.person.phone.@@previous}";
-        assertOutput(ftl, "Chennai, India");
-    }*/
 
+    @Test
+    public void testValidCdataNode() throws IOException, TemplateException {
+        String ftl = "${doc.person.phone.@@previous}";
+        assertOutput(ftl, "\n    this is a valid cdata\n    ");
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d40d29cb/src/test/resources/freemarker/core/siblingDataModel.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/core/siblingDataModel.xml b/src/test/resources/freemarker/core/siblingDataModel.xml
index 37e8795..5a48103 100644
--- a/src/test/resources/freemarker/core/siblingDataModel.xml
+++ b/src/test/resources/freemarker/core/siblingDataModel.xml
@@ -6,6 +6,8 @@
     <!--This is a comment Node -->
     <?xml-stylesheet type="text/css" href="style.css"?>
     <profession>Software Engineer</profession>
-    <![CDATA[ <a>test<a> ]]>
+    <![CDATA[    ]]>
+    <hobby>gardening</hobby>
+    <![CDATA[this is a valid cdata]]>
     <phone>12345678</phone>
 </person>


Mime
View raw message