SWS-639 - Deprecate redundant XML classes
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>wstx-asl</artifactId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
<url>https://fisheye.springframework.org/browse/spring-ws/trunk</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<osgi.version>2.0.0.M3</osgi.version>
|
||||
<osgi.version>2.0.0.M4</osgi.version>
|
||||
<osgi.range>"${osgi.version:[=.=.=, =.=.+1)}"</osgi.range>
|
||||
<spring.framework.version>3.0.3.RELEASE</spring.framework.version>
|
||||
<spring.framework.osgi.range>"[3.0.2, 4.0.0)"</spring.framework.osgi.range>
|
||||
<spring.framework.version>3.0.5.BUILD-SNAPSHOT</spring.framework.version>
|
||||
<spring.framework.osgi.range>"[3.0.5, 4.0.0)"</spring.framework.osgi.range>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<pluginRepositories>
|
||||
@@ -57,6 +57,7 @@
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -280,14 +281,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>wstx-asl</artifactId>
|
||||
<version>3.2.9</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>stax</groupId>
|
||||
<artifactId>stax-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<version>4.0.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdom</groupId>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>wstx-asl</artifactId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -33,8 +33,9 @@ import org.xml.sax.SAXException;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.0.0
|
||||
* @deprecated With no concrete replacement
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public abstract class AbstractStaxContentHandler implements ContentHandler {
|
||||
|
||||
private SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
|
||||
|
||||
@@ -38,8 +38,9 @@ import org.xml.sax.SAXParseException;
|
||||
* @see #setEntityResolver(org.xml.sax.EntityResolver)
|
||||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 1.0.0
|
||||
* @deprecated With no concrete replacement
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public abstract class AbstractStaxXmlReader extends AbstractXmlReader {
|
||||
|
||||
private static final String NAMESPACES_FEATURE_NAME = "http://xml.org/sax/features/namespaces";
|
||||
|
||||
@@ -28,8 +28,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.0.0
|
||||
* @deprecated With no concrete replacement
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public abstract class AbstractXmlStreamReader implements XMLStreamReader {
|
||||
|
||||
public String getElementText() throws XMLStreamException {
|
||||
@@ -150,7 +151,8 @@ public abstract class AbstractXmlStreamReader implements XMLStreamReader {
|
||||
public String getAttributeValue(String namespaceURI, String localName) {
|
||||
for (int i = 0; i < getAttributeCount(); i++) {
|
||||
QName name = getAttributeName(i);
|
||||
if (name.getNamespaceURI().equals(namespaceURI) && name.getLocalPart().equals(localName)) {
|
||||
if (name.getLocalPart().equals(localName) &&
|
||||
(namespaceURI == null || name.getNamespaceURI().equals(namespaceURI))) {
|
||||
return getAttributeValue(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,9 @@ import org.xml.sax.Locator;
|
||||
* @see XMLEvent
|
||||
* @see XMLEventConsumer
|
||||
* @since 1.0.0
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createContentHandler(javax.xml.stream.XMLEventWriter)}.
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public class StaxEventContentHandler extends AbstractStaxContentHandler {
|
||||
|
||||
private final XMLEventFactory eventFactory;
|
||||
|
||||
@@ -52,8 +52,9 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
* @see #setEntityResolver(org.xml.sax.EntityResolver)
|
||||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 1.0.0
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createXMLReader(javax.xml.stream.XMLEventReader)}
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public class StaxEventXmlReader extends AbstractStaxXmlReader {
|
||||
|
||||
private final XMLEventReader reader;
|
||||
|
||||
@@ -34,8 +34,9 @@ import org.xml.sax.Locator;
|
||||
* @author Arjen Poutsma
|
||||
* @see XMLStreamWriter
|
||||
* @since 1.0.0
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createContentHandler(javax.xml.stream.XMLStreamWriter)}
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public class StaxStreamContentHandler extends AbstractStaxContentHandler {
|
||||
|
||||
private final XMLStreamWriter streamWriter;
|
||||
|
||||
@@ -40,8 +40,9 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
* @see #setEntityResolver(org.xml.sax.EntityResolver)
|
||||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 1.0.0
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createXMLReader(javax.xml.stream.XMLStreamReader)}
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public class StaxStreamXmlReader extends AbstractStaxXmlReader {
|
||||
|
||||
private final XMLStreamReader reader;
|
||||
|
||||
@@ -35,8 +35,9 @@ import javax.xml.stream.events.XMLEvent;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.0.0
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createEventStreamReader(XMLEventReader)}
|
||||
*/
|
||||
@SuppressWarnings("Since15")
|
||||
@Deprecated
|
||||
public class XmlEventStreamReader extends AbstractXmlStreamReader {
|
||||
|
||||
private XMLEvent event;
|
||||
|
||||
@@ -36,8 +36,7 @@ import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.xml.JaxpVersion;
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -59,19 +58,14 @@ public abstract class TraxUtils {
|
||||
*
|
||||
* @return <code>true</code> if <code>source</code> is a Spring-WS {@link StaxSource} or JAXP 1.4 {@link
|
||||
* StAXSource}; <code>false</code> otherwise.
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#isStaxSource(Source)}
|
||||
* @deprecated In favor of {@link StaxUtils#isStaxSource(Source)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isStaxSource(Source source) {
|
||||
if (source instanceof StaxSource) {
|
||||
return true;
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.isStaxSource(source);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return StaxUtils.isStaxSource(source);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,19 +73,14 @@ public abstract class TraxUtils {
|
||||
*
|
||||
* @return <code>true</code> if <code>result</code> is a Spring-WS {@link StaxResult} or JAXP 1.4 {@link
|
||||
* StAXResult}; <code>false</code> otherwise.
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#isStaxResult(Result)}
|
||||
* @deprecated In favor of {@link StaxUtils#isStaxResult(Result)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isStaxResult(Result result) {
|
||||
if (result instanceof StaxResult) {
|
||||
return true;
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.isStaxResult(result);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return StaxUtils.isStaxResult(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,19 +90,14 @@ public abstract class TraxUtils {
|
||||
* @return the {@link XMLStreamReader}
|
||||
* @throws IllegalArgumentException if <code>source</code> is neither a Spring-WS {@link StaxSource} or {@link
|
||||
* StAXSource}
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#getXMLStreamReader(Source)}
|
||||
* @deprecated In favor of {@link StaxUtils#getXMLStreamReader(Source)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static XMLStreamReader getXMLStreamReader(Source source) {
|
||||
if (source instanceof StaxSource) {
|
||||
return ((StaxSource) source).getXMLStreamReader();
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.getXMLStreamReader(source);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Source '" + source + "' is neither StaxSource nor StAXSource");
|
||||
}
|
||||
return StaxUtils.getXMLStreamReader(source);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,19 +107,14 @@ public abstract class TraxUtils {
|
||||
* @return the {@link XMLEventReader}
|
||||
* @throws IllegalArgumentException if <code>source</code> is neither a Spring-WS {@link StaxSource} or {@link
|
||||
* StAXSource}
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#getXMLEventReader(Source)}
|
||||
* @deprecated In favor of {@link StaxUtils#getXMLEventReader(Source)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static XMLEventReader getXMLEventReader(Source source) {
|
||||
if (source instanceof StaxSource) {
|
||||
return ((StaxSource) source).getXMLEventReader();
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.getXMLEventReader(source);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Source '" + source + "' is neither StaxSource nor StAXSource");
|
||||
}
|
||||
return StaxUtils.getXMLEventReader(source);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,19 +124,14 @@ public abstract class TraxUtils {
|
||||
* @return the {@link XMLStreamReader}
|
||||
* @throws IllegalArgumentException if <code>source</code> is neither a Spring-WS {@link StaxResult} or {@link
|
||||
* StAXResult}
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#getXMLStreamWriter(Result)}
|
||||
* @deprecated In favor of {@link StaxUtils#getXMLStreamWriter(Result)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static XMLStreamWriter getXMLStreamWriter(Result result) {
|
||||
if (result instanceof StaxResult) {
|
||||
return ((StaxResult) result).getXMLStreamWriter();
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.getXMLStreamWriter(result);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Result '" + result + "' is neither StaxResult nor StAXResult");
|
||||
}
|
||||
return StaxUtils.getXMLStreamWriter(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,19 +141,14 @@ public abstract class TraxUtils {
|
||||
* @return the {@link XMLStreamReader}
|
||||
* @throws IllegalArgumentException if <code>source</code> is neither a Spring-WS {@link StaxResult} or {@link
|
||||
* StAXResult}
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#getXMLEventWriter(Result)}
|
||||
* @deprecated In favor of {@link StaxUtils#getXMLEventWriter(Result)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static XMLEventWriter getXMLEventWriter(Result result) {
|
||||
if (result instanceof StaxResult) {
|
||||
return ((StaxResult) result).getXMLEventWriter();
|
||||
}
|
||||
else if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.getXMLEventWriter(result);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Result '" + result + "' is neither StaxResult nor StAXResult");
|
||||
}
|
||||
return StaxUtils.getXMLEventWriter(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,16 +157,11 @@ public abstract class TraxUtils {
|
||||
*
|
||||
* @param streamReader the StAX stream reader
|
||||
* @return a source wrapping <code>streamReader</code>
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createStaxSource(XMLStreamReader)}
|
||||
* @deprecated In favor of {@link StaxUtils#createStaxSource(XMLStreamReader)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Source createStaxSource(XMLStreamReader streamReader) {
|
||||
if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.createStaxSource(streamReader);
|
||||
}
|
||||
else {
|
||||
return new StaxSource(streamReader);
|
||||
}
|
||||
return StaxUtils.createStaxSource(streamReader);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,16 +171,11 @@ public abstract class TraxUtils {
|
||||
* @param eventReader the StAX event reader
|
||||
* @return a source wrapping <code>eventReader</code>
|
||||
* @throws XMLStreamException in case of StAX errors
|
||||
* @deprecated In favor of {@link org.springframework.util.xml.StaxUtils#createStaxSource(XMLEventReader)}
|
||||
* @deprecated In favor of {@link StaxUtils#createStaxSource(XMLEventReader)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Source createStaxSource(XMLEventReader eventReader) throws XMLStreamException {
|
||||
if (JaxpVersion.isAtLeastJaxp14()) {
|
||||
return Jaxp14StaxHandler.createStaxSource(eventReader);
|
||||
}
|
||||
else {
|
||||
return new StaxSource(eventReader);
|
||||
}
|
||||
return StaxUtils.createStaxSource(eventReader);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +199,7 @@ public abstract class TraxUtils {
|
||||
|
||||
/**
|
||||
* Performs the given {@linkplain SourceCallback callback} operation on a {@link Source}. Supports both the JAXP 1.4
|
||||
* {@link StAXSource} and the Spring-WS {@link StaxSource}.
|
||||
* {@link StAXSource} and the Spring 3.0 {@link StaxUtils#createStaxSource StaxSource}.
|
||||
*
|
||||
* @param source source to look at
|
||||
* @param callback the callback to invoke for each kind of source
|
||||
@@ -288,7 +247,7 @@ public abstract class TraxUtils {
|
||||
|
||||
/**
|
||||
* Performs the given {@linkplain ResultCallback callback} operation on a {@link Result}. Supports both the JAXP 1.4
|
||||
* {@link StAXResult} and the Spring-WS {@link StaxResult}.
|
||||
* {@link StAXResult} and the Spring 3.0 {@link StaxUtils#createStaxResult StaxSource}.
|
||||
*
|
||||
* @param result result to look at
|
||||
* @param callback the callback to invoke for each kind of result
|
||||
@@ -441,45 +400,5 @@ public abstract class TraxUtils {
|
||||
void streamResult(Writer writer) throws Exception;
|
||||
}
|
||||
|
||||
/** Inner class to avoid a static JAXP 1.4 dependency. */
|
||||
private static class Jaxp14StaxHandler {
|
||||
|
||||
private static Source createStaxSource(XMLStreamReader streamReader) {
|
||||
return new StAXSource(streamReader);
|
||||
}
|
||||
|
||||
private static Source createStaxSource(XMLEventReader eventReader) throws XMLStreamException {
|
||||
return new StAXSource(eventReader);
|
||||
}
|
||||
|
||||
private static boolean isStaxSource(Source source) {
|
||||
return source instanceof StAXSource;
|
||||
}
|
||||
|
||||
private static boolean isStaxResult(Result result) {
|
||||
return result instanceof StAXResult;
|
||||
}
|
||||
|
||||
private static XMLStreamReader getXMLStreamReader(Source source) {
|
||||
Assert.isInstanceOf(StAXSource.class, source);
|
||||
return ((StAXSource) source).getXMLStreamReader();
|
||||
}
|
||||
|
||||
private static XMLEventReader getXMLEventReader(Source source) {
|
||||
Assert.isInstanceOf(StAXSource.class, source);
|
||||
return ((StAXSource) source).getXMLEventReader();
|
||||
}
|
||||
|
||||
private static XMLStreamWriter getXMLStreamWriter(Result result) {
|
||||
Assert.isInstanceOf(StAXResult.class, result);
|
||||
return ((StAXResult) result).getXMLStreamWriter();
|
||||
}
|
||||
|
||||
private static XMLEventWriter getXMLEventWriter(Result result) {
|
||||
Assert.isInstanceOf(StAXResult.class, result);
|
||||
return ((StAXResult) result).getXMLEventWriter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import javax.xml.xpath.XPathFactoryConfigurationException;
|
||||
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
import org.springframework.xml.transform.TraxUtils;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -44,7 +44,7 @@ import org.xml.sax.InputSource;
|
||||
* Namespaces can be set using the <code>namespaces</code> property.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @see #setNamespaces(java.util.Properties)
|
||||
* @see #setNamespaces(java.util.Map)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
@@ -128,7 +128,7 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
xpath.setNamespaceContext(namespaceContext);
|
||||
}
|
||||
try {
|
||||
if (TraxUtils.isStaxSource(context)) {
|
||||
if (StaxUtils.isStaxSource(context)) {
|
||||
Element element = getRootElement(context);
|
||||
return xpath.evaluate(expression, element, returnType);
|
||||
}
|
||||
|
||||
@@ -34,17 +34,15 @@ import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXResult;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stax.StAXResult;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -57,178 +55,10 @@ import org.xml.sax.ext.LexicalHandler;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
@SuppressWarnings("Since15")
|
||||
public class TraxUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testIsStaxSourceInvalid() throws Exception {
|
||||
Assert.assertFalse("A StAX Source", TraxUtils.isStaxSource(new DOMSource()));
|
||||
Assert.assertFalse("A StAX Source", TraxUtils.isStaxSource(new SAXSource()));
|
||||
Assert.assertFalse("A StAX Source", TraxUtils.isStaxSource(new StreamSource()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsStaxSource() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
|
||||
StaxSource source = new StaxSource(streamReader);
|
||||
|
||||
Assert.assertTrue("Not a StAX Source", TraxUtils.isStaxSource(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsStaxSourceJaxp14() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
|
||||
StAXSource source = new StAXSource(streamReader);
|
||||
|
||||
Assert.assertTrue("Not a StAX Source", TraxUtils.isStaxSource(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsStaxResultInvalid() throws Exception {
|
||||
Assert.assertFalse("A StAX Result", TraxUtils.isStaxResult(new DOMResult()));
|
||||
Assert.assertFalse("A StAX Result", TraxUtils.isStaxResult(new SAXResult()));
|
||||
Assert.assertFalse("A StAX Result", TraxUtils.isStaxResult(new StreamResult()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsStaxResult() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter());
|
||||
StaxResult result = new StaxResult(streamWriter);
|
||||
|
||||
Assert.assertTrue("Not a StAX Result", TraxUtils.isStaxResult(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsStaxResultJaxp14() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter());
|
||||
StAXResult result = new StAXResult(streamWriter);
|
||||
|
||||
Assert.assertTrue("Not a StAX Result", TraxUtils.isStaxResult(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateStaxSourceStreamReader() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
|
||||
|
||||
Source source = TraxUtils.createStaxSource(streamReader);
|
||||
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
StringResult result = new StringResult();
|
||||
transformer.transform(source, result);
|
||||
|
||||
assertXMLEqual(expected, result.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateStaxSourceEventReader() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(expected));
|
||||
|
||||
Source source = TraxUtils.createStaxSource(eventReader);
|
||||
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
StringResult result = new StringResult();
|
||||
transformer.transform(source, result);
|
||||
|
||||
assertXMLEqual(expected, result.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLStreamReader() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
|
||||
|
||||
StaxSource source = new StaxSource(streamReader);
|
||||
|
||||
Assert.assertEquals("Invalid XMLStreamReader", streamReader, TraxUtils.getXMLStreamReader(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLStreamReaderJaxp14() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
|
||||
|
||||
StAXSource source = new StAXSource(streamReader);
|
||||
|
||||
Assert.assertEquals("Invalid XMLStreamReader", streamReader, TraxUtils.getXMLStreamReader(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLEventReader() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(expected));
|
||||
|
||||
StaxSource source = new StaxSource(eventReader);
|
||||
|
||||
Assert.assertEquals("Invalid XMLEventReader", eventReader, TraxUtils.getXMLEventReader(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLEventReaderJaxp14() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
String expected = "<element/>";
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(expected));
|
||||
|
||||
StAXSource source = new StAXSource(eventReader);
|
||||
|
||||
Assert.assertEquals("Invalid XMLEventReader", eventReader, TraxUtils.getXMLEventReader(source));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLStreamWriter() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter());
|
||||
|
||||
StaxResult result = new StaxResult(streamWriter);
|
||||
|
||||
Assert.assertEquals("Invalid XMLStreamWriter", streamWriter, TraxUtils.getXMLStreamWriter(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLStreamWriterJaxp14() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter());
|
||||
|
||||
StAXResult result = new StAXResult(streamWriter);
|
||||
|
||||
Assert.assertEquals("Invalid XMLStreamWriter", streamWriter, TraxUtils.getXMLStreamWriter(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLEventWriter() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new StringWriter());
|
||||
|
||||
StaxResult result = new StaxResult(eventWriter);
|
||||
|
||||
Assert.assertEquals("Invalid XMLStreamWriter", eventWriter, TraxUtils.getXMLEventWriter(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXMLEventWriterJaxp14() throws Exception {
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new StringWriter());
|
||||
|
||||
StAXResult result = new StAXResult(eventWriter);
|
||||
|
||||
Assert.assertEquals("Invalid XMLEventWriter", eventWriter, TraxUtils.getXMLEventWriter(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDocument() throws Exception {
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
@@ -315,7 +145,7 @@ public class TraxUtilsTest {
|
||||
|
||||
replay(mock);
|
||||
|
||||
TraxUtils.doWithSource(new StaxSource(eventReader), mock);
|
||||
TraxUtils.doWithSource(StaxUtils.createStaxSource(eventReader), mock);
|
||||
|
||||
verify(mock);
|
||||
}
|
||||
@@ -330,7 +160,7 @@ public class TraxUtilsTest {
|
||||
|
||||
replay(mock);
|
||||
|
||||
TraxUtils.doWithResult(new StaxResult(eventWriter), mock);
|
||||
TraxUtils.doWithResult(StaxUtils.createStaxResult(eventWriter), mock);
|
||||
|
||||
verify(mock);
|
||||
}
|
||||
@@ -345,7 +175,7 @@ public class TraxUtilsTest {
|
||||
|
||||
replay(mock);
|
||||
|
||||
TraxUtils.doWithSource(new StaxSource(streamReader), mock);
|
||||
TraxUtils.doWithSource(StaxUtils.createStaxSource(streamReader), mock);
|
||||
|
||||
verify(mock);
|
||||
}
|
||||
@@ -360,7 +190,7 @@ public class TraxUtilsTest {
|
||||
|
||||
replay(mock);
|
||||
|
||||
TraxUtils.doWithResult(new StaxResult(streamWriter), mock);
|
||||
TraxUtils.doWithResult(StaxUtils.createStaxResult(streamWriter), mock);
|
||||
|
||||
verify(mock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user