use of javax.xml.stream.XMLInputFactory in project spring-framework by spring-projects.
the class StaxEventXMLReaderTests method partial.
@Test
public void partial() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT));
// skip to root
eventReader.nextTag();
StaxEventXMLReader xmlReader = new StaxEventXMLReader(eventReader);
ContentHandler contentHandler = mock(ContentHandler.class);
xmlReader.setContentHandler(contentHandler);
xmlReader.parse(new InputSource());
verify(contentHandler).startDocument();
verify(contentHandler).startElement(eq("http://springframework.org/spring-ws"), eq("child"), eq("child"), any(Attributes.class));
verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child");
verify(contentHandler).endDocument();
}
use of javax.xml.stream.XMLInputFactory in project spring-framework by spring-projects.
the class StaxStreamXMLReaderTests method partial.
@Test
public void partial() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(CONTENT));
// skip to root
streamReader.nextTag();
assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "root"), streamReader.getName());
// skip to child
streamReader.nextTag();
assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"), streamReader.getName());
StaxStreamXMLReader xmlReader = new StaxStreamXMLReader(streamReader);
ContentHandler contentHandler = mock(ContentHandler.class);
xmlReader.setContentHandler(contentHandler);
xmlReader.parse(new InputSource());
verify(contentHandler).setDocumentLocator(any(Locator.class));
verify(contentHandler).startDocument();
verify(contentHandler).startElement(eq("http://springframework.org/spring-ws"), eq("child"), eq("child"), any(Attributes.class));
verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child");
verify(contentHandler).endDocument();
}
use of javax.xml.stream.XMLInputFactory in project spring-framework by spring-projects.
the class StaxUtilsTests method isStaxSource.
@Test
public void isStaxSource() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
String expected = "<element/>";
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
Source source = StaxUtils.createCustomStaxSource(streamReader);
assertTrue("Not a StAX Source", StaxUtils.isStaxSource(source));
}
use of javax.xml.stream.XMLInputFactory in project spring-framework by spring-projects.
the class AbstractUnmarshallerTests method unmarshalJaxp14StaxSourceXmlStreamReader.
@Test
public void unmarshalJaxp14StaxSourceXmlStreamReader() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
StAXSource source = new StAXSource(streamReader);
Object flights = unmarshaller.unmarshal(source);
testFlights(flights);
}
use of javax.xml.stream.XMLInputFactory in project spring-framework by spring-projects.
the class XStreamUnmarshallerTests method unmarshalStaxSourceXmlStreamReader.
@Test
public void unmarshalStaxSourceXmlStreamReader() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
Source source = StaxUtils.createStaxSource(streamReader);
Object flights = unmarshaller.unmarshal(source);
testFlight(flights);
}
Aggregations