Author: DartPeng
Date: 2008-09-25 05:48:34 -0400 (Thu, 25 Sep 2008)
New Revision: 10472
Added:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/FreeMarkerTest.java
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/test.flt
Modified:
trunk/smooks/tests/org.jboss.tools.smooks.test/.classpath
trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF
Log:
add some codes for testing FreeMarker2DOM , DOM2FreeMarker
Modified: trunk/smooks/tests/org.jboss.tools.smooks.test/.classpath
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/.classpath 2008-09-25 05:32:49 UTC (rev
10471)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/.classpath 2008-09-25 09:48:34 UTC (rev
10472)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF 2008-09-25
05:32:49 UTC (rev 10471)
+++ trunk/smooks/tests/org.jboss.tools.smooks.test/META-INF/MANIFEST.MF 2008-09-25
09:48:34 UTC (rev 10472)
@@ -19,7 +19,8 @@
org.eclipse.xsd.edit,
org.eclipse.emf,
org.eclipse.emf.ecore.edit,
- org.eclipse.emf.edit.ui
+ org.eclipse.emf.edit.ui,
+ org.jboss.tools.smooks.java2xml
Eclipse-LazyStart: true
Bundle-ClassPath: lib/dom4j-1.6.1.jar,
.
Added:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/FreeMarkerTest.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/FreeMarkerTest.java
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/FreeMarkerTest.java 2008-09-25
09:48:34 UTC (rev 10472)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.test.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import junit.framework.TestCase;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.io.SAXReader;
+import org.jboss.tools.smooks.java2xml.analyzer.DOM2FreeMarkerTransformor;
+import org.jboss.tools.smooks.java2xml.analyzer.FreeMarkerContentReplacer;
+
+/**
+ * @author Dart Peng
+ * @Date : Sep 25, 2008
+ */
+public class FreeMarkerTest extends TestCase {
+ public void testParse() throws DocumentException, IOException {
+ Reader reader = new InputStreamReader(FreeMarkerTest.class
+ .getResourceAsStream("test.flt"));
+ FreeMarkerContentReplacer replacer = new FreeMarkerContentReplacer();
+ String contents = replacer.replaceFreeMarkerTemplate(reader);
+ System.out.println(contents);
+
+ SAXReader sax = new SAXReader();
+ Document doc = sax.read(new ByteArrayInputStream(contents.getBytes()));
+ DOM2FreeMarkerTransformor trans = new DOM2FreeMarkerTransformor();
+ String result = trans.transformDOM(doc);
+
+ System.out.println(result);
+ }
+}
Property changes on:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/FreeMarkerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/test.flt
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/test.flt
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.test/src/org/jboss/tools/smooks/test/xml/test.flt 2008-09-25
09:48:34 UTC (rev 10472)
@@ -0,0 +1,11 @@
+<shipping-history date="${history.creationDate}">
+ <warehouse id="${history.warehouse.id}"
location="${history.warehouse.name}" />
+ <trackingNumbers>
+ <#list history.trackingNumbers as trackingNumber>
+ <trackingNumber>
+ <shipperID>${trackingNumber.shipperID}</shipperID>
+
<shipmentNumber>${trackingNumber.shipmentNumber}</shipmentNumber>
+ </trackingNumber>
+ </#list>
+ </trackingNumbers>
+</shipping-history>