Java Code Examples for org.springframework.util.xml.StaxUtils#createStaxSource()

The following examples show how to use org.springframework.util.xml.StaxUtils#createStaxSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUnmarshallerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
	testFlights(flights);
}
 
Example 2
Source File: AbstractUnmarshallerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void unmarshalStaxSourceXmlEventReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(INPUT_STRING));
	Source source = StaxUtils.createStaxSource(eventReader);
	Object flights = unmarshaller.unmarshal(source);
	testFlights(flights);
}
 
Example 3
Source File: AbstractUnmarshallerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flights"),
			streamReader.getName());
	streamReader.nextTag(); // skip to flight
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flight"),
			streamReader.getName());
	Source source = StaxUtils.createStaxSource(streamReader);
	Object flight = unmarshaller.unmarshal(source);
	testFlight(flight);
}
 
Example 4
Source File: Jaxb2UnmarshallerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@Override
@SuppressWarnings("unchecked")
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	streamReader.nextTag(); // skip to flight
	Source source = StaxUtils.createStaxSource(streamReader);
	JAXBElement<FlightType> element = (JAXBElement<FlightType>) unmarshaller.unmarshal(source);
	FlightType flight = element.getValue();
	testFlight(flight);
}
 
Example 5
Source File: XStreamUnmarshallerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example 6
Source File: AbstractUnmarshallerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
	testFlights(flights);
}
 
Example 7
Source File: AbstractUnmarshallerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void unmarshalStaxSourceXmlEventReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(INPUT_STRING));
	Source source = StaxUtils.createStaxSource(eventReader);
	Object flights = unmarshaller.unmarshal(source);
	testFlights(flights);
}
 
Example 8
Source File: AbstractUnmarshallerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flights"),
			streamReader.getName());
	streamReader.nextTag(); // skip to flight
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flight"),
			streamReader.getName());
	Source source = StaxUtils.createStaxSource(streamReader);
	Object flight = unmarshaller.unmarshal(source);
	testFlight(flight);
}
 
Example 9
Source File: Jaxb2UnmarshallerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@Override
@SuppressWarnings("unchecked")
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	streamReader.nextTag(); // skip to flight
	Source source = StaxUtils.createStaxSource(streamReader);
	JAXBElement<FlightType> element = (JAXBElement<FlightType>) unmarshaller.unmarshal(source);
	FlightType flight = element.getValue();
	testFlight(flight);
}
 
Example 10
Source File: XStreamUnmarshallerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example 11
Source File: AbstractUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
	testFlights(flights);
}
 
Example 12
Source File: AbstractUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void unmarshalStaxSourceXmlEventReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(INPUT_STRING));
	Source source = StaxUtils.createStaxSource(eventReader);
	Object flights = unmarshaller.unmarshal(source);
	testFlights(flights);
}
 
Example 13
Source File: AbstractUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flights"),
			streamReader.getName());
	streamReader.nextTag(); // skip to flight
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flight"),
			streamReader.getName());
	Source source = StaxUtils.createStaxSource(streamReader);
	Object flight = unmarshaller.unmarshal(source);
	testFlight(flight);
}
 
Example 14
Source File: Jaxb2UnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Override
@SuppressWarnings("unchecked")
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	streamReader.nextTag(); // skip to flight
	Source source = StaxUtils.createStaxSource(streamReader);
	JAXBElement<FlightType> element = (JAXBElement<FlightType>) unmarshaller.unmarshal(source);
	FlightType flight = element.getValue();
	testFlight(flight);
}
 
Example 15
Source File: XStreamUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 16
Source File: XmlBeansUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Override
public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
	XMLInputFactory inputFactory = XMLInputFactory.newInstance();
	XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
	streamReader.nextTag(); // skip to flights
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flights"),
			streamReader.getName());
	streamReader.nextTag(); // skip to flight
	assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flight"),
			streamReader.getName());
	Source source = StaxUtils.createStaxSource(streamReader);
	Object flight = unmarshaller.unmarshal(source);
	testFlight(flight);
}