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 2012/12/30 16:14:21 UTC
svn commit: r1426952 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/impl/builder/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelem...
Author: veithen
Date: Sun Dec 30 15:14:20 2012
New Revision: 1426952
URL: http://svn.apache.org/viewvc?rev=1426952&view=rev
Log:
Consuming an OMSourcedElement should not change the state of the parent node.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java?rev=1426952&r1=1426951&r2=1426952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java Sun Dec 30 15:14:20 2012
@@ -535,14 +535,15 @@ public abstract class StAXBuilder implem
parserAccessed = true;
// Mark all containers in the hierarchy as discarded because they can no longer be built
OMContainerEx current = target;
- while (current != null) {
+ while (elementLevel > 0) {
discarded(current);
- if (current instanceof OMElement) {
- current = (OMContainerEx)((OMElement)current).getParent();
- } else {
- current = null;
- }
+ current = (OMContainerEx)((OMElement)current).getParent();
+ elementLevel--;
}
+ if (current != null && current == document) {
+ discarded(current);
+ }
+ target = null;
return parser;
} else {
throw new IllegalStateException(
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1426952&r1=1426951&r2=1426952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Sun Dec 30 15:14:20 2012
@@ -465,10 +465,14 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterEmbedded(metaFactory));
for (int expand = 0; expand <= 2; expand++) {
for (int count = 1; count <= 2; count++) {
- addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, false, expand, count));
- addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, true, expand, count));
- addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, false, expand, count));
- addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, true, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, false, false, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, false, true, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, true, false, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, true, true, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, false, false, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, false, true, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, true, false, expand, count));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, true, true, expand, count));
}
}
addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReaderEmbedded(metaFactory));
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java?rev=1426952&r1=1426951&r2=1426952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java Sun Dec 30 15:14:20 2012
@@ -21,6 +21,7 @@ package org.apache.axiom.ts.om.sourcedel
import java.io.StringWriter;
import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMSourcedElement;
@@ -34,6 +35,7 @@ import org.custommonkey.xmlunit.XMLAsser
*/
public class TestSerializeToXMLWriterFromReader extends AxiomTestCase {
private final boolean destructive;
+ private final boolean orphan;
private final boolean cache;
private final int expand;
private final int count;
@@ -45,6 +47,9 @@ public class TestSerializeToXMLWriterFro
* the meta factory for the implementation to be tested
* @param destructive
* determines if the {@link OMDataSource} is destructive or not
+ * @param orphan
+ * determines if the test is to be executed on an {@link OMSourcedElement} that has a
+ * parent or not
* @param cache
* the argument to be passed to {@link OMSourcedElement#getXMLStreamReader(boolean)}
* @param expand
@@ -55,13 +60,15 @@ public class TestSerializeToXMLWriterFro
* the number of times {@link OMSourcedElement#getXMLStreamReader(boolean)} will be
* called; the only meaningful values are 1 and 2
*/
- public TestSerializeToXMLWriterFromReader(OMMetaFactory metaFactory, boolean destructive, boolean cache, int expand, int count) {
+ public TestSerializeToXMLWriterFromReader(OMMetaFactory metaFactory, boolean destructive, boolean orphan, boolean cache, int expand, int count) {
super(metaFactory);
this.destructive = destructive;
+ this.orphan = orphan;
this.cache = cache;
this.expand = expand;
this.count = count;
addTestProperty("destructive", String.valueOf(destructive));
+ addTestProperty("orphan", String.valueOf(orphan));
addTestProperty("cache", String.valueOf(cache));
addTestProperty("expand", String.valueOf(expand));
addTestProperty("count", String.valueOf(count));
@@ -69,7 +76,16 @@ public class TestSerializeToXMLWriterFro
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
+ OMElement parent;
+ if (orphan) {
+ parent = null;
+ } else {
+ parent = factory.createOMElement("parent", null);
+ }
OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(factory, destructive);
+ if (parent != null) {
+ parent.addChild(element);
+ }
if (expand != 0) {
element.getFirstOMChild();
}
@@ -102,6 +118,10 @@ public class TestSerializeToXMLWriterFro
} else {
assertFalse(element.isExpanded());
}
+ if (parent != null) {
+ // Operations on the OMSourcedElement should have no impact on the parent
+ assertTrue(parent.isComplete());
+ }
}
}
}