You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/12/22 17:21:06 UTC
svn commit: r728721 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-integration/
axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/
axiom-integration/src/test/java/org/apache...
Author: veithen
Date: Mon Dec 22 08:21:05 2008
New Revision: 728721
URL: http://svn.apache.org/viewvc?rev=728721&view=rev
Log:
Added some integration tests for DOOM with Saxon and Xalan. Changed the exception thrown by NodeImpl#compareDocumentPosition from UnsupportedOperationException to DOMException(NOT_SUPPORTED_ERR) to make this work with Saxon 8.9.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/
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/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/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/identity.xslt (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=728721&r1=728720&r2=728721&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java Mon Dec 22 08:21:05 2008
@@ -518,9 +518,12 @@
throw new UnsupportedOperationException("TODO");
}
- public short compareDocumentPosition(Node arg0) throws DOMException {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
+ public short compareDocumentPosition(Node other) throws DOMException {
+ // This is not yet implemented. In the meantime, we throw a DOMException
+ // and not an UnsupportedOperationException, since this works better with
+ // some other libraries (such as Saxon 8.9).
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, DOMMessageFormatter
+ .formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null));
}
public String getTextContent() throws DOMException {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml?rev=728721&r1=728720&r2=728721&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml Mon Dec 22 08:21:05 2008
@@ -39,6 +39,11 @@
<version>${axiom.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-dom</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
@@ -70,7 +75,12 @@
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
- <version>8.5.1</version>
+ <version>8.9</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-dom</artifactId>
+ <version>8.9</version>
</dependency>
</dependencies>
<build>
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java?rev=728721&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java Mon Dec 22 08:21:05 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.om.impl.dom.jaxp;
+
+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.XMLTestCase;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TransformerTest extends XMLTestCase {
+ private void testStylesheet(TransformerFactory tf) throws Exception {
+ DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ Document input = builder.parse(TransformerTest.class.getResourceAsStream("input.xml"));
+ Document stylesheet
+ = builder.parse(TransformerTest.class.getResourceAsStream("stylesheet.xslt"));
+ Document expected = builder.parse(TransformerTest.class.getResourceAsStream("output.xml"));
+ Document actual = builder.newDocument();
+ Transformer transformer = tf.newTransformer(new DOMSource(stylesheet));
+ transformer.transform(new DOMSource(input), new DOMResult(actual));
+ XMLUnit.setIgnoreWhitespace(true);
+ assertXMLEqual(expected, actual);
+ }
+
+ public void testStylesheetWithXalan() throws Exception {
+ testStylesheet(new org.apache.xalan.processor.TransformerFactoryImpl());
+ }
+
+ public void testStyleSheetWithSaxon() throws Exception {
+ testStylesheet(new net.sf.saxon.TransformerFactoryImpl());
+ }
+
+ // This test failed with Saxon 8.9 because NodeImpl#compareDocumentPosition
+ // threw an UnsupportedOperationException instead of a DOMException.
+ private void testIdentity(TransformerFactory tf) throws Exception {
+ DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
+ 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(TransformerTest.class.getResourceAsStream("identity.xslt"));
+ Document output = builder.newDocument();
+ Transformer transformer = tf.newTransformer(new DOMSource(stylesheet));
+ transformer.transform(new DOMSource(document), new DOMResult(output));
+ XMLUnit.setIgnoreWhitespace(false);
+ assertXMLEqual(document, output);
+ }
+
+ public void testIdentityWithXalan() throws Exception {
+ testIdentity(new org.apache.xalan.processor.TransformerFactoryImpl());
+ }
+
+ public void testIdentityWithSaxon() throws Exception {
+ testIdentity(new net.sf.saxon.TransformerFactoryImpl());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/TransformerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt?rev=728721&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt Mon Dec 22 08:21:05 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml"/>
+ <xsl:template match="node()|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/identity.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml?rev=728721&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml Mon Dec 22 08:21:05 2008
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sales>
+ <division id="North">
+ <revenue>10</revenue>
+ <growth>9</growth>
+ <bonus>7</bonus>
+ </division>
+ <division id="South">
+ <revenue>4</revenue>
+ <growth>3</growth>
+ <bonus>4</bonus>
+ </division>
+ <division id="West">
+ <revenue>6</revenue>
+ <growth>-1.5</growth>
+ <bonus>2</bonus>
+ </division>
+</sales>
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/input.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml?rev=728721&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml Mon Dec 22 08:21:05 2008
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg width="3in" height="3in"
+ xmlns="http://www.w3.org/2000/svg">
+ <g style="stroke: #000000">
+ <line x1="0" x2="150" y1="150" y2="150"/>
+ <line x1="0" x2="0" y1="0" y2="150"/>
+ <text x="0" y="10">Revenue</text>
+ <text x="150" y="165">Division</text>
+ <rect x="10" y="50" width="20" height="100"/>
+ <text x="10" y="165">North</text>
+ <text x="10" y="45">10</text>
+ <rect x="50" y="110" width="20" height="40"/>
+ <text x="50" y="165">South</text>
+ <text x="50" y="105">4</text>
+ <rect x="90" y="90" width="20" height="60"/>
+ <text x="90" y="165">West</text>
+ <text x="90" y="85">6</text>
+ </g>
+</svg>
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/output.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt?rev=728721&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt Mon Dec 22 08:21:05 2008
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/2000/svg">
+
+ <xsl:output method="xml" indent="yes" media-type="image/svg"/>
+
+ <xsl:template match="/">
+ <svg width = "3in" height="3in">
+ <g style = "stroke: #000000">
+ <!-- draw the axes -->
+ <line x1="0" x2="150" y1="150" y2="150"/>
+ <line x1="0" x2="0" y1="0" y2="150"/>
+ <text x="0" y="10">Revenue</text>
+ <text x="150" y="165">Division</text>
+ <xsl:for-each select="sales/division">
+ <!-- define some useful variables -->
+
+ <!-- the bar's x position -->
+ <xsl:variable name="pos"
+ select="(position()*40)-30"/>
+
+ <!-- the bar's height -->
+ <xsl:variable name="height"
+ select="revenue*10"/>
+
+ <!-- the rectangle -->
+ <rect x="{$pos}" y="{150-$height}"
+ width="20" height="{$height}"/>
+
+ <!-- the text label -->
+ <text x="{$pos}" y="165">
+ <xsl:value-of select="@id"/>
+ </text>
+
+ <!-- the bar value -->
+ <text x="{$pos}" y="{145-$height}">
+ <xsl:value-of select="revenue"/>
+ </text>
+ </xsl:for-each>
+ </g>
+ </svg>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/stylesheet.xslt
------------------------------------------------------------------------------
svn:eol-style = native