Add utility to create a org.xml.sax.XMLReader
Closes gh-1471
This commit is contained in:
@@ -26,7 +26,6 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLEventWriter;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
@@ -188,9 +187,7 @@ public abstract class AbstractWebServiceMessageTest {
|
||||
}
|
||||
|
||||
private void validateMessage() throws Exception {
|
||||
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
|
||||
parserFactory.setNamespaceAware(true);
|
||||
XMLReader xmlReader = parserFactory.newSAXParser().getXMLReader();
|
||||
XMLReader xmlReader = SaxUtils.namespaceAwareXmlReader();
|
||||
xmlReader.setContentHandler(new DefaultHandler());
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
this.webServiceMessage.writeTo(os);
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
@@ -41,6 +40,7 @@ import org.xml.sax.XMLReader;
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
import org.springframework.xml.DocumentBuilderFactoryUtils;
|
||||
import org.springframework.xml.XMLInputFactoryUtils;
|
||||
import org.springframework.xml.sax.SaxUtils;
|
||||
|
||||
@SuppressWarnings("Since15")
|
||||
public abstract class AbstractEndpointTest {
|
||||
@@ -67,9 +67,7 @@ public abstract class AbstractEndpointTest {
|
||||
|
||||
@Test
|
||||
public void testSaxSource() throws Exception {
|
||||
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
|
||||
parserFactory.setNamespaceAware(true);
|
||||
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
|
||||
XMLReader reader = SaxUtils.namespaceAwareXmlReader();
|
||||
InputSource inputSource = new InputSource(new StringReader(REQUEST));
|
||||
testSource(new SAXSource(reader, inputSource));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user