Author: veithen
Date: Fri Apr 13 21:07:26 2012
New Revision: 1325949

URL: http://svn.apache.org/viewvc?rev=1325949&view=rev
Log:
Rationalized the various test cases that test the JAXP Transformer API on DOOM.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestValidator.java
      - copied, changed from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/identity.xslt
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/input.xml
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/ipo.xsd
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/ipo_1.xml
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/output.xml
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/org/apache/axiom/ts/dom/document/stylesheet.xslt
      - copied unchanged from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt
Removed:
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TransformTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/
    
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml?rev=1325949&r1=1325948&r2=1325949&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml 
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml 
Fri Apr 13 21:07:26 2012
@@ -52,7 +52,26 @@
             <groupId>xerces</groupId>
             <artifactId>xercesImpl</artifactId>
             <version>2.9.1</version>
-            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.saxon</groupId>
+            <artifactId>saxon</artifactId>
+            <version>8.7</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.saxon</groupId>
+            <artifactId>saxon-dom</artifactId>
+            <version>8.7</version>
+        </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+            <version>1.2</version>
         </dependency>
     </dependencies>
     <profiles>

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1325949&r1=1325948&r2=1325949&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
 Fri Apr 13 21:07:26 2012
@@ -51,6 +51,11 @@ public class DOMTestSuiteBuilder extends
         addTest(new 
org.apache.axiom.ts.dom.document.TestGetDomConfigDefaults(dbf));
         addTest(new 
org.apache.axiom.ts.dom.document.TestGetOwnerDocument(dbf));
         addTest(new 
org.apache.axiom.ts.dom.document.TestNormalizeDocumentNamespace(dbf));
+        addTest(new 
org.apache.axiom.ts.dom.document.TestTransformerWithIdentityStylesheet(dbf, 
org.apache.xalan.processor.TransformerFactoryImpl.class));
+        addTest(new 
org.apache.axiom.ts.dom.document.TestTransformerWithIdentityStylesheet(dbf, 
net.sf.saxon.TransformerFactoryImpl.class));
+        addTest(new 
org.apache.axiom.ts.dom.document.TestTransformerWithStylesheet(dbf, 
org.apache.xalan.processor.TransformerFactoryImpl.class));
+        addTest(new 
org.apache.axiom.ts.dom.document.TestTransformerWithStylesheet(dbf, 
net.sf.saxon.TransformerFactoryImpl.class));
+        addTest(new org.apache.axiom.ts.dom.document.TestValidator(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestAppendChild(dbf));
         addTest(new 
org.apache.axiom.ts.dom.element.TestAppendChildCyclic(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestAppendChildSelf(dbf));

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java?rev=1325949&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java
 Fri Apr 13 21:07:26 2012
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.axiom.ts.dom.document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+// This test failed with Saxon 8.9 because NodeImpl#compareDocumentPosition
+// threw an UnsupportedOperationException instead of a DOMException.
+public class TestTransformerWithIdentityStylesheet extends TransformerTestCase 
{
+    public TestTransformerWithIdentityStylesheet(DocumentBuilderFactory dbf, 
Class transformerFactoryClass) {
+        super(dbf, transformerFactoryClass);
+    }
+
+    protected void runTest() throws Throwable {
+        DocumentBuilder builder = dbf.newDocumentBuilder();
+        
+        Document document = builder.newDocument();
+        Element root = document.createElement("root");
+        Element element = document.createElementNS("urn:mynamespace", 
"element1");
+        element.setAttribute("att", "testValue");
+        element.appendChild(document.createTextNode("test"));
+        root.appendChild(element);
+        document.appendChild(root);
+        
+        Document stylesheet
+                = 
builder.parse(TestTransformerWithIdentityStylesheet.class.getResourceAsStream("identity.xslt"));
+        Document output = builder.newDocument();
+        Transformer transformer = 
((TransformerFactory)transformerFactoryClass.newInstance()).newTransformer(new 
DOMSource(stylesheet));
+        transformer.transform(new DOMSource(document), new DOMResult(output));
+        XMLUnit.setIgnoreWhitespace(false);
+        XMLAssert.assertXMLEqual(document, output);
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithIdentityStylesheet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java?rev=1325949&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java
 Fri Apr 13 21:07:26 2012
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.axiom.ts.dom.document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
+
+public class TestTransformerWithStylesheet extends TransformerTestCase {
+    public TestTransformerWithStylesheet(DocumentBuilderFactory dbf, Class 
transformerFactoryClass) {
+        super(dbf, transformerFactoryClass);
+    }
+
+    protected void runTest() throws Throwable {
+        DocumentBuilder builder = dbf.newDocumentBuilder();
+        Document input = 
builder.parse(TestTransformerWithStylesheet.class.getResourceAsStream("input.xml"));
+        Document stylesheet
+                = 
builder.parse(TestTransformerWithStylesheet.class.getResourceAsStream("stylesheet.xslt"));
+        Document expected = 
builder.parse(TestTransformerWithStylesheet.class.getResourceAsStream("output.xml"));
+        Document actual = builder.newDocument();
+        Transformer transformer = 
((TransformerFactory)transformerFactoryClass.newInstance()).newTransformer(new 
DOMSource(stylesheet));
+        transformer.transform(new DOMSource(input), new DOMResult(actual));
+        XMLUnit.setIgnoreWhitespace(true);
+        XMLAssert.assertXMLEqual(expected, actual);
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestTransformerWithStylesheet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestValidator.java
 (from r1325524, 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java)
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestValidator.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestValidator.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java&r1=1325524&r2=1325949&rev=1325949&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestValidator.java
 Fri Apr 13 21:07:26 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.axiom.om.impl.dom.jaxp;
+package org.apache.axiom.ts.dom.document;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -26,19 +26,21 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.apache.axiom.ts.dom.DOMTestCase;
 import org.apache.xerces.jaxp.validation.XMLSchemaFactory;
-import org.junit.Test;
 
-public class ValidatorTest {
-    @Test
-    public void test() throws Exception {
+public class TestValidator extends DOMTestCase {
+    public TestValidator(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    protected void runTest() throws Throwable {
         SchemaFactory factory = new XMLSchemaFactory();
-        DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
         DocumentBuilder builder = dbf.newDocumentBuilder();
         Schema schema = factory.newSchema(new DOMSource(
-                
builder.parse(ValidatorTest.class.getResourceAsStream("ipo.xsd"))));
+                
builder.parse(TestValidator.class.getResourceAsStream("ipo.xsd"))));
         Validator validator = schema.newValidator();
         validator.validate(new DOMSource(
-                
builder.parse(ValidatorTest.class.getResourceAsStream("ipo_1.xml"))));
+                
builder.parse(TestValidator.class.getResourceAsStream("ipo_1.xml"))));
     }
 }

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java?rev=1325949&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java
 Fri Apr 13 21:07:26 2012
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.axiom.ts.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+
+public abstract class TransformerTestCase extends DOMTestCase {
+    protected final Class transformerFactoryClass;
+    
+    public TransformerTestCase(DocumentBuilderFactory dbf, Class 
transformerFactoryClass) {
+        super(dbf);
+        this.transformerFactoryClass = transformerFactoryClass;
+        addTestProperty("transformerFactory", 
transformerFactoryClass.getName());
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TransformerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to