Author: veithen
Date: Sun Jan 2 13:06:03 2011
New Revision: 1054397
URL: http://svn.apache.org/viewvc?rev=1054397&view=rev
Log:
DOOM: Fixed a logic error in ElementImpl#internalSerialize which causes
serializeAndConsume to behave incorrectly.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1054397&r1=1054396&r2=1054397&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Sun Jan 2 13:06:03 2011
@@ -1076,7 +1076,7 @@ public class ElementImpl extends ParentN
public void internalSerialize(XMLStreamWriter writer,
boolean cache) throws XMLStreamException {
- if (!cache) {
+ if (cache) {
// in this case we don't care whether the elements are built or not
// we just call the serializeAndConsume methods
OMSerializerUtil.serializeStartpart(this, writer);
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java?rev=1054397&r1=1054396&r2=1054397&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
Sun Jan 2 13:06:03 2011
@@ -81,7 +81,8 @@ public class AxiomTestSuiteBuilder {
addTest(new
org.apache.axiom.ts.om.element.TestSerializationWithTwoNonBuiltOMElements(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestSerializeAndConsumeWithIncompleteDescendant(metaFactory));
for (int i=0; i<conformanceFiles.length; i++) {
- addTest(new
org.apache.axiom.ts.om.element.TestSerializeToOutputStream(metaFactory,
conformanceFiles[i]));
+ addTest(new
org.apache.axiom.ts.om.element.TestSerializeToOutputStream(metaFactory,
conformanceFiles[i], true));
+ addTest(new
org.apache.axiom.ts.om.element.TestSerializeToOutputStream(metaFactory,
conformanceFiles[i], false));
}
addTest(new
org.apache.axiom.ts.om.element.TestSetTextQName(metaFactory));
addTest(new
org.apache.axiom.ts.om.factory.TestCreateOMElement(metaFactory));
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java?rev=1054397&r1=1054396&r2=1054397&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeToOutputStream.java
Sun Jan 2 13:06:03 2011
@@ -27,6 +27,7 @@ import javax.xml.transform.TransformerFa
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.util.StAXParserConfiguration;
@@ -35,8 +36,12 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
public class TestSerializeToOutputStream extends ConformanceTestCase {
- public TestSerializeToOutputStream(OMMetaFactory metaFactory, String file)
{
+ private final boolean cache;
+
+ public TestSerializeToOutputStream(OMMetaFactory metaFactory, String file,
boolean cache) {
super(metaFactory, file);
+ this.cache = cache;
+ setName(getName() + " [cache=" + cache + "]");
}
protected void runTest() throws Throwable {
@@ -58,10 +63,22 @@ public class TestSerializeToOutputStream
OMXMLParserWrapper builder =
metaFactory.createOMBuilder(metaFactory.getOMFactory(),
StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
try {
+ OMElement element = builder.getDocumentElement();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- builder.getDocumentElement().serialize(baos);
+ if (cache) {
+ element.serialize(baos);
+ } else {
+ element.serializeAndConsume(baos);
+ }
assertXMLIdentical(compareXML(new InputSource(new
ByteArrayInputStream(control)),
new InputSource(new
ByteArrayInputStream(baos.toByteArray()))), true);
+ if (cache) {
+ assertTrue(element.isComplete());
+ } else {
+ // TODO: need to investigate why assertConsumed is not
working here
+ assertFalse(element.isComplete());
+// assertConsumed(element);
+ }
} finally {
builder.close();
}