You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/01/12 18:09:08 UTC
[1/2] incubator-freemarker git commit: Moved DOM sibling tests to the
proper package
Repository: incubator-freemarker
Updated Branches:
refs/heads/2.3-gae aa7ab1cfb -> 4101072e6
Moved DOM sibling tests to the proper package
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/1dcd21d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/1dcd21d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/1dcd21d6
Branch: refs/heads/2.3-gae
Commit: 1dcd21d68ef7d632261974fdbd95e1e053dde708
Parents: aa7ab1c
Author: ddekany <dd...@apache.org>
Authored: Thu Jan 12 18:51:47 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Thu Jan 12 19:08:31 2017 +0100
----------------------------------------------------------------------
src/test/java/freemarker/core/SiblingTest.java | 99 --------------------
.../java/freemarker/ext/dom/DOMSiblingTest.java | 99 ++++++++++++++++++++
src/test/java/freemarker/ext/dom/DOMTest.java | 6 +-
.../freemarker/core/siblingDataModel.xml | 31 ------
.../freemarker/ext/dom/DOMSiblingTest.xml | 31 ++++++
5 files changed, 134 insertions(+), 132 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1dcd21d6/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
deleted file mode 100644
index d0d5779..0000000
--- a/src/test/java/freemarker/core/SiblingTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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 freemarker.core;
-
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import freemarker.ext.dom.NodeModel;
-import freemarker.template.TemplateException;
-import freemarker.test.TemplateTest;
-
-public class SiblingTest extends TemplateTest {
-
- @Before
- public void setUp() throws SAXException, IOException, ParserConfigurationException {
- InputSource is = new InputSource(getClass().getResourceAsStream("siblingDataModel.xml"));
- addToDataModel("doc", NodeModel.parse(is));
- }
-
- @Test
- public void testBlankPreviousSibling() throws IOException, TemplateException {
- assertOutput("${doc.person.name?previousSibling}", "\n ");
- }
-
- @Test
- public void testNonBlankPreviousSibling() throws IOException, TemplateException {
- assertOutput("${doc.person.address?previousSibling}", "12th August");
- }
-
- @Test
- public void testBlankNextSibling() throws IOException, TemplateException {
- assertOutput("${doc.person.name?nextSibling}", "\n ");
- }
-
- @Test
- public void testNonBlankNextSibling() throws IOException, TemplateException {
- assertOutput("${doc.person.dob?nextSibling}", "Chennai, India");
- }
-
- @Test
- public void testNullPreviousSibling() throws IOException, TemplateException {
- assertOutput("${doc.person?previousSibling?? ?c}", "false");
- }
-
- @Test
- public void testSignificantPreviousSibling() throws IOException, TemplateException {
- String ftl = "${doc.person.name.@@previous_sibling_element}";
- assertOutput(ftl, "male");
- }
-
- @Test
- public void testSignificantNextSibling() throws IOException, TemplateException {
- String ftl = "${doc.person.name.@@next_sibling_element}";
- assertOutput(ftl, "12th August");
- }
-
- @Test
- public void testNullSignificantPreviousSibling() throws IOException, TemplateException {
- assertOutput("${doc.person.phone.@@next_sibling_element?size}", "0");
- }
-
- @Test
- public void testSkippingCommentNode() throws IOException, TemplateException {
- assertOutput("${doc.person.profession.@@previous_sibling_element}", "Chennai, India");
- }
-
- @Test
- public void testSkippingEmptyCDataNode() throws IOException, TemplateException {
- assertOutput("${doc.person.hobby.@@previous_sibling_element}", "Software Engineer");
- }
-
- @Test
- public void testValidCDataNode() throws IOException, TemplateException {
- assertOutput("${doc.person.phone.@@previous_sibling_element?size}", "0");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1dcd21d6/src/test/java/freemarker/ext/dom/DOMSiblingTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/ext/dom/DOMSiblingTest.java b/src/test/java/freemarker/ext/dom/DOMSiblingTest.java
new file mode 100644
index 0000000..70dace9
--- /dev/null
+++ b/src/test/java/freemarker/ext/dom/DOMSiblingTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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 freemarker.ext.dom;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import freemarker.template.TemplateException;
+import freemarker.test.TemplateTest;
+
+public class DOMSiblingTest extends TemplateTest {
+
+ @Before
+ public void setUp() throws SAXException, IOException, ParserConfigurationException {
+ InputSource is = new InputSource(getClass().getResourceAsStream("DOMSiblingTest.xml"));
+ addToDataModel("doc", NodeModel.parse(is));
+ }
+
+ @Test
+ public void testBlankPreviousSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.name?previousSibling}", "\n ");
+ assertOutput("${doc.person.name?previous_sibling}", "\n ");
+ }
+
+ @Test
+ public void testNonBlankPreviousSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.address?previousSibling}", "12th August");
+ }
+
+ @Test
+ public void testBlankNextSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.name?nextSibling}", "\n ");
+ assertOutput("${doc.person.name?next_sibling}", "\n ");
+ }
+
+ @Test
+ public void testNonBlankNextSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.dob?nextSibling}", "Chennai, India");
+ }
+
+ @Test
+ public void testNullPreviousSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person?previousSibling?? ?c}", "false");
+ }
+
+ @Test
+ public void testSignificantPreviousSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.name.@@previous_sibling_element}", "male");
+ }
+
+ @Test
+ public void testSignificantNextSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.name.@@next_sibling_element}", "12th August");
+ }
+
+ @Test
+ public void testNullSignificantPreviousSibling() throws IOException, TemplateException {
+ assertOutput("${doc.person.phone.@@next_sibling_element?size}", "0");
+ }
+
+ @Test
+ public void testSkippingCommentNode() throws IOException, TemplateException {
+ assertOutput("${doc.person.profession.@@previous_sibling_element}", "Chennai, India");
+ }
+
+ @Test
+ public void testSkippingEmptyCDataNode() throws IOException, TemplateException {
+ assertOutput("${doc.person.hobby.@@previous_sibling_element}", "Software Engineer");
+ }
+
+ @Test
+ public void testValidCDataNode() throws IOException, TemplateException {
+ assertOutput("${doc.person.phone.@@previous_sibling_element?size}", "0");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1dcd21d6/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 1d2ceab..0d4e7de 100644
--- a/src/test/java/freemarker/ext/dom/DOMTest.java
+++ b/src/test/java/freemarker/ext/dom/DOMTest.java
@@ -18,8 +18,10 @@
*/
package freemarker.ext.dom;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.StringReader;
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1dcd21d6/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
deleted file mode 100644
index bdb3e45..0000000
--- a/src/test/resources/freemarker/core/siblingDataModel.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<person>
- <gender>male</gender>
- <name>pradeep</name>
- <dob>12th August</dob><address>Chennai, India</address>
- <!--This is a comment Node -->
- <?xml-stylesheet type="text/css" href="style.css"?>
- <profession>Software Engineer</profession>
- <![CDATA[ ]]>
- <hobby>gardening</hobby>
- <![CDATA[this is a valid cdata]]>
- <phone>12345678</phone>
-</person>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1dcd21d6/src/test/resources/freemarker/ext/dom/DOMSiblingTest.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/ext/dom/DOMSiblingTest.xml b/src/test/resources/freemarker/ext/dom/DOMSiblingTest.xml
new file mode 100644
index 0000000..bdb3e45
--- /dev/null
+++ b/src/test/resources/freemarker/ext/dom/DOMSiblingTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<person>
+ <gender>male</gender>
+ <name>pradeep</name>
+ <dob>12th August</dob><address>Chennai, India</address>
+ <!--This is a comment Node -->
+ <?xml-stylesheet type="text/css" href="style.css"?>
+ <profession>Software Engineer</profession>
+ <![CDATA[ ]]>
+ <hobby>gardening</hobby>
+ <![CDATA[this is a valid cdata]]>
+ <phone>12345678</phone>
+</person>
[2/2] incubator-freemarker git commit: Added some more
@@..._sibling_element tests.
Posted by dd...@apache.org.
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 <dd...@apache.org>
Authored: Thu Jan 12 19:08:56 2017 +0100
Committer: ddekany <dd...@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?> <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");
+ }
+
}