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 <[email protected]> Authored: Thu Jan 12 18:51:47 2017 +0100 Committer: ddekany <[email protected]> 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>
