You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/10/27 22:42:24 UTC

svn commit: r1190012 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/ axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ axiom-tests/...

Author: veithen
Date: Thu Oct 27 20:42:24 2011
New Revision: 1190012

URL: http://svn.apache.org/viewvc?rev=1190012&view=rev
Log:
AXIOM-385: DocumentImpl should implement OMNode because OMDocument doesn't extend OMNode.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMDocument.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    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-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11DefaultFaultConversionTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java Thu Oct 27 20:42:24 2011
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.dom;
 
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.OMNodeEx;
 import org.w3c.dom.CharacterData;
 import org.w3c.dom.DOMException;
 
@@ -27,7 +28,7 @@ import org.w3c.dom.DOMException;
  * This implements the OMText operations which are to be inherited by TextImpl, CommentImpl,
  * CDATASectionImpl.
  */
-public abstract class CharacterImpl extends ChildNode implements CharacterData {
+public abstract class CharacterImpl extends ChildNode implements CharacterData, OMNodeEx {
 
     protected String textValue;
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java Thu Oct 27 20:42:24 2011
@@ -47,11 +47,11 @@ public abstract class ChildNode extends 
         while (nextSibling == null && this.parentNode != null && !this.parentNode.done && parentNode.builder != null) {
             this.parentNode.buildNext();
         }
-        return nextSibling;
+        return (OMNode)nextSibling;
     }
 
     public OMNode getNextOMSiblingIfAvailable() {
-        return nextSibling;
+        return (OMNode)nextSibling;
     }
 
     public Node getNextSibling() {
@@ -59,7 +59,7 @@ public abstract class ChildNode extends 
     }
 
     public OMNode getPreviousOMSibling() {
-        return this.previousSibling;
+        return (OMNode)this.previousSibling;
     }
 
     public Node getPreviousSibling() {
@@ -121,19 +121,19 @@ public abstract class ChildNode extends 
             getNextOMSibling(); // Make sure that nextSibling is set correctly
             if (previousSibling == null) { // This is the first child
                 if (nextSibling != null) {
-                    this.parentNode.setFirstChild(nextSibling);
+                    this.parentNode.setFirstChild((OMNode)nextSibling);
                 } else {
                     this.parentNode.firstChild = null;
                     this.parentNode.lastChild = null;
                 }
             } else {
-                this.previousSibling.setNextOMSibling(nextSibling);
+                this.previousSibling.setNextOMSibling((OMNode)nextSibling);
                 if (nextSibling == null) {
                     this.previousSibling.parentNode.done = true;
                 }
             }
             if (this.nextSibling != null) {
-                this.nextSibling.setPreviousOMSibling(this.previousSibling);
+                this.nextSibling.setPreviousOMSibling((OMNode)this.previousSibling);
                 this.nextSibling = null;
             }
             if (this.parentNode != null && this.parentNode.lastChild == this) {
@@ -142,7 +142,7 @@ public abstract class ChildNode extends 
             this.parentNode = null;
             this.previousSibling = null;
         }
-        return this;
+        return (OMNode)this;
     }
 
     public void discard() throws OMException {
@@ -193,12 +193,12 @@ public abstract class ChildNode extends 
             ChildNode siblingImpl = (ChildNode) sibling;
             siblingImpl.nextSibling = this;
             if (previousSibling == null) {
-                this.parentNode.setFirstChild(siblingImpl);
+                this.parentNode.setFirstChild((OMNode)siblingImpl);
                 siblingImpl.previousSibling = null;
             } else {
                 siblingImpl.setParent(this.parentNode);
-                previousSibling.setNextOMSibling(siblingImpl);
-                siblingImpl.setPreviousOMSibling(previousSibling);
+                previousSibling.setNextOMSibling((OMNode)siblingImpl);
+                siblingImpl.setPreviousOMSibling((OMNode)previousSibling);
             }
             previousSibling = siblingImpl;
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java Thu Oct 27 20:42:24 2011
@@ -25,10 +25,11 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.axiom.om.OMDocType;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.OMNodeEx;
 import org.w3c.dom.DocumentType;
 import org.w3c.dom.NamedNodeMap;
 
-public class DocumentTypeImpl extends ChildNode implements DocumentType, OMDocType {
+public class DocumentTypeImpl extends ChildNode implements DocumentType, OMDocType, OMNodeEx {
     private String value;
     
     public DocumentTypeImpl(DocumentImpl ownerDocument, OMFactory factory) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Thu Oct 27 20:42:24 2011
@@ -28,6 +28,7 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.common.NamespaceIterator;
 import org.apache.axiom.om.impl.common.OMChildElementIterator;
 import org.apache.axiom.om.impl.common.OMDescendantsIterator;
@@ -59,7 +60,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 
 /** Implementation of the org.w3c.dom.Element and org.apache.axiom.om.Element interfaces. */
-public class ElementImpl extends ParentNode implements Element, OMElement,
+public class ElementImpl extends ParentNode implements Element, OMElement, OMNodeEx,
         OMConstants {
 
     private static final Log log = LogFactory.getLog(ElementImpl.class);

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=1190012&r1=1190011&r2=1190012&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 Thu Oct 27 20:42:24 2011
@@ -26,7 +26,6 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
-import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.w3c.dom.DOMException;
@@ -42,7 +41,7 @@ import java.io.OutputStream;
 import java.io.Writer;
 import java.util.Hashtable;
 
-public abstract class NodeImpl implements Node, NodeList, OMNodeEx, Cloneable {
+public abstract class NodeImpl implements Node, NodeList, Cloneable {
 
     /** Holds the user data objects */
     private Hashtable userData; // Will be initialized in setUserData()
@@ -871,4 +870,8 @@ public abstract class NodeImpl implement
     public void internalSerializeAndConsume(XMLStreamWriter writer) throws XMLStreamException {
         internalSerialize(writer, false);
     }
+    
+    // This method is actually defined by OMNodeEx, but OMNodeEx is only implemented
+    // by certain subclasses (for the reason, see AXIOM-385).
+    public abstract void internalSerialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException;
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Thu Oct 27 20:42:24 2011
@@ -147,11 +147,11 @@ public abstract class ParentNode extends
         while ((firstChild == null) && !done) {
             buildNext();
         }
-        return firstChild;
+        return (OMNode)firstChild;
     }
 
     public OMNode getFirstOMChildIfAvailable() {
-        return firstChild;
+        return (OMNode)firstChild;
     }
 
     public void setFirstChild(OMNode omNode) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java Thu Oct 27 20:42:24 2011
@@ -26,11 +26,12 @@ import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMProcessingInstruction;
+import org.apache.axiom.om.impl.OMNodeEx;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 import org.w3c.dom.ProcessingInstruction;
 
-public class ProcessingInstructionImpl extends ChildNode implements ProcessingInstruction, OMProcessingInstruction {
+public class ProcessingInstructionImpl extends ChildNode implements ProcessingInstruction, OMProcessingInstruction, OMNodeEx {
     private String target;
     private String value;
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java Thu Oct 27 20:42:24 2011
@@ -140,7 +140,7 @@ public class SOAPEnvelopeImpl extends SO
                 // body and insert the header.  If the body is not found,
                 // this indicates that it has not been parsed yet...and
                 // the code will fall through to the super.addChild.
-                OMNode node = this.lastChild;
+                OMNode node = (OMNode)this.lastChild;
                 while (node != null) {
                     if (node instanceof SOAPBody) {
                         node.insertSiblingBefore(child);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Thu Oct 27 20:42:24 2011
@@ -36,7 +36,6 @@ import org.apache.axiom.ts.om.factory.Te
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
 import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
-import org.apache.axiom.ts.xpath.TestAXIOMXPath;
 
 public class OMImplementationTest extends TestCase {
     public static TestSuite suite() {
@@ -83,9 +82,6 @@ public class OMImplementationTest extend
         // TODO: if there is a comment node surrounded by text, then these text nodes need to be merged
         builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
         
-        // TODO: investigate this failure
-        builder.exclude(TestAXIOMXPath.class, "(test=id54298)");
-        
         return builder.build();
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11DefaultFaultConversionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11DefaultFaultConversionTest.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11DefaultFaultConversionTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAP11DefaultFaultConversionTest.java Thu Oct 27 20:42:24 2011
@@ -21,7 +21,6 @@ package org.apache.axiom.soap;
 
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
@@ -62,7 +61,7 @@ public class SOAP11DefaultFaultConversio
         StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(
                 envelope.getXMLStreamReader(), factory,SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
         SOAPEnvelope env = stAXSOAPModelBuilder.getSOAPEnvelope();
-        ((OMNode) env.getParent()).build();
+        env.getParent().build();
         
         fault = env.getBody().getFault();
         

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1190012&r1=1190011&r2=1190012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Thu Oct 27 20:42:24 2011
@@ -211,6 +211,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestUndeclarePrefix(metaFactory));
         addTest(new org.apache.axiom.ts.om.factory.TestCreateOMAttributeWithInvalidNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.factory.TestCreateOMCommentWithoutParent(metaFactory));
+        addTest(new org.apache.axiom.ts.om.factory.TestCreateOMDocument(metaFactory));
         for (int i=0; i<OMElementCreator.INSTANCES.length; i++) {
             OMElementCreator creator = OMElementCreator.INSTANCES[i];
             if (creator.isSupportsDefaultNamespace()) {

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMDocument.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMDocument.java?rev=1190012&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMDocument.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMDocument.java Thu Oct 27 20:42:24 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.factory;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestCreateOMDocument extends AxiomTestCase {
+    public TestCreateOMDocument(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMDocument document = metaFactory.getOMFactory().createOMDocument();
+        assertNotNull(document);
+        assertNull(document.getFirstOMChild());
+        
+        // OMDocument doesn't extend OMNode. Therefore, the OMDocument implementation
+        // should not implement OMNode either. This is a regression test for AXIOM-385.
+        assertFalse(document instanceof OMNode);
+    }
+}

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