Author: dgolovin
Date: 2010-07-01 13:35:57 -0400 (Thu, 01 Jul 2010)
New Revision: 23155
Added:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSampleXMLFreeMarkerTemplateBuilderTest.java
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSDXMLFreeMarkerTemplateBuilderTest.java
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerTest.java
Removed:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSample_XMLFreeMarkerTemplateBuilderTest.java
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSD_XMLFreeMarkerTemplateBuilderTest.java
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerText.java
Modified:
trunk/smooks/features/org.jboss.tools.smooks.feature/pom.xml
trunk/smooks/features/org.jboss.tools.smooks.test.feature/pom.xml
trunk/smooks/features/pom.xml
trunk/smooks/plugins/org.jboss.tools.smooks.core/pom.xml
trunk/smooks/plugins/org.jboss.tools.smooks.runtime/pom.xml
trunk/smooks/plugins/org.jboss.tools.smooks.templating/pom.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/pom.xml
trunk/smooks/plugins/pom.xml
trunk/smooks/pom.xml
trunk/smooks/site/pom.xml
trunk/smooks/tests/org.jboss.tools.smooks.core.test/pom.xml
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/META-INF/MANIFEST.MF
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/pom.xml
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilderTest.java
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/META-INF/MANIFEST.MF
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/pom.xml
trunk/smooks/tests/pom.xml
Log:
1. Smooks maven repo structure alligned to svn repo
2. Smooks templating and ui tests are enabled in build
3. Test classes namess alligned to meet java coding convention about class name, so
underscore was removed everywhere
Modified: trunk/smooks/features/org.jboss.tools.smooks.feature/pom.xml
===================================================================
--- trunk/smooks/features/org.jboss.tools.smooks.feature/pom.xml 2010-07-01 17:25:35 UTC
(rev 23154)
+++ trunk/smooks/features/org.jboss.tools.smooks.feature/pom.xml 2010-07-01 17:35:57 UTC
(rev 23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.features</groupId>
<artifactId>org.jboss.tools.smooks.feature</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
Modified: trunk/smooks/features/org.jboss.tools.smooks.test.feature/pom.xml
===================================================================
--- trunk/smooks/features/org.jboss.tools.smooks.test.feature/pom.xml 2010-07-01 17:25:35
UTC (rev 23154)
+++ trunk/smooks/features/org.jboss.tools.smooks.test.feature/pom.xml 2010-07-01 17:35:57
UTC (rev 23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.features</groupId>
<artifactId>org.jboss.tools.smooks.test.feature</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
Modified: trunk/smooks/features/pom.xml
===================================================================
--- trunk/smooks/features/pom.xml 2010-07-01 17:25:35 UTC (rev 23154)
+++ trunk/smooks/features/pom.xml 2010-07-01 17:35:57 UTC (rev 23155)
@@ -1,14 +1,9 @@
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <relativePath>../../parent-pom.xml</relativePath>
- <groupId>org.jboss.tools</groupId>
- <artifactId>org.jboss.tools.parent.pom</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <groupId>org.jboss.tools</groupId>
- <artifactId>smooks.features</artifactId>
+ <groupId>org.jboss.tools.smooks</groupId>
+ <artifactId>features</artifactId>
+ <name>smooks.features</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.core/pom.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/pom.xml 2010-07-01 17:25:35 UTC (rev
23154)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/pom.xml 2010-07-01 17:35:57 UTC (rev
23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.plugins</groupId>
<artifactId>org.jboss.tools.smooks.core</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.runtime/pom.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.runtime/pom.xml 2010-07-01 17:25:35 UTC
(rev 23154)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.runtime/pom.xml 2010-07-01 17:35:57 UTC
(rev 23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tool.smooks.plugins</groupId>
<artifactId>org.jboss.tools.smooks.runtime</artifactId>
<version>1.2.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.templating/pom.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.templating/pom.xml 2010-07-01 17:25:35 UTC
(rev 23154)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.templating/pom.xml 2010-07-01 17:35:57 UTC
(rev 23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.plugins</groupId>
<artifactId>org.jboss.tools.smooks.templating</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/pom.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/pom.xml 2010-07-01 17:25:35 UTC (rev
23154)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/pom.xml 2010-07-01 17:35:57 UTC (rev
23155)
@@ -7,7 +7,7 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.plugins</groupId>
<artifactId>org.jboss.tools.smooks.ui</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
Modified: trunk/smooks/plugins/pom.xml
===================================================================
--- trunk/smooks/plugins/pom.xml 2010-07-01 17:25:35 UTC (rev 23154)
+++ trunk/smooks/plugins/pom.xml 2010-07-01 17:35:57 UTC (rev 23155)
@@ -1,14 +1,9 @@
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <relativePath>../../parent-pom.xml</relativePath>
- <groupId>org.jboss.tools</groupId>
- <artifactId>org.jboss.tools.parent.pom</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <groupId>org.jboss.tools</groupId>
- <artifactId>smooks.plugins</artifactId>
+ <groupId>org.jboss.tools.smooks</groupId>
+ <artifactId>plugins</artifactId>
+ <name>smooks.plugins</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
Modified: trunk/smooks/pom.xml
===================================================================
--- trunk/smooks/pom.xml 2010-07-01 17:25:35 UTC (rev 23154)
+++ trunk/smooks/pom.xml 2010-07-01 17:35:57 UTC (rev 23155)
@@ -1,21 +1,16 @@
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <relativePath>../parent-pom.xml</relativePath>
- <groupId>org.jboss.tools</groupId>
- <artifactId>org.jboss.tools.parent.pom</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
<groupId>org.jboss.tools</groupId>
<artifactId>smooks</artifactId>
+ <name>smooks.all</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>features</module>
<module>plugins</module>
<module>tests</module>
- <module>site</module>
- </modules>
+ <module>site</module>
+ </modules>
</project>
Modified: trunk/smooks/site/pom.xml
===================================================================
--- trunk/smooks/site/pom.xml 2010-07-01 17:25:35 UTC (rev 23154)
+++ trunk/smooks/site/pom.xml 2010-07-01 17:35:57 UTC (rev 23155)
@@ -6,8 +6,9 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
- <artifactId>smooks.site</artifactId>
+ <groupId>org.jboss.tools.smooks</groupId>
+ <artifactId>site</artifactId>
+ <name>smooks.site</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>eclipse-update-site</packaging>
</project>
Modified: trunk/smooks/tests/org.jboss.tools.smooks.core.test/pom.xml
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.core.test/pom.xml 2010-07-01 17:25:35 UTC
(rev 23154)
+++ trunk/smooks/tests/org.jboss.tools.smooks.core.test/pom.xml 2010-07-01 17:35:57 UTC
(rev 23155)
@@ -7,8 +7,14 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.tests</groupId>
<artifactId>org.jboss.tools.smooks.core.test</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <emma.filter>org.jboss.tools.smooks*</emma.filter>
+ <emma.instrument.bundles>org.jboss.tools.smooks.core</emma.instrument.bundles>
+ </properties>
+
</project>
Modified: trunk/smooks/tests/org.jboss.tools.smooks.templating.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/META-INF/MANIFEST.MF 2010-07-01
17:25:35 UTC (rev 23154)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/META-INF/MANIFEST.MF 2010-07-01
17:35:57 UTC (rev 23155)
@@ -3,8 +3,8 @@
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.smooks.templating.test
Bundle-Version: 1.1.0.qualifier
-Bundle-ClassPath: lib/xmlunit-1.1.jar,
- .
+Bundle-ClassPath: .,
+ lib/xmlunit-1.1.jar
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: plugin
Require-Bundle: org.junit,
Modified: trunk/smooks/tests/org.jboss.tools.smooks.templating.test/pom.xml
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.templating.test/pom.xml 2010-07-01 17:25:35
UTC (rev 23154)
+++ trunk/smooks/tests/org.jboss.tools.smooks.templating.test/pom.xml 2010-07-01 17:35:57
UTC (rev 23155)
@@ -7,8 +7,13 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.tests</groupId>
<artifactId>org.jboss.tools.smooks.templating.test</artifactId>
<version>1.1.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <emma.filter>org.jboss.tools.smooks.templating*</emma.filter>
+ <emma.instrument.bundles>org.jboss.tools.smooks.templating</emma.instrument.bundles>
+ </properties>
</project>
Modified:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilderTest.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilderTest.java 2010-07-01
17:25:35 UTC (rev 23154)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilderTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -35,7 +35,7 @@
*/
public class CSVFreeMarkerTemplateBuilderTest extends TestCase {
- public void test_all_fields_mapped_01() throws TemplateBuilderException, IOException,
ModelBuilderException {
+ public void testAllFieldsMapped01() throws TemplateBuilderException, IOException,
ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder1 = new
CSVFreeMarkerTemplateBuilder(modelBuilder, ',', '\"', false);
@@ -62,7 +62,7 @@
template);
}
- public void test_all_fields_mapped_01_includingFieldNames() throws
TemplateBuilderException, IOException, ModelBuilderException {
+ public void testAllFieldsMapped01IncludingFieldNames() throws
TemplateBuilderException, IOException, ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder1 = new
CSVFreeMarkerTemplateBuilder(modelBuilder, ',', '\"', true);
@@ -95,7 +95,7 @@
* Same as test above accept it uses different delimiters.
* @throws ModelBuilderException
*/
- public void test_all_fields_mapped_02() throws TemplateBuilderException, IOException,
ModelBuilderException {
+ public void testAllFieldsMapped02() throws TemplateBuilderException, IOException,
ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder1 = new
CSVFreeMarkerTemplateBuilder(modelBuilder, '|', '\'', false);
@@ -120,7 +120,7 @@
template);
}
- public void test_all_fields_not_mapped() throws TemplateBuilderException,
ModelBuilderException {
+ public void testAllFieldsNotMapped() throws TemplateBuilderException,
ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder;
@@ -153,7 +153,7 @@
}
}
- public void test_collection_not_mapped_01() throws TemplateBuilderException,
ModelBuilderException {
+ public void testCollectionNotMapped01() throws TemplateBuilderException,
ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder;
@@ -169,7 +169,7 @@
}
}
- public void test_collection_not_mapped_02() throws TemplateBuilderException,
ModelBuilderException {
+ public void testCollectionNotMapped02() throws TemplateBuilderException,
ModelBuilderException {
CSVModelBuilder modelBuilder = new CSVModelBuilder("firstname",
"lastname", "country");
CSVFreeMarkerTemplateBuilder builder;
Copied:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSampleXMLFreeMarkerTemplateBuilderTest.java
(from rev 22821,
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSample_XMLFreeMarkerTemplateBuilderTest.java)
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSampleXMLFreeMarkerTemplateBuilderTest.java
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSampleXMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.tools.smooks.templating.template.xml;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.smooks.templating.model.ModelBuilderException;
+import org.jboss.tools.smooks.templating.template.TemplateBuilder;
+import org.jboss.tools.smooks.templating.template.TestUtil;
+import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
+ */
+public class XMLSampleXMLFreeMarkerTemplateBuilderTest extends TestCase {
+
+ public void testXMLOrder01() throws IOException, ParserConfigurationException,
TemplateBuilderException, SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXMLSampleFreeMarkerTemplateBuilder(new
File("src/org/jboss/tools/smooks/templating/template/xml/order-status-01.xml"));
+
+ Node identNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:OrderStatusResultHeader/ns0:BuyerParty/ns1:PartyID/ns1:Ident");
+ builder.addValueMapping("order.status.id", identNode);
+
+ String theTemplate = builder.buildTemplate();
+
+// System.out.println(theTemplate);
+ TestUtil.assertXMLEquals(theTemplate,
"expected/order-status-expected-01.xml", getClass());
+
+ // Now, test that we can parse the template ....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+ }
+
+ public void testXMLOrder02() throws IOException, ParserConfigurationException,
TemplateBuilderException, SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXMLSampleFreeMarkerTemplateBuilder(new
File("src/org/jboss/tools/smooks/templating/template/xml/order-status-01.xml"));
+
+ Node identNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:OrderStatusResultHeader/ns0:BuyerParty/ns1:PartyID/ns1:Ident");
+ Element resultStatusCollectionNode = (Element)
builder.getModelNode("ns0:OrderStatusResult/ns0:ListOfOrderStatusResultDetail/ns0:OrderStatusResultDetail");
+ Node buyerRefNumberNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:ListOfOrderStatusResultDetail/ns0:OrderStatusResultDetail/ns0:OrderStatusResultReference/ns0:BuyerReferenceNumber");
+
+ builder.addValueMapping("order.status.id", identNode);
+ builder.addCollectionMapping("order.orderItemsStatusList",
resultStatusCollectionNode, "itemStatus");
+ builder.addValueMapping("itemStatus.buyerRefNumber", buyerRefNumberNode);
+
+ String theTemplate = builder.buildTemplate();
+
+// System.out.println(theTemplate);
+ TestUtil.assertEquals(theTemplate, "expected/order-status-expected-02.xml",
getClass());
+
+ // Now, test that we can parse the template ....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+ }
+}
Property changes on:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSampleXMLFreeMarkerTemplateBuilderTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSample_XMLFreeMarkerTemplateBuilderTest.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSample_XMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:25:35 UTC (rev 23154)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XMLSample_XMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.tools.smooks.templating.template.xml;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPathExpressionException;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.smooks.templating.model.ModelBuilderException;
-import org.jboss.tools.smooks.templating.template.TemplateBuilder;
-import org.jboss.tools.smooks.templating.template.TestUtil;
-import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-/**
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class XMLSample_XMLFreeMarkerTemplateBuilderTest extends TestCase {
-
- public void test_XML_Order_01() throws IOException, ParserConfigurationException,
TemplateBuilderException, SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXMLSampleFreeMarkerTemplateBuilder(new
File("src/org/jboss/tools/smooks/templating/template/xml/order-status-01.xml"));
-
- Node identNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:OrderStatusResultHeader/ns0:BuyerParty/ns1:PartyID/ns1:Ident");
- builder.addValueMapping("order.status.id", identNode);
-
- String theTemplate = builder.buildTemplate();
-
-// System.out.println(theTemplate);
- TestUtil.assertXMLEquals(theTemplate,
"expected/order-status-expected-01.xml", getClass());
-
- // Now, test that we can parse the template ....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
- }
-
- public void test_XML_Order_02() throws IOException, ParserConfigurationException,
TemplateBuilderException, SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXMLSampleFreeMarkerTemplateBuilder(new
File("src/org/jboss/tools/smooks/templating/template/xml/order-status-01.xml"));
-
- Node identNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:OrderStatusResultHeader/ns0:BuyerParty/ns1:PartyID/ns1:Ident");
- Element resultStatusCollectionNode = (Element)
builder.getModelNode("ns0:OrderStatusResult/ns0:ListOfOrderStatusResultDetail/ns0:OrderStatusResultDetail");
- Node buyerRefNumberNode =
builder.getModelNode("ns0:OrderStatusResult/ns0:ListOfOrderStatusResultDetail/ns0:OrderStatusResultDetail/ns0:OrderStatusResultReference/ns0:BuyerReferenceNumber");
-
- builder.addValueMapping("order.status.id", identNode);
- builder.addCollectionMapping("order.orderItemsStatusList",
resultStatusCollectionNode, "itemStatus");
- builder.addValueMapping("itemStatus.buyerRefNumber", buyerRefNumberNode);
-
- String theTemplate = builder.buildTemplate();
-
-// System.out.println(theTemplate);
- TestUtil.assertEquals(theTemplate, "expected/order-status-expected-02.xml",
getClass());
-
- // Now, test that we can parse the template ....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
- }
-}
Copied:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSDXMLFreeMarkerTemplateBuilderTest.java
(from rev 22821,
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSD_XMLFreeMarkerTemplateBuilderTest.java)
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSDXMLFreeMarkerTemplateBuilderTest.java
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSDXMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.tools.smooks.templating.template.xml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.URI;
+import org.jboss.tools.smooks.templating.model.ModelBuilderException;
+import org.jboss.tools.smooks.templating.model.xml.XSDModelBuilder;
+import org.jboss.tools.smooks.templating.template.Mapping;
+import org.jboss.tools.smooks.templating.template.TemplateBuilder;
+import org.jboss.tools.smooks.templating.template.TestUtil;
+import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
+import
org.jboss.tools.smooks.templating.template.exception.UnmappedCollectionNodeException;
+import org.milyn.util.FreeMarkerTemplate;
+import org.milyn.xml.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
+ */
+public class XSDXMLFreeMarkerTemplateBuilderTest extends TestCase {
+
+ public void testSimplePerson01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
+ SAXException, ModelBuilderException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
+ "src/org/jboss/tools/smooks/templating/template/xml/simple-person.xsd"),
"person");
+ String theTemplate = builder.buildTemplate();
+
+ TestUtil.assertXMLEquals(theTemplate, "expected/simple-person-01.xml",
getClass());
+
+ // Now, test that we can parse the template ....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+ }
+
+ public void testSimplePerson02() throws IOException, ParserConfigurationException,
TemplateBuilderException,
+ SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
+ "src/org/jboss/tools/smooks/templating/template/xml/simple-person.xsd"),
"person");
+
+ builder.addValueMapping("male",
builder.getModelNode("ns0:person/name/smk:compositor/male"));
+ builder.addValueMapping("firstName",
builder.getModelNode("ns0:person/name/@first"));
+ builder.addValueMapping("lastName",
builder.getModelNode("ns0:person/name/@last"));
+ builder.addValueMapping("address",
builder.getModelNode("ns0:person/address"));
+ builder.addValueMapping("age",
builder.getModelNode("ns0:person/age"));
+
+ Map javaCtx = createPersonObj("Tom", "Fennelly",
"Ireland", 21);
+ String template = builder.buildTemplate();
+ // System.out.println(template);
+ FreeMarkerTemplate freemarker = new FreeMarkerTemplate(template);
+ String templateRes = freemarker.apply(javaCtx);
+
+ TestUtil.assertXMLEquals(templateRes, "expected/simple-person-02.xml",
getClass());
+ TestUtil.validate(builder, templateRes);
+
+ // Now, test that we can parse the template and extract the mappings
+ // from it....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), template);
+ assertEquals(5, builder2.getMappings().size());
+ assertEquals(template, builder2.buildTemplate());
+ }
+
+ public void testPeople01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
+ SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
+ "src/org/jboss/tools/smooks/templating/template/xml/people.xsd"),
"people");
+
+ // Try adding a value mapping before adding the collection mapping.
+ // Should get an exception...
+ try {
+ builder.addValueMapping("personObj.firtName",
builder.getModelNode("ns0:people/person/name/@first"));
+ fail("Expected UnmappedCollectionNodeException");
+ } catch (UnmappedCollectionNodeException e) {
+ assertEquals("Unmapped collection node 'person'.", e.getMessage());
+ }
+ }
+
+ public void testPeople02() throws IOException, ParserConfigurationException,
TemplateBuilderException,
+ SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
+ "src/org/jboss/tools/smooks/templating/template/xml/people.xsd"),
"people");
+
+ builder.addCollectionMapping("people", (Element)
builder.getModelNode("ns0:people/person"), "personObj");
+ builder.addValueMapping("personObj.male",
builder.getModelNode("ns0:people/person/name/smk:compositor/male"));
+ builder.addValueMapping("personObj.firstName",
builder.getModelNode("ns0:people/person/name/@first"));
+ builder.addValueMapping("personObj.lastName",
builder.getModelNode("ns0:people/person/name/@last"));
+ builder.addValueMapping("personObj.address",
builder.getModelNode("ns0:people/person/address"));
+ builder.addValueMapping("personObj.age",
builder.getModelNode("ns0:people/person/age"));
+
+ assertEquals(6, builder.getMappings().size());
+
+ Map javaCtx = new HashMap();
+ List people = new ArrayList();
+ people.add(createPersonObj("Tom", "Fennelly", "Ireland",
6));
+ people.add(createPersonObj("Mike", "Fennelly", "Ireland",
5));
+ javaCtx.put("people", people);
+
+ String template = builder.buildTemplate();
+
+ FreeMarkerTemplate freemarker = new FreeMarkerTemplate(template);
+ String templateRes = freemarker.apply(javaCtx);
+
+ TestUtil.assertXMLEquals(templateRes, "expected/people-01.xml", getClass());
+
+ // Now, test that we can parse the template and extract the mappings
+ // from it....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), template);
+ assertEquals(6, builder2.getMappings().size());
+ assertEquals(template, builder2.buildTemplate());
+ }
+
+ public void testElementName() throws IOException, ModelBuilderException {
+ File xsdFile = new
File("src/org/jboss/tools/smooks/templating/template/xml/smooks1_0.xsd");
+ URI uri = URI.createFileURI(xsdFile.getCanonicalFile().toString());
+ XSDModelBuilder builder = new XSDModelBuilder(uri);
+ builder.setRootElementName("smooks-resource-list");
+ XMLFreeMarkerTemplateBuilder templateBuilder = new
XMLFreeMarkerTemplateBuilder(builder);
+ Document document = templateBuilder.getModel();
+
+ StringWriter writer = new StringWriter();
+ XmlUtil.serialize(document, true, writer);
+ System.out.println(writer);
+ //checkNodeName(document.getDocumentElement());
+ }
+
+ public void testCreature01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
+ SAXException, ModelBuilderException, XPathExpressionException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
+ "src/org/jboss/tools/smooks/templating/template/xml/creature.xsd"),
"creature");
+
+ Mapping mapping = builder.addValueMapping("dog",
builder.getModelNode("ns0:creature/smk:compositor/dog/@name"));
+
+ // The mapping onto the <dog> node should result in the <person> and
+ // <cat> nodes being hidden...
+ assertEquals(2, mapping.getHideNodes().size());
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
mapping.getHideNodes().get(0));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
mapping.getHideNodes().get(1));
+
+ String theTemplate = builder.buildTemplate();
+ TestUtil.assertXMLEquals(theTemplate, "expected/creature-01.xml",
getClass());
+ TestUtil.validate(builder, theTemplate);
+
+ // Now, test that we can parse the template and extract the mappings
+ // from it....
+ XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+
+ // ========================================================
+
+ // Remove the <dog> mapping... should reshow the <person> and <cat>
+ // nodes...
+ List<Node> showNodes = builder.removeMapping(mapping);
+ assertEquals(2, showNodes.size());
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
showNodes.get(0));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
showNodes.get(1));
+
+ mapping = builder.addValueMapping("cat",
builder.getModelNode("ns0:creature/smk:compositor/cat"));
+
+ // The mapping onto the <cat> node should result in the <person> and
+ // <dog> nodes being hidden...
+ assertEquals(2, mapping.getHideNodes().size());
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
mapping.getHideNodes().get(0));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
mapping.getHideNodes().get(1));
+
+ theTemplate = builder.buildTemplate();
+ TestUtil.assertXMLEquals(theTemplate, "expected/creature-02.xml",
getClass());
+ TestUtil.validate(builder, theTemplate);
+
+ // Now, test that we can parse the template and extract the mappings
+ // from it....
+ builder2 = new XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+
+ // ========================================================
+
+ // Remove the <cat> mapping... should reshow the <person> and <dog>
+ // nodes...
+ showNodes = builder.removeMapping(mapping);
+ assertEquals(2, showNodes.size());
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
showNodes.get(0));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
showNodes.get(1));
+
+ // Map the person... there are nested choice compositors on this one...
+ mapping = builder.addValueMapping("male", builder
+ .getModelNode("ns0:creature/smk:compositor/person/name/smk:compositor/male"));
+ builder.addValueMapping("firstName",
builder.getModelNode("ns0:creature/smk:compositor/person/name/@first"));
+ builder.addValueMapping("lastName",
builder.getModelNode("ns0:creature/smk:compositor/person/name/@last"));
+ builder.addValueMapping("address",
builder.getModelNode("ns0:creature/smk:compositor/person/address"));
+ builder.addValueMapping("age",
builder.getModelNode("ns0:creature/smk:compositor/person/age"));
+
+ // The mapping onto the <person> node should result in the <female>,
+ // <dog> and <cat> nodes being hidden...
+ assertEquals(3, mapping.getHideNodes().size());
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person/name/smk:compositor/female"),
mapping
+ .getHideNodes().get(0));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
mapping.getHideNodes().get(1));
+ assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
mapping.getHideNodes().get(2));
+
+ theTemplate = builder.buildTemplate();
+ TestUtil.assertXMLEquals(theTemplate, "expected/creature-03.xml",
getClass());
+
+ // Now, test that we can parse the template and extract the mappings
+ // from it....
+ builder2 = new XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
+ assertEquals(theTemplate, builder2.buildTemplate());
+ }
+
+ public void testOrderStatusRequest() throws IOException, ParserConfigurationException,
ModelBuilderException, SAXException, TemplateBuilderException {
+ TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new
+
File("resources/xcbl40/schema/org/xcbl/path_delim/schemas/xcbl/v4_0/ordermanagement/v1_0/ordermanagement.xsd"),
"OrderStatusResult");
+ String theTemplate = builder.buildTemplate();
+
+ System.out.println(theTemplate);
+ TestUtil.assertXMLEquals(theTemplate, "expected/order-status-01.xml",
getClass());
+ }
+
+ private Map createPersonObj(String first, String last, String address, int age) {
+ Map javaCtx = new HashMap();
+ javaCtx.put("male", true);
+ javaCtx.put("firstName", first);
+ javaCtx.put("lastName", last);
+ javaCtx.put("address", address);
+ javaCtx.put("age", age);
+ return javaCtx;
+ }
+
+ private void printModel(TemplateBuilder builder) {
+ System.out.println(XmlUtil.serialize(builder.getModel(), true));
+ }
+}
Property changes on:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSDXMLFreeMarkerTemplateBuilderTest.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted:
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSD_XMLFreeMarkerTemplateBuilderTest.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSD_XMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:25:35 UTC (rev 23154)
+++
trunk/smooks/tests/org.jboss.tools.smooks.templating.test/src/org/jboss/tools/smooks/templating/template/xml/XSD_XMLFreeMarkerTemplateBuilderTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -1,263 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.tools.smooks.templating.template.xml;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPathExpressionException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.emf.common.util.URI;
-import org.jboss.tools.smooks.templating.model.ModelBuilderException;
-import org.jboss.tools.smooks.templating.model.xml.XSDModelBuilder;
-import org.jboss.tools.smooks.templating.template.Mapping;
-import org.jboss.tools.smooks.templating.template.TemplateBuilder;
-import org.jboss.tools.smooks.templating.template.TestUtil;
-import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
-import
org.jboss.tools.smooks.templating.template.exception.UnmappedCollectionNodeException;
-import org.milyn.util.FreeMarkerTemplate;
-import org.milyn.xml.XmlUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class XSD_XMLFreeMarkerTemplateBuilderTest extends TestCase {
-
- public void test_SimplePerson_01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
- SAXException, ModelBuilderException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
- "src/org/jboss/tools/smooks/templating/template/xml/simple-person.xsd"),
"person");
- String theTemplate = builder.buildTemplate();
-
- TestUtil.assertXMLEquals(theTemplate, "expected/simple-person-01.xml",
getClass());
-
- // Now, test that we can parse the template ....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
- }
-
- public void test_SimplePerson_02() throws IOException, ParserConfigurationException,
TemplateBuilderException,
- SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
- "src/org/jboss/tools/smooks/templating/template/xml/simple-person.xsd"),
"person");
-
- builder.addValueMapping("male",
builder.getModelNode("ns0:person/name/smk:compositor/male"));
- builder.addValueMapping("firstName",
builder.getModelNode("ns0:person/name/@first"));
- builder.addValueMapping("lastName",
builder.getModelNode("ns0:person/name/@last"));
- builder.addValueMapping("address",
builder.getModelNode("ns0:person/address"));
- builder.addValueMapping("age",
builder.getModelNode("ns0:person/age"));
-
- Map javaCtx = createPersonObj("Tom", "Fennelly",
"Ireland", 21);
- String template = builder.buildTemplate();
- // System.out.println(template);
- FreeMarkerTemplate freemarker = new FreeMarkerTemplate(template);
- String templateRes = freemarker.apply(javaCtx);
-
- TestUtil.assertXMLEquals(templateRes, "expected/simple-person-02.xml",
getClass());
- TestUtil.validate(builder, templateRes);
-
- // Now, test that we can parse the template and extract the mappings
- // from it....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), template);
- assertEquals(5, builder2.getMappings().size());
- assertEquals(template, builder2.buildTemplate());
- }
-
- public void test_people_01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
- SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
- "src/org/jboss/tools/smooks/templating/template/xml/people.xsd"),
"people");
-
- // Try adding a value mapping before adding the collection mapping.
- // Should get an exception...
- try {
- builder.addValueMapping("personObj.firtName",
builder.getModelNode("ns0:people/person/name/@first"));
- fail("Expected UnmappedCollectionNodeException");
- } catch (UnmappedCollectionNodeException e) {
- assertEquals("Unmapped collection node 'person'.", e.getMessage());
- }
- }
-
- public void test_people_02() throws IOException, ParserConfigurationException,
TemplateBuilderException,
- SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
- "src/org/jboss/tools/smooks/templating/template/xml/people.xsd"),
"people");
-
- builder.addCollectionMapping("people", (Element)
builder.getModelNode("ns0:people/person"), "personObj");
- builder.addValueMapping("personObj.male",
builder.getModelNode("ns0:people/person/name/smk:compositor/male"));
- builder.addValueMapping("personObj.firstName",
builder.getModelNode("ns0:people/person/name/@first"));
- builder.addValueMapping("personObj.lastName",
builder.getModelNode("ns0:people/person/name/@last"));
- builder.addValueMapping("personObj.address",
builder.getModelNode("ns0:people/person/address"));
- builder.addValueMapping("personObj.age",
builder.getModelNode("ns0:people/person/age"));
-
- assertEquals(6, builder.getMappings().size());
-
- Map javaCtx = new HashMap();
- List people = new ArrayList();
- people.add(createPersonObj("Tom", "Fennelly", "Ireland",
6));
- people.add(createPersonObj("Mike", "Fennelly", "Ireland",
5));
- javaCtx.put("people", people);
-
- String template = builder.buildTemplate();
-
- FreeMarkerTemplate freemarker = new FreeMarkerTemplate(template);
- String templateRes = freemarker.apply(javaCtx);
-
- TestUtil.assertXMLEquals(templateRes, "expected/people-01.xml", getClass());
-
- // Now, test that we can parse the template and extract the mappings
- // from it....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), template);
- assertEquals(6, builder2.getMappings().size());
- assertEquals(template, builder2.buildTemplate());
- }
-
- public void test_elementname() throws IOException, ModelBuilderException {
- File xsdFile = new
File("src/org/jboss/tools/smooks/templating/template/xml/smooks1_0.xsd");
- URI uri = URI.createFileURI(xsdFile.getCanonicalFile().toString());
- XSDModelBuilder builder = new XSDModelBuilder(uri);
- builder.setRootElementName("smooks-resource-list");
- XMLFreeMarkerTemplateBuilder templateBuilder = new
XMLFreeMarkerTemplateBuilder(builder);
- Document document = templateBuilder.getModel();
-
- StringWriter writer = new StringWriter();
- XmlUtil.serialize(document, true, writer);
- System.out.println(writer);
- //checkNodeName(document.getDocumentElement());
- }
-
- public void test_creature_01() throws IOException, ParserConfigurationException,
TemplateBuilderException,
- SAXException, ModelBuilderException, XPathExpressionException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new File(
- "src/org/jboss/tools/smooks/templating/template/xml/creature.xsd"),
"creature");
-
- Mapping mapping = builder.addValueMapping("dog",
builder.getModelNode("ns0:creature/smk:compositor/dog/@name"));
-
- // The mapping onto the <dog> node should result in the <person> and
- // <cat> nodes being hidden...
- assertEquals(2, mapping.getHideNodes().size());
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
mapping.getHideNodes().get(0));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
mapping.getHideNodes().get(1));
-
- String theTemplate = builder.buildTemplate();
- TestUtil.assertXMLEquals(theTemplate, "expected/creature-01.xml",
getClass());
- TestUtil.validate(builder, theTemplate);
-
- // Now, test that we can parse the template and extract the mappings
- // from it....
- XMLFreeMarkerTemplateBuilder builder2 = new
XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
-
- // ========================================================
-
- // Remove the <dog> mapping... should reshow the <person> and <cat>
- // nodes...
- List<Node> showNodes = builder.removeMapping(mapping);
- assertEquals(2, showNodes.size());
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
showNodes.get(0));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
showNodes.get(1));
-
- mapping = builder.addValueMapping("cat",
builder.getModelNode("ns0:creature/smk:compositor/cat"));
-
- // The mapping onto the <cat> node should result in the <person> and
- // <dog> nodes being hidden...
- assertEquals(2, mapping.getHideNodes().size());
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
mapping.getHideNodes().get(0));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
mapping.getHideNodes().get(1));
-
- theTemplate = builder.buildTemplate();
- TestUtil.assertXMLEquals(theTemplate, "expected/creature-02.xml",
getClass());
- TestUtil.validate(builder, theTemplate);
-
- // Now, test that we can parse the template and extract the mappings
- // from it....
- builder2 = new XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
-
- // ========================================================
-
- // Remove the <cat> mapping... should reshow the <person> and <dog>
- // nodes...
- showNodes = builder.removeMapping(mapping);
- assertEquals(2, showNodes.size());
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
showNodes.get(0));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person"),
showNodes.get(1));
-
- // Map the person... there are nested choice compositors on this one...
- mapping = builder.addValueMapping("male", builder
- .getModelNode("ns0:creature/smk:compositor/person/name/smk:compositor/male"));
- builder.addValueMapping("firstName",
builder.getModelNode("ns0:creature/smk:compositor/person/name/@first"));
- builder.addValueMapping("lastName",
builder.getModelNode("ns0:creature/smk:compositor/person/name/@last"));
- builder.addValueMapping("address",
builder.getModelNode("ns0:creature/smk:compositor/person/address"));
- builder.addValueMapping("age",
builder.getModelNode("ns0:creature/smk:compositor/person/age"));
-
- // The mapping onto the <person> node should result in the <female>,
- // <dog> and <cat> nodes being hidden...
- assertEquals(3, mapping.getHideNodes().size());
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/person/name/smk:compositor/female"),
mapping
- .getHideNodes().get(0));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/dog"),
mapping.getHideNodes().get(1));
- assertEquals(builder.getModelNode("ns0:creature/smk:compositor/cat"),
mapping.getHideNodes().get(2));
-
- theTemplate = builder.buildTemplate();
- TestUtil.assertXMLEquals(theTemplate, "expected/creature-03.xml",
getClass());
-
- // Now, test that we can parse the template and extract the mappings
- // from it....
- builder2 = new XMLFreeMarkerTemplateBuilder(builder.getModelBuilder(), theTemplate);
- assertEquals(theTemplate, builder2.buildTemplate());
- }
-
- public void test_OrderStatusRequest() throws IOException, ParserConfigurationException,
ModelBuilderException, SAXException, TemplateBuilderException {
- TemplateBuilder builder = TestUtil.createXSDFreeMarkerTemplateBuilder(new
-
File("resources/xcbl40/schema/org/xcbl/path_delim/schemas/xcbl/v4_0/ordermanagement/v1_0/ordermanagement.xsd"),
"OrderStatusResult");
- String theTemplate = builder.buildTemplate();
-
- System.out.println(theTemplate);
- TestUtil.assertXMLEquals(theTemplate, "expected/order-status-01.xml",
getClass());
- }
-
- private Map createPersonObj(String first, String last, String address, int age) {
- Map javaCtx = new HashMap();
- javaCtx.put("male", true);
- javaCtx.put("firstName", first);
- javaCtx.put("lastName", last);
- javaCtx.put("address", address);
- javaCtx.put("age", age);
- return javaCtx;
- }
-
- private void printModel(TemplateBuilder builder) {
- System.out.println(XmlUtil.serialize(builder.getModel(), true));
- }
-}
Modified: trunk/smooks/tests/org.jboss.tools.smooks.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.ui.test/META-INF/MANIFEST.MF 2010-07-01
17:25:35 UTC (rev 23154)
+++ trunk/smooks/tests/org.jboss.tools.smooks.ui.test/META-INF/MANIFEST.MF 2010-07-01
17:35:57 UTC (rev 23155)
@@ -3,8 +3,8 @@
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.smooks.ui.test
Bundle-Version: 1.1.0.qualifier
-Bundle-ClassPath: lib/xmlunit-1.1.jar,
- .,
+Bundle-ClassPath: .,
+ lib/xmlunit-1.1.jar,
lib/xstream-1.2.2.jar
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: plugin
Modified: trunk/smooks/tests/org.jboss.tools.smooks.ui.test/pom.xml
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.ui.test/pom.xml 2010-07-01 17:25:35 UTC (rev
23154)
+++ trunk/smooks/tests/org.jboss.tools.smooks.ui.test/pom.xml 2010-07-01 17:35:57 UTC (rev
23155)
@@ -7,8 +7,27 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.smooks.tests</groupId>
<artifactId>org.jboss.tools.smooks.ui.test</artifactId>
<version>1.1.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <emma.filter>org.jboss.tools.smooks.*</emma.filter>
+ <emma.instrument.bundles>org.jboss.tools.smooks.ui,org.jboss.tools.smooks.core</emma.instrument.bundles>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>maven-osgi-test-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>org/jboss/tools/smooks/launch/serialize/ObjectSerializerTest.class</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Copied:
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerTest.java
(from rev 22821,
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerText.java)
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerTest.java
(rev 0)
+++
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerTest.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -0,0 +1,68 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009, JBoss Inc.
+ */
+package org.jboss.tools.smooks.launch.serialize;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.milyn.payload.JavaResult;
+import org.xml.sax.SAXException;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
+ */
+public class ObjectSerializerTest extends TestCase {
+
+ public void test() throws IOException, SAXException {
+ Map<String, Object> beanContext = new HashMap<String, Object>();
+ Order order = new Order();
+ List<OrderItem> items = order.getOrderItems();
+
+ beanContext.put("order", order);
+ beanContext.put("header", order.getHeader());
+ beanContext.put("orderItems", items);
+
+ items.add(new OrderItem().setProductId(55126).setQuantity(6).setPrice(65.98));
+ items.add(new OrderItem().setProductId(23423).setQuantity(3).setPrice(8.42));
+ items.add(new OrderItem().setProductId(45645).setQuantity(7).setPrice(999.00));
+
+ beanContext.put("orderItem", items.get(items.size() - 1));
+
+ JavaResult javaResult = new JavaResult(beanContext);
+
+ Collection<ObjectSerializer> rootBeans = ObjectSerializer.serialize(javaResult);
+
+ // ObjectSerializer should work out that there's just 1 root
+ // bean i.e. the "order" bean...
+ assertEquals(1, rootBeans.size());
+ for(ObjectSerializer serializer : rootBeans) {
+ //System.out.println(serializer.getSerializedForm());
+ TestUtil.assertEquals(serializer.getSerializedForm(), "expected-01.txt",
getClass());
+ assertEquals("[header, orderItems, orderItem]",
serializer.getReferencedBeans().toString());
+ }
+ }
+}
Deleted:
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerText.java
===================================================================
---
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerText.java 2010-07-01
17:25:35 UTC (rev 23154)
+++
trunk/smooks/tests/org.jboss.tools.smooks.ui.test/src/org/jboss/tools/smooks/launch/serialize/ObjectSerializerText.java 2010-07-01
17:35:57 UTC (rev 23155)
@@ -1,68 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2009, JBoss Inc.
- */
-package org.jboss.tools.smooks.launch.serialize;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.milyn.payload.JavaResult;
-import org.xml.sax.SAXException;
-
-import junit.framework.TestCase;
-
-/**
- *
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public class ObjectSerializerText extends TestCase {
-
- public void test() throws IOException, SAXException {
- Map<String, Object> beanContext = new HashMap<String, Object>();
- Order order = new Order();
- List<OrderItem> items = order.getOrderItems();
-
- beanContext.put("order", order);
- beanContext.put("header", order.getHeader());
- beanContext.put("orderItems", items);
-
- items.add(new OrderItem().setProductId(55126).setQuantity(6).setPrice(65.98));
- items.add(new OrderItem().setProductId(23423).setQuantity(3).setPrice(8.42));
- items.add(new OrderItem().setProductId(45645).setQuantity(7).setPrice(999.00));
-
- beanContext.put("orderItem", items.get(items.size() - 1));
-
- JavaResult javaResult = new JavaResult(beanContext);
-
- Collection<ObjectSerializer> rootBeans = ObjectSerializer.serialize(javaResult);
-
- // ObjectSerializer should work out that there's just 1 root
- // bean i.e. the "order" bean...
- assertEquals(1, rootBeans.size());
- for(ObjectSerializer serializer : rootBeans) {
- //System.out.println(serializer.getSerializedForm());
- TestUtil.assertEquals(serializer.getSerializedForm(), "expected-01.txt",
getClass());
- assertEquals("[header, orderItems, orderItem]",
serializer.getReferencedBeans().toString());
- }
- }
-}
Modified: trunk/smooks/tests/pom.xml
===================================================================
--- trunk/smooks/tests/pom.xml 2010-07-01 17:25:35 UTC (rev 23154)
+++ trunk/smooks/tests/pom.xml 2010-07-01 17:35:57 UTC (rev 23155)
@@ -1,14 +1,9 @@
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <relativePath>../../parent-pom.xml</relativePath>
- <groupId>org.jboss.tools</groupId>
- <artifactId>org.jboss.tools.parent.pom</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <groupId>org.jboss.tools</groupId>
- <artifactId>smooks.tests</artifactId>
+ <groupId>org.jboss.tools.smooks</groupId>
+ <artifactId>tests</artifactId>
+ <name>smooks.tests</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>