@Test @SuppressWarnings("deprecation") public void unmarshalSAXSource() throws Exception { XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING))); Object flights = unmarshaller.unmarshal(source); testFlights(flights); }
@Test public void unmarshalStreamSourceInputStream() throws Exception { StreamSource source = new StreamSource(new ByteArrayInputStream(INPUT_STRING.getBytes("UTF-8"))); Object flights = unmarshaller.unmarshal(source); testFlights(flights); }
@Test public void unmarshalStreamSourceReader() throws Exception { StreamSource source = new StreamSource(new StringReader(INPUT_STRING)); Object flights = unmarshaller.unmarshal(source); testFlights(flights); }
@Test public void unmarshalDomSource() throws Exception { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = builder.newDocument(); Element flightsElement = document.createElementNS("http://samples.springframework.org/flight", "tns:flights"); document.appendChild(flightsElement); Element flightElement = document.createElementNS("http://samples.springframework.org/flight", "tns:flight"); flightsElement.appendChild(flightElement); Element numberElement = document.createElementNS("http://samples.springframework.org/flight", "tns:number"); flightElement.appendChild(numberElement); Text text = document.createTextNode("42"); numberElement.appendChild(text); DOMSource source = new DOMSource(document); Object flights = unmarshaller.unmarshal(source); testFlights(flights); }
@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); }
@Test public void unmarshalJaxp14StaxSourceXmlEventReader() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(INPUT_STRING)); StAXSource source = new StAXSource(eventReader); Object flights = unmarshaller.unmarshal(source); testFlights(flights); }
@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); }
@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); }