Author: veithen
Date: Mon Oct 24 22:06:34 2011
New Revision: 1188411
URL: http://svn.apache.org/viewvc?rev=1188411&view=rev
Log:
AXIOM-315: Fixed known issues with respect to node completeness in DOOM.
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-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.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-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestIsCompleteAfterAddingIncompleteChild.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestSerializeAndConsumeWithIncompleteDescendant.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=1188411&r1=1188410&r2=1188411&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
Mon Oct 24 22:06:34 2011
@@ -44,7 +44,7 @@ public abstract class ChildNode extends
}
public OMNode getNextOMSibling() throws OMException {
- while (nextSibling == null && this.parentNode != null &&
!this.parentNode.done) {
+ while (nextSibling == null && this.parentNode != null &&
!this.parentNode.done && parentNode.builder != null) {
this.parentNode.buildNext();
}
return nextSibling;
@@ -222,4 +222,14 @@ public abstract class ChildNode extends
return newnode;
}
+ public void setComplete(boolean state) {
+ super.setComplete(state);
+ if (parentNode != null) {
+ if (!done) {
+ parentNode.setComplete(false);
+ } else {
+ parentNode.notifyChildComplete();
+ }
+ }
+ }
}
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=1188411&r1=1188410&r2=1188411&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
Mon Oct 24 22:06:34 2011
@@ -26,6 +26,7 @@ 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.OMSourcedElement;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.impl.OMContainerEx;
@@ -89,8 +90,9 @@ public abstract class ParentNode extends
}
public void buildNext() {
- if (!this.done)
+ if (builder != null) {
builder.next();
+ }
}
public Iterator getChildren() {
@@ -275,7 +277,6 @@ public abstract class ParentNode extends
if (newDomChild.parentNode == null) {
newDomChild.parentNode = this;
}
- return newChild;
} else {
Iterator children = this.getChildren();
boolean found = false;
@@ -367,8 +368,13 @@ public abstract class ParentNode extends
newDomChild.parentNode = this;
}
- return newChild;
}
+
+ if (!newDomChild.isComplete() && !(newDomChild instanceof
OMSourcedElement)) {
+ setComplete(false);
+ }
+
+ return newChild;
}
/** Replaces the oldChild with the newChild. */
@@ -706,4 +712,17 @@ public abstract class ParentNode extends
public SAXSource getSAXSource(boolean cache) {
return new OMSource(this);
}
+
+ void notifyChildComplete() {
+ if (!this.done && builder == null) {
+ Iterator iterator = getChildren();
+ while (iterator.hasNext()) {
+ OMNode node = (OMNode) iterator.next();
+ if (!node.isComplete()) {
+ return;
+ }
+ }
+ this.setComplete(true);
+ }
+ }
}
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=1188411&r1=1188410&r2=1188411&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
Mon Oct 24 22:06:34 2011
@@ -46,13 +46,8 @@ public class OMImplementationTest extend
builder.exclude(TestSetTextQNameWithEmptyPrefix.class);
builder.exclude(TestSetTextQNameWithoutNamespace.class);
- // TODO: AXIOM-315
-
builder.exclude(org.apache.axiom.ts.om.document.TestIsCompleteAfterAddingIncompleteChild.class);
-
builder.exclude(org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild.class);
-
- // TODO: these need to be investigated; may be related to AXIOM-315
+ // TODO: doesn't work because the test trigger a call to importNode
which will build the descendant
builder.exclude(org.apache.axiom.ts.om.document.TestSerializeAndConsumeWithIncompleteDescendant.class);
-
builder.exclude(org.apache.axiom.ts.om.element.TestSerializeAndConsumeWithIncompleteDescendant.class);
// TODO: Axiom should throw an exception if an attempt is made to
create a cyclic parent-child relationship
builder.exclude(TestInsertSiblingAfterOnChild.class);
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestIsCompleteAfterAddingIncompleteChild.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestIsCompleteAfterAddingIncompleteChild.java?rev=1188411&r1=1188410&r2=1188411&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestIsCompleteAfterAddingIncompleteChild.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestIsCompleteAfterAddingIncompleteChild.java
Mon Oct 24 22:06:34 2011
@@ -41,7 +41,8 @@ public class TestIsCompleteAfterAddingIn
OMFactory factory = metaFactory.getOMFactory();
OMElement incompleteElement =
OMXMLBuilderFactory.createOMBuilder(factory,
new
StringReader("<elem>text</elem>")).getDocumentElement(true);
- OMDocument document = factory.createOMDocument();
+ // TODO: need to get the OMFactory again because for DOOM, it is
stateful
+ OMDocument document = metaFactory.getOMFactory().createOMDocument();
assertTrue(document.isComplete());
document.addChild(incompleteElement);
assertFalse(document.isComplete());
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestSerializeAndConsumeWithIncompleteDescendant.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestSerializeAndConsumeWithIncompleteDescendant.java?rev=1188411&r1=1188410&r2=1188411&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestSerializeAndConsumeWithIncompleteDescendant.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestSerializeAndConsumeWithIncompleteDescendant.java
Mon Oct 24 22:06:34 2011
@@ -45,7 +45,8 @@ public class TestSerializeAndConsumeWith
OMFactory factory = metaFactory.getOMFactory();
OMElement incompleteElement =
OMXMLBuilderFactory.createOMBuilder(factory,
new
StringReader("<elem>text</elem>")).getDocumentElement(true);
- OMDocument document = factory.createOMDocument();
+ // TODO: need to get the OMFactory again because for DOOM, it is
stateful
+ OMDocument document = metaFactory.getOMFactory().createOMDocument();
OMElement root = factory.createOMElement("root", null, document);
root.addChild(incompleteElement);
StringWriter out = new StringWriter();