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/17 14:11:39 UTC

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

Author: veithen
Date: Wed Dec 17 05:11:38 2008
New Revision: 727371

URL: http://svn.apache.org/viewvc?rev=727371&view=rev
Log:
DOOM: Fixed an issue where detach() didn't work correctly if the next sibling had not been built yet.

Modified:
    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-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java

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=727371&r1=727370&r2=727371&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 Wed Dec 17 05:11:38 2008
@@ -114,6 +114,7 @@
             if (!done) {
                 build();
             }
+            getNextOMSibling(); // Make sure that nextSibling is set correctly
             if (previousSibling == null) { // This is the first child
                 if (nextSibling != null) {
                     this.parentNode.setFirstChild(nextSibling);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=727371&r1=727370&r2=727371&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementTestBase.java Wed Dec 17 05:11:38 2008
@@ -24,6 +24,8 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 
+import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
+
 public abstract class OMElementTestBase extends AbstractTestCase {
     protected abstract OMFactory getOMFactory();
 
@@ -101,4 +103,31 @@
         assertXMLEqual("<ns:parent xmlns:ns=\"http://www.testuri.com\">" +
                 "<ns:c1 /><ns:c2 /><ns:c3 /></ns:parent>", parent.toString());
     }
+
+    private void testDetach(boolean build) throws Exception {
+        OMElement root = AXIOMUtil.stringToOM(getOMFactory(), "<root><a/><b/><c/></root>");
+        if (build) {
+            root.build();
+        } else {
+            assertFalse(root.isComplete());
+        }
+        OMElement a = (OMElement)root.getFirstOMChild();
+        assertEquals("a", a.getLocalName());
+        OMElement b = (OMElement)a.getNextOMSibling();
+        assertEquals("b", b.getLocalName());
+        b.detach();
+        assertNull(b.getParent());
+        OMElement c = (OMElement)a.getNextOMSibling();
+        assertEquals("c", c.getLocalName());
+        assertSame(c, a.getNextOMSibling());
+        assertSame(a, c.getPreviousOMSibling());
+    }
+    
+    public void testDetachWithBuild() throws Exception {
+        testDetach(true);
+    }
+    
+    public void testDetachWithoutBuild() throws Exception {
+        testDetach(false);
+    }
 }