ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1054127 - in /webservices/commons/trunk/modules/axiom/modules: axiom-tests/src/test/java/org/apache/axiom/om/infoset/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/ axiom-t...
Date Fri, 31 Dec 2010 15:30:10 GMT
Author: veithen
Date: Fri Dec 31 15:30:10 2010
New Revision: 1054127

URL: http://svn.apache.org/viewvc?rev=1054127&view=rev
Log:
AXIOM-311: Replaced XMLConformanceTest (which is not executed by default) by a new test case
that is executed against the set of conformance test files already used in other test cases.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/ConformanceTestCase.java
  (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
  (with props)
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/infoset/
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestGetXMLStreamReader.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java?rev=1054127&r1=1054126&r2=1054127&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
Fri Dec 31 15:30:10 2010
@@ -23,7 +23,6 @@ import java.util.Set;
 
 import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.ts.om.document.TestGetXMLStreamReader;
 
 import junit.framework.TestSuite;
 
@@ -41,14 +40,14 @@ public class AxiomTestSuiteBuilder {
     }
     
     public TestSuite build() {
+        String[] conformanceFiles = AbstractTestCase.getConformanceTestFiles();
         suite = new TestSuite();
         addTest(new org.apache.axiom.ts.om.attribute.TestGetQName(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElementWithDiscardDocument(metaFactory));
         addTest(new org.apache.axiom.ts.om.document.TestSerializeAndConsumeWithIncompleteDescendant(metaFactory));
-        String[] files = AbstractTestCase.getConformanceTestFiles();
-        for (int i=0; i<files.length; i++) {
-            addTest(new TestGetXMLStreamReader(metaFactory, files[i]));
+        for (int i=0; i<conformanceFiles.length; i++) {
+            addTest(new org.apache.axiom.ts.om.document.TestGetXMLStreamReader(metaFactory,
conformanceFiles[i]));
         }
         addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationInScope(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationOnSameElement(metaFactory));
@@ -80,6 +79,9 @@ public class AxiomTestSuiteBuilder {
                 "<person><name xmlns=\"urn:ns\">John</name><age xmlns=\"urn:ns\">34</age><weight
xmlns=\"urn:ns\">50</weight></person>"));
         addTest(new org.apache.axiom.ts.om.element.TestSerializationWithTwoNonBuiltOMElements(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestSerializeAndConsumeWithIncompleteDescendant(metaFactory));
+        for (int i=0; i<conformanceFiles.length; i++) {
+            addTest(new org.apache.axiom.ts.om.element.TestSerializeToOutputStream(metaFactory,
conformanceFiles[i]));
+        }
         addTest(new org.apache.axiom.ts.om.element.TestSetTextQName(metaFactory));
         addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, true));
         addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, false));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/ConformanceTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/ConformanceTestCase.java?rev=1054127&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/ConformanceTestCase.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/ConformanceTestCase.java
Fri Dec 31 15:30:10 2010
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.io.InputStream;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMMetaFactory;
+
+/**
+ * Base class for test cases that are executed against the files from the conformance test
set.
+ * 
+ * @see org.apache.axiom.om.AbstractTestCase#getConformanceTestFiles()
+ */
+public abstract class ConformanceTestCase extends AxiomTestCase {
+    private final String file;
+
+    public ConformanceTestCase(OMMetaFactory metaFactory, String file) {
+        super(metaFactory);
+        this.file = file;
+        int idx = file.lastIndexOf('/');
+        setName(getName() + " [file=" + file.substring(idx+1) + "]");
+    }
+
+    protected InputStream getFileAsStream() {
+        return AbstractTestCase.getTestResource(file);
+    }
+}

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

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestGetXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestGetXMLStreamReader.java?rev=1054127&r1=1054126&r2=1054127&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestGetXMLStreamReader.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestGetXMLStreamReader.java
Fri Dec 31 15:30:10 2010
@@ -22,31 +22,25 @@ import java.io.InputStream;
 
 import javax.xml.stream.XMLStreamReader;
 
-import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.impl.OMStAXWrapper;
 import org.apache.axiom.om.impl.RootWhitespaceFilter;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
-import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.ConformanceTestCase;
 
 /**
  * Test comparing the output of {@link OMStAXWrapper} with that of a native StAX parser.
  */
-public class TestGetXMLStreamReader extends AxiomTestCase {
-    private final String file;
-    
+public class TestGetXMLStreamReader extends ConformanceTestCase {
     public TestGetXMLStreamReader(OMMetaFactory metaFactory, String file) {
-        super(metaFactory);
-        this.file = file;
-        int idx = file.lastIndexOf('/');
-        setName(getName() + " [file=" + file.substring(idx+1) + "]");
+        super(metaFactory, file);
     }
     
     protected void runTest() throws Throwable {
-        InputStream in1 = AbstractTestCase.getTestResource(file);
-        InputStream in2 = AbstractTestCase.getTestResource(file);
+        InputStream in1 = getFileAsStream();
+        InputStream in2 = getFileAsStream();
         try {
             XMLStreamReader expected = StAXUtils.createXMLStreamReader(in1);
             try {

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java?rev=1054127&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
Fri Dec 31 15:30:10 2010
@@ -0,0 +1,74 @@
+/*
+ * 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.om.element;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.ts.ConformanceTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+public class TestSerializeToOutputStream extends ConformanceTestCase {
+    public TestSerializeToOutputStream(OMMetaFactory metaFactory, String file) {
+        super(metaFactory, file);
+    }
+
+    protected void runTest() throws Throwable {
+        InputStream in = getFileAsStream();
+        byte[] control;
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            Document doc = dbf.newDocumentBuilder().parse(in);
+            // By default Axiom doesn't preserve CDATA sections; replace them by text nodes
+            // in the control document
+            doc.getDomConfig().setParameter("cdata-sections", Boolean.FALSE);
+            doc.normalizeDocument();
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            TransformerFactory.newInstance().newTransformer().transform(
+                    new DOMSource(doc.getDocumentElement()), new StreamResult(baos));
+            control = baos.toByteArray();
+        } finally {
+            in.close();
+        }
+        in = getFileAsStream();
+        try {
+            OMXMLParserWrapper builder = metaFactory.createOMBuilder(metaFactory.getOMFactory(),
in);
+            try {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                builder.getDocumentElement().serialize(baos);
+                assertXMLIdentical(compareXML(new InputSource(new ByteArrayInputStream(control)),
+                        new InputSource(new ByteArrayInputStream(baos.toByteArray()))), true);
+            } finally {
+                builder.close();
+            }
+        } finally {
+            in.close();
+        }
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message