ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1719704 - in /webservices/axiom/trunk: implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/ testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/d...
Date Sat, 12 Dec 2015 15:41:31 GMT
Author: veithen
Date: Sat Dec 12 15:41:31 2015
New Revision: 1719704

URL: http://svn.apache.org/viewvc?rev=1719704&view=rev
Log:
Increase test coverage of DOM's importNode.

Added:
    webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java
  (with props)
    webservices/axiom/trunk/testing/xml-testsuite/src/main/resources/org/apache/axiom/ts/xml/bulk/sigEncr.xml
      - copied, changed from r1718932, webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/sigEncr.xml
Removed:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/sigEncr.xml
Modified:
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
    webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
    webservices/axiom/trunk/testing/dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1719704&r1=1719703&r2=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Sat Dec 12 15:41:31 2015
@@ -38,6 +38,7 @@ import org.w3c.dom.DocumentType;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
 
 public class DocumentImpl extends ParentNode implements DOMDocument, AxiomDocument {
     private Vector idAttrs;
@@ -141,9 +142,13 @@ public class DocumentImpl extends Parent
                 newNode = createCDATASection(importedNode.getNodeValue());
                 break;
             
+            case Node.PROCESSING_INSTRUCTION_NODE: {
+                ProcessingInstruction pi = (ProcessingInstruction)importedNode;
+                newNode = createProcessingInstruction(pi.getTarget(), pi.getData());
+                break;
+            }
             case Node.ENTITY_REFERENCE_NODE:
             case Node.ENTITY_NODE:
-            case Node.PROCESSING_INSTRUCTION_NODE:
             case Node.DOCUMENT_TYPE_NODE:
             case Node.NOTATION_NODE:
                 throw new UnsupportedOperationException("TODO : Implement handling of org.w3c.dom.Node
type == " + type );

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1719704&r1=1719703&r2=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Sat Dec 12 15:41:31 2015
@@ -18,8 +18,11 @@
  */
 package org.apache.axiom.ts.omdom;
 
+import static org.apache.axiom.testing.multiton.Multiton.getInstances;
+
 import org.apache.axiom.om.dom.DOMMetaFactory;
 import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
+import org.apache.axiom.ts.xml.XMLSample;
 
 /**
  * Builds a test suite for Axiom implementations that also implement DOM. Note that this
test suite
@@ -41,7 +44,9 @@ public class OMDOMTestSuiteBuilder exten
         addTest(new org.apache.axiom.ts.omdom.document.TestCreateDocumentFragmentInterfaces(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.document.TestGetOMFactory1(metaFactory));
         addTest(new org.apache.axiom.ts.omdom.document.TestGetOMFactory2(metaFactory));
-        addTest(new org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory));
+        for (XMLSample sample : getInstances(XMLSample.class)) {
+            addTest(new org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory, sample));
+        }
         addTest(new org.apache.axiom.ts.omdom.document.TestInsertBeforeForbidden(metaFactory,
true));
         addTest(new org.apache.axiom.ts.omdom.document.TestInsertBeforeForbidden(metaFactory,
false));
         addTest(new org.apache.axiom.ts.omdom.element.TestAddAttributeReplace(metaFactory));

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java?rev=1719704&r1=1719703&r2=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
Sat Dec 12 15:41:31 2015
@@ -24,29 +24,31 @@ import static org.apache.axiom.truth.xml
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.dom.DOMMetaFactory;
-import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.ConformanceTestCase;
+import org.apache.axiom.ts.jaxp.DOMImplementation;
+import org.apache.axiom.ts.xml.XMLSample;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-public class TestImportNode extends AxiomTestCase {
-    public TestImportNode(OMMetaFactory metaFactory) {
-        super(metaFactory);
+public class TestImportNode extends ConformanceTestCase {
+    public TestImportNode(OMMetaFactory metaFactory, XMLSample file) {
+        super(metaFactory, file);
     }
 
     protected void runTest() throws Throwable {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        DocumentBuilderFactory dbf = DOMImplementation.XERCES.newDocumentBuilderFactory();
         dbf.setNamespaceAware(true);
-        Document doc = dbf.newDocumentBuilder().parse(
-                AbstractTestCase.getTestResource("sigEncr.xml"));
+        Document doc = dbf.newDocumentBuilder().parse(file.getUrl().toString());
         Document doc2 = ((DOMMetaFactory)metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
         Node n = doc2.importNode(doc.getDocumentElement(), true);
         assertAbout(xml())
                 .that(xml(OMElement.class, (OMElement)n))
+                // Import discards DTD information
+                .treatingElementContentWhitespaceAsText()
                 .hasSameContentAs(xml(Element.class, doc.getDocumentElement()));
     }
 }

Modified: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1719704&r1=1719703&r2=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
Sat Dec 12 15:41:31 2015
@@ -31,6 +31,7 @@ import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
+import org.apache.axiom.ts.jaxp.DOMImplementation;
 import org.apache.axiom.ts.jaxp.XSLTImplementation;
 import org.apache.axiom.ts.xml.XMLSample;
 import org.objectweb.asm.ClassReader;
@@ -140,6 +141,11 @@ public final class DOMTestSuiteBuilder e
         addTest(new org.apache.axiom.ts.dom.element.TestGetNamespaceURIWithNoNamespace(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestGetPrefixWithDefaultNamespace(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestGetTextContent(dbf));
+        for (XMLSample file : getInstances(XMLSample.class)) {
+            for (DOMImplementation from : getInstances(DOMImplementation.class)) {
+                addTest(new org.apache.axiom.ts.dom.element.TestImportNode(dbf, file, from));
+            }
+        }
         addTest(new org.apache.axiom.ts.dom.element.TestInsertBefore(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestInsertBeforeWithDocumentFragment(dbf));
         addTest(new org.apache.axiom.ts.dom.element.TestLookupNamespaceURIDefaultBindings(dbf));

Added: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java?rev=1719704&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java
(added)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java
Sat Dec 12 15:41:31 2015
@@ -0,0 +1,56 @@
+/*
+ * 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.element;
+
+import static com.google.common.truth.Truth.assertAbout;
+import static org.apache.axiom.truth.xml.XMLTruth.xml;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.apache.axiom.ts.jaxp.DOMImplementation;
+import org.apache.axiom.ts.xml.XMLSample;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestImportNode extends DOMTestCase {
+    private final XMLSample file;
+    private final DOMImplementation from;
+
+    public TestImportNode(DocumentBuilderFactory dbf, XMLSample file, DOMImplementation from)
{
+        super(dbf);
+        this.file = file;
+        addTestParameter("file", file.getName());
+        this.from = from;
+        addTestParameter("from", from.getName());
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        DocumentBuilderFactory foreignFactory = from.newDocumentBuilderFactory();
+        foreignFactory.setNamespaceAware(true);
+        Element orgElement = foreignFactory.newDocumentBuilder().parse(file.getUrl().toString()).getDocumentElement();
+        Document doc = dbf.newDocumentBuilder().newDocument();
+        assertAbout(xml())
+                .that(xml(Element.class, (Element)doc.importNode(orgElement, true)))
+                // Import discards DTD information
+                .treatingElementContentWhitespaceAsText()
+                .hasSameContentAs(orgElement);
+    }
+}

Propchange: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestImportNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/testing/dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java?rev=1719704&r1=1719703&r2=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
(original)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
Sat Dec 12 15:41:31 2015
@@ -25,6 +25,7 @@ import junit.framework.TestSuite;
 
 import org.apache.axiom.ts.dom.document.TestLookupNamespaceURIWithEmptyDocument;
 import org.apache.axiom.ts.dom.document.TestLookupPrefixWithEmptyDocument;
+import org.apache.axiom.ts.dom.element.TestImportNode;
 import org.apache.axiom.ts.dom.element.TestLookupNamespaceURIXercesJ1586;
 import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
 
@@ -43,6 +44,9 @@ public class XercesTest extends TestCase
         // XERCESJ-1586
         builder.exclude(TestLookupNamespaceURIXercesJ1586.class);
         
+        // Xerces has difficulties importing nodes from Crimson
+        builder.exclude(TestImportNode.class, "(from=crimson)");
+        
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrgetvalue2)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS06)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument08)");

Copied: webservices/axiom/trunk/testing/xml-testsuite/src/main/resources/org/apache/axiom/ts/xml/bulk/sigEncr.xml
(from r1718932, webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/sigEncr.xml)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/resources/org/apache/axiom/ts/xml/bulk/sigEncr.xml?p2=webservices/axiom/trunk/testing/xml-testsuite/src/main/resources/org/apache/axiom/ts/xml/bulk/sigEncr.xml&p1=webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/sigEncr.xml&r1=1718932&r2=1719704&rev=1719704&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/sigEncr.xml (original)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/resources/org/apache/axiom/ts/xml/bulk/sigEncr.xml
Sat Dec 12 15:41:31 2015
@@ -1,4 +1,4 @@
-<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
     <s:Header>
         <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
             <u:Timestamp u:Id="uuid-c46b1c73-532c-4ee6-ab98-4f985c232697-11">



Mime
View raw message