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 sc...@apache.org on 2008/08/08 15:09:18 UTC

svn commit: r683960 - in /webservices/commons/trunk/modules/axiom/modules: axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java

Author: scheu
Date: Fri Aug  8 06:09:17 2008
New Revision: 683960

URL: http://svn.apache.org/viewvc?rev=683960&view=rev
Log:
WSCOMMONS-369
When an OMSE child is added to a parent, the "isComplete" setting should not be propogated to the parent.
(An OMSE is sourced by an independent OMDataSource and parser.  Therefore its complete setting should never
be propogated to its parent or ancestors).

Kudos to Michael Rheinheimer for his hard work debugging this issue.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=683960&r1=683959&r2=683960&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Fri Aug  8 06:09:17 2008
@@ -28,6 +28,7 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMContainerEx;
@@ -302,7 +303,14 @@
             lastChild = child;
         }
 
-        if (!child.isComplete()) {
+        // For a normal OMNode, the incomplete status is
+        // propogated up the tree.  
+        // However, a OMSourcedElement is self-contained 
+        // (it has an independent parser source).
+        // So only propogate the incomplete setting if this
+        // is a normal OMNode
+        if (!child.isComplete() && 
+            !(child instanceof OMSourcedElement)) {
             this.setComplete(false);
         }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java?rev=683960&r1=683959&r2=683960&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java Fri Aug  8 06:09:17 2008
@@ -98,6 +98,46 @@
         root.addChild(element);
     }
 
+    /**
+     * Make sure that the incomplete setting of an OMSE is not 
+     * propogated to the root
+     **/
+    public void testComplete() {
+        
+        // Build a root element and child OMSE
+        OMFactory f = new OMLinkedListImplFactory();
+        OMNamespace ns = new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "");
+        OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
+        OMElement child = new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
+        OMElement root = f.createOMElement("root", rootNS);
+        
+        // Trigger expansion of the child OMSE
+        // This will cause the child to be partially parsed (i.e. incomplete)
+        child.getChildren();
+        
+        // Add the child OMSE to the root.
+        root.addChild(child);
+        
+        // Normally adding an incomplete child to a parent will 
+        // cause the parent to be marked as incomplete.
+        // But OMSE's are self-contained...therefore the root
+        // should still be complete
+        assertTrue(!child.isComplete());
+        assertTrue(root.isComplete());
+        
+        // Now repeat the test, but this time trigger the 
+        // partial parsing of the child after adding it to the root.
+        child = new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
+        root = f.createOMElement("root", rootNS);
+        
+        root.addChild(child);
+        child.getChildren(); // causes partial parsing...i.e. incomplete child
+    
+        assertTrue(!child.isComplete());
+        assertTrue(root.isComplete());
+    }
+    
+    
     /** Ensure that each method of OMElementImpl is overridden in OMSourcedElementImpl */
     public void testMethodOverrides() {
         Method[] submeths = OMSourcedElementImpl.class.getDeclaredMethods();