Author: veithen
Date: Sat Jan 1 14:31:48 2011
New Revision: 1054233
URL: http://svn.apache.org/viewvc?rev=1054233&view=rev
Log:
AXIOM-353: Enhanced the OMXMLBuilderFactory API so that a
StAXParserConfiguration can be specified. Used this to improve
TestSerializeToOutputStream, so that it also tests CDATA sections.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXParserConfiguration.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElement.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithDiscardDocument.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializationWithTwoNonBuiltOMElements.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-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMMetaFactory.java
Sat Jan 1 14:31:48 2011
@@ -24,6 +24,7 @@ import java.io.Reader;
import javax.xml.stream.XMLStreamReader;
+import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.soap.SOAPFactory;
/**
@@ -82,11 +83,13 @@ public interface OMMetaFactory {
* @param omFactory
* the object model factory to use; must be obtained from the
same
* {...@link OMMetaFactory}
+ * @param configuration
+ * the parser configuration to use
* @param in
* the input stream representing the XML document
* @return the builder
*/
- OMXMLParserWrapper createOMBuilder(OMFactory omFactory, InputStream in);
+ OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, InputStream in);
/**
* Create an object model builder that reads an XML document from the
provided character
@@ -95,9 +98,11 @@ public interface OMMetaFactory {
* @param omFactory
* the object model factory to use; must be obtained from the
same
* {...@link OMMetaFactory}
+ * @param configuration
+ * the parser configuration to use
* @param in
* the character stream representing the XML document
* @return the builder
*/
- OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Reader in);
+ OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, Reader in);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
Sat Jan 1 14:31:48 2011
@@ -23,6 +23,8 @@ import java.io.Reader;
import javax.xml.stream.XMLStreamReader;
+import org.apache.axiom.om.util.StAXParserConfiguration;
+
/**
* Provides static factory methods to create various kinds of object model
builders from different
* types of input sources. The methods defined by this class are the starting
point to parse XML
@@ -58,21 +60,36 @@ public class OMXMLBuilderFactory {
}
/**
- * Create an object model builder that reads a plain XML document from the
provided input
- * stream.
+ * Create an object model builder that reads a plain XML document from the
provided input stream
+ * with the default parser configuration defined by {...@link
StAXParserConfiguration#DEFAULT}.
*
* @param in
* the input stream representing the XML document
* @return the builder
*/
public static OMXMLParserWrapper createOMBuilder(InputStream in) {
+ return createOMBuilder(StAXParserConfiguration.DEFAULT, in);
+ }
+
+ /**
+ * Create an object model builder that reads a plain XML document from the
provided input stream
+ * with a given parser configuration.
+ *
+ * @param configuration
+ * the parser configuration to use
+ * @param in
+ * the input stream representing the XML document
+ * @return the builder
+ */
+ public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration
configuration, InputStream in) {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory();
- return metaFactory.createOMBuilder(metaFactory.getOMFactory(), in);
+ return metaFactory.createOMBuilder(metaFactory.getOMFactory(),
configuration, in);
}
/**
* Create an object model builder that reads an XML document from the
provided input stream
- * using a specified object model factory.
+ * using a specified object model factory and with the default parser
configuration defined by
+ * {...@link StAXParserConfiguration#DEFAULT}.
*
* @param omFactory
* the object model factory to use
@@ -81,25 +98,57 @@ public class OMXMLBuilderFactory {
* @return the builder
*/
public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
InputStream in) {
- return omFactory.getMetaFactory().createOMBuilder(omFactory, in);
+ return createOMBuilder(omFactory, StAXParserConfiguration.DEFAULT, in);
+ }
+
+ /**
+ * Create an object model builder that reads an XML document from the
provided input stream
+ * using a specified object model factory and with a given parser
configuration.
+ *
+ * @param omFactory
+ * the object model factory to use
+ * @param configuration
+ * the parser configuration to use
+ * @param in
+ * the input stream representing the XML document
+ * @return the builder
+ */
+ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, InputStream in) {
+ return omFactory.getMetaFactory().createOMBuilder(omFactory,
configuration, in);
}
/**
* Create an object model builder that reads a plain XML document from the
provided character
- * stream.
+ * stream with the default parser configuration defined by
+ * {...@link StAXParserConfiguration#DEFAULT}.
*
* @param in
* the character stream representing the XML document
* @return the builder
*/
public static OMXMLParserWrapper createOMBuilder(Reader in) {
+ return createOMBuilder(StAXParserConfiguration.DEFAULT, in);
+ }
+
+ /**
+ * Create an object model builder that reads a plain XML document from the
provided character
+ * stream with a given parser configuration.
+ *
+ * @param configuration
+ * the parser configuration to use
+ * @param in
+ * the character stream representing the XML document
+ * @return the builder
+ */
+ public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration
configuration, Reader in) {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory();
- return metaFactory.createOMBuilder(metaFactory.getOMFactory(), in);
+ return metaFactory.createOMBuilder(metaFactory.getOMFactory(),
configuration, in);
}
/**
* Create an object model builder that reads an XML document from the
provided character stream
- * using a specified object model factory.
+ * using a specified object model factory and with the default parser
configuration defined by
+ * {...@link StAXParserConfiguration#DEFAULT}.
*
* @param omFactory
* the object model factory to use
@@ -108,6 +157,22 @@ public class OMXMLBuilderFactory {
* @return the builder
*/
public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
Reader in) {
- return omFactory.getMetaFactory().createOMBuilder(omFactory, in);
+ return createOMBuilder(omFactory, StAXParserConfiguration.DEFAULT, in);
+ }
+
+ /**
+ * Create an object model builder that reads an XML document from the
provided character stream
+ * using a specified object model factory and with a given parser
configuration.
+ *
+ * @param omFactory
+ * the object model factory to use
+ * @param configuration
+ * the parser configuration to use
+ * @param in
+ * the character stream representing the XML document
+ * @return the builder
+ */
+ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, Reader in) {
+ return omFactory.getMetaFactory().createOMBuilder(omFactory,
configuration, in);
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/AbstractOMMetaFactory.java
Sat Jan 1 14:31:48 2011
@@ -29,6 +29,7 @@ import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.om.util.StAXUtils;
/**
@@ -46,17 +47,17 @@ public abstract class AbstractOMMetaFact
return builder;
}
- public OMXMLParserWrapper createOMBuilder(OMFactory omFactory, InputStream
in) {
+ public OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, InputStream in) {
try {
- return createStAXOMBuilder(omFactory,
StAXUtils.createXMLStreamReader(in));
+ return createStAXOMBuilder(omFactory,
StAXUtils.createXMLStreamReader(configuration, in));
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
}
- public OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Reader in) {
+ public OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
StAXParserConfiguration configuration, Reader in) {
try {
- return createStAXOMBuilder(omFactory,
StAXUtils.createXMLStreamReader(in));
+ return createStAXOMBuilder(omFactory,
StAXUtils.createXMLStreamReader(configuration, in));
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXParserConfiguration.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXParserConfiguration.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXParserConfiguration.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/StAXParserConfiguration.java
Sat Jan 1 14:31:48 2011
@@ -101,6 +101,20 @@ public interface StAXParserConfiguration
};
/**
+ * Configuration that sets up the parser to preserve CDATA sections. This
configuration will
+ * also put the parser in non coalescing mode.
+ */
+ StAXParserConfiguration PRESERVE_CDATA_SECTIONS = new
StAXParserConfiguration() {
+ public XMLInputFactory configure(XMLInputFactory factory, StAXDialect
dialect) {
+ return dialect.enableCDataReporting(factory);
+ }
+
+ public String toString() {
+ return "PRESERVE_CDATA_SECTIONS";
+ }
+ };
+
+ /**
* Configuration suitable for SOAP messages. This will configure the parser
* to throw an exception when it encounters a document type declaration.
The
* SOAP 1.1 specification indeed prescribes that
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
Sat Jan 1 14:31:48 2011
@@ -91,7 +91,7 @@ public abstract class AbstractTestCase
}
public OMElement getTestResourceAsElement(OMMetaFactory omMetaFactory,
String relativePath) {
- return omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(),
getTestResource(relativePath)).getDocumentElement();
+ return
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(),
getTestResource(relativePath)).getDocumentElement();
}
public static String[] getConformanceTestFiles() {
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
Sat Jan 1 14:31:48 2011
@@ -98,7 +98,7 @@ public class OMDocumentTestBase extends
}
private OMDocument getSampleOMDocument(String xml) {
- return omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(), new
StringReader(xml)).getDocument();
+ return
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), new
StringReader(xml)).getDocument();
}
// private OMDocument getSampleOMDocument() {
@@ -119,7 +119,7 @@ public class OMDocumentTestBase extends
public void testBuild() throws Exception {
CountingInputStream in = new CountingInputStream(getTestResource(
TestConstants.REALLY_BIG_MESSAGE));
- OMDocument doc =
omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(), in).getDocument();
+ OMDocument doc =
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(),
in).getDocument();
assertFalse(doc.isComplete());
int countBeforeBuild = in.getCount();
doc.build();
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
Sat Jan 1 14:31:48 2011
@@ -415,7 +415,7 @@ public abstract class OMElementTestBase
elem);
String xml = elem.toString();
- OMXMLParserWrapper builder =
omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(),
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(),
new ByteArrayInputStream(xml.getBytes()));
builder.getDocumentElement().build();
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java
Sat Jan 1 14:31:48 2011
@@ -38,7 +38,7 @@ public class OMXMLParserWrapperTestBase
public void testCloseWithInputStream() throws Exception {
CloseSensorInputStream in = new
CloseSensorInputStream(getTestResource(TestConstants.TEST));
try {
- OMXMLParserWrapper builder =
omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(), in);
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), in);
builder.getDocument().build();
builder.close();
// OMXMLParserWrapper#close() does _not_ close the underlying
input stream
@@ -51,7 +51,7 @@ public class OMXMLParserWrapperTestBase
public void testCloseWithReader() throws Exception {
CloseSensorReader in = new CloseSensorReader(new
StringReader("<root><child/></root>"));
try {
- OMXMLParserWrapper builder =
omMetaFactory.createOMBuilder(omMetaFactory.getOMFactory(), in);
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), in);
builder.getDocument().build();
builder.close();
// OMXMLParserWrapper#close() does _not_ close the underlying
input stream
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElement.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElement.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElement.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElement.java
Sat Jan 1 14:31:48 2011
@@ -23,6 +23,7 @@ import java.io.StringReader;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.ts.AxiomTestCase;
@@ -35,7 +36,7 @@ public class TestGetDocumentElement exte
}
protected void runTest() throws Throwable {
- OMXMLParserWrapper builder =
metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
new StringReader("<!--comment1--><root/><!--comment2-->"));
OMElement element = builder.getDocumentElement();
assertEquals("root", element.getLocalName());
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithDiscardDocument.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithDiscardDocument.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithDiscardDocument.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithDiscardDocument.java
Sat Jan 1 14:31:48 2011
@@ -23,6 +23,7 @@ import java.io.StringReader;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.ts.AxiomTestCase;
@@ -37,7 +38,7 @@ public class TestGetDocumentElementWithD
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
- OMXMLParserWrapper builder = metaFactory.createOMBuilder(factory,
+ OMXMLParserWrapper builder =
OMXMLBuilderFactory.createOMBuilder(factory,
new StringReader("<!--comment1--><root/><!--comment2-->"));
OMElement element = builder.getDocumentElement(true);
assertEquals("root", element.getLocalName());
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializationWithTwoNonBuiltOMElements.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializationWithTwoNonBuiltOMElements.java?rev=1054233&r1=1054232&r2=1054233&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializationWithTwoNonBuiltOMElements.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializationWithTwoNonBuiltOMElements.java
Sat Jan 1 14:31:48 2011
@@ -23,6 +23,7 @@ import java.io.StringReader;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.impl.OMNodeEx;
import org.apache.axiom.ts.AxiomTestCase;
@@ -43,9 +44,11 @@ public class TestSerializationWithTwoNon
OMFactory omFactory = metaFactory.getOMFactory();
OMElement rootElement = omFactory.createOMElement("Root", null);
- OMElement childOne = metaFactory.createOMBuilder(omFactory, new
StringReader(sampleXMLOne)).getDocumentElement(true);
+ OMElement childOne = OMXMLBuilderFactory.createOMBuilder(omFactory,
+ new StringReader(sampleXMLOne)).getDocumentElement(true);
rootElement.addChild(childOne);
- OMElement childTwo = metaFactory.createOMBuilder(omFactory, new
StringReader(sampleXMLTwo)).getDocumentElement(true);
+ OMElement childTwo = OMXMLBuilderFactory.createOMBuilder(omFactory,
+ new StringReader(sampleXMLTwo)).getDocumentElement(true);
((OMNodeEx) childTwo).setParent(null);
rootElement.addChild(childTwo);
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=1054233&r1=1054232&r2=1054233&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
Sat Jan 1 14:31:48 2011
@@ -29,6 +29,7 @@ import javax.xml.transform.stream.Stream
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.ts.ConformanceTestCase;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -45,10 +46,6 @@ public class TestSerializeToOutputStream
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(in);
- // By default Axiom doesn't preserve CDATA sections; replace them
by text nodes
- // in the control document
- doc.getDomConfig().setParameter("cdata-sections", Boolean.FALSE);
- doc.normalizeDocument();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TransformerFactory.newInstance().newTransformer().transform(
new DOMSource(doc.getDocumentElement()), new
StreamResult(baos));
@@ -58,7 +55,8 @@ public class TestSerializeToOutputStream
}
in = getFileAsStream();
try {
- OMXMLParserWrapper builder =
metaFactory.createOMBuilder(metaFactory.getOMFactory(), in);
+ OMXMLParserWrapper builder =
metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.getDocumentElement().serialize(baos);