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/08 21:20:23 UTC
[04/13] incubator-freemarker git commit: Unit Test for sibling changes
Unit Test for sibling changes
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/ada5afed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/ada5afed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/ada5afed
Branch: refs/heads/2.3-gae
Commit: ada5afed5c6d1361888f1734976da247e627694d
Parents: 180d186
Author: Pradeep <pr...@trimble.com>
Authored: Tue Nov 3 11:36:31 2015 +0530
Committer: Pradeep <pr...@trimble.com>
Committed: Mon Jan 11 19:20:13 2016 +0530
----------------------------------------------------------------------
src/test/java/freemarker/core/SiblingTest.java | 42 ++++++++++++++++++++
.../freemarker/core/siblingDataModel.xml | 6 +++
2 files changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ada5afed/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
new file mode 100644
index 0000000..cda5430
--- /dev/null
+++ b/src/test/java/freemarker/core/SiblingTest.java
@@ -0,0 +1,42 @@
+package freemarker.core;
+
+import freemarker.ext.dom.NodeModel;
+import freemarker.template.TemplateException;
+import freemarker.test.TemplateTest;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by Pmuruge on 10/29/2015.
+ */
+public class SiblingTest extends TemplateTest {
+
+ @Override
+ protected Object getDataModel() {
+ Map dataModel = new HashMap();
+ String dataModelFileUrl = this.getClass().getResource(".").toString() + "/siblingDataModel.xml";
+ try {
+ dataModel.put(
+ "doc", NodeModel.parse(new File("build/test-classes/freemarker/core/siblingDataModel.xml")));
+ } catch (Exception e) {
+ System.out.println("Exception while parsing the dataModel xml");
+ e.printStackTrace();
+ }
+ return dataModel;
+ }
+ @Test
+ public void testPreviousSibling() throws IOException, TemplateException {
+ String ftl = "<#assign sibling>${doc.person.name?previousSibling}</#assign>" +
+ "${sibling?trim}" ;
+ assertOutput(ftl, "");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ada5afed/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
new file mode 100644
index 0000000..f743e2e
--- /dev/null
+++ b/src/test/resources/freemarker/core/siblingDataModel.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<person>
+ <gender>male</gender>
+ <name>pradeep</name>
+ <dob>12th August</dob>
+</person>