Author: veithen
Date: Sat Apr 14 18:20:41 2012
New Revision: 1326171

URL: http://svn.apache.org/viewvc?rev=1326171&view=rev
Log:
AXIOM-412: Fixed a regression introduced by r1326115.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.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/ParentNode.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java?rev=1326171&r1=1326170&r2=1326171&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java
 Sat Apr 14 18:20:41 2012
@@ -24,7 +24,9 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 
 public class TestRemoveSingleChild extends DOMTestCase {
@@ -34,10 +36,16 @@ public class TestRemoveSingleChild exten
 
     protected void runTest() throws Throwable {
         DocumentBuilder builder = dbf.newDocumentBuilder();
-        Element element = builder.parse(new InputSource(new StringReader(
-                "<root><a/></root>"))).getDocumentElement();
-        element.removeChild(element.getFirstChild());
+        Document document = builder.parse(new InputSource(new StringReader(
+                "<root><a/></root>")));
+        Element element = document.getDocumentElement();
+        Node child = element.getFirstChild();
+        element.removeChild(child);
         assertNull(element.getFirstChild());
         assertNull(element.getLastChild());
+        assertNull(child.getPreviousSibling());
+        assertNull(child.getNextSibling());
+        assertNull(child.getParentNode());
+        assertSame(document, child.getOwnerDocument());
     }
 }

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=1326171&r1=1326170&r2=1326171&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
 Sat Apr 14 18:20:41 2012
@@ -191,6 +191,10 @@ public abstract class ChildNode extends 
     }
 
     public OMNode detach() throws OMException {
+        return detach(false);
+    }
+    
+    OMNode detach(boolean useDomSemantics) {
         ParentNode parentNode = parentNode();
         if (parentNode == null) {
             throw new OMException("Parent level elements cannot be detached");
@@ -219,7 +223,7 @@ public abstract class ChildNode extends 
             if (parentNode != null && parentNode.lastChild == this) {
                 parentNode.lastChild = previousSibling;
             }
-            setParent(null, false);
+            setParent(null, useDomSemantics);
             this.previousSibling = null;
         }
         return (OMNode)this;

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=1326171&r1=1326170&r2=1326171&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
 Sat Apr 14 18:20:41 2012
@@ -455,7 +455,7 @@ public abstract class ParentNode extends
     /** Removes the given child from the DOM Tree. */
     public Node removeChild(Node oldChild) throws DOMException {
         if (oldChild.getParentNode() == this) {
-            ((ChildNode)oldChild).detach();
+            ((ChildNode)oldChild).detach(true);
             return oldChild;
         } else {
             throw new DOMException(DOMException.NOT_FOUND_ERR,


Reply via email to