SimpleXMLEventReader implements XMLEventReader { @Override public XMLEvent nextEvent() throws XMLStreamException { XMLEvent currentEvent = peek(); if (currentEvent == null) { throw new XMLStreamException("no more events"); } currentEventType = currentEvent.getEventType(); peekedEvent = null; return currentEvent; } SimpleXMLEventReader(XMLStreamReader delegate);  SimpleXMLEventReader(XMLStreamReader delegate, XMLEventAllocator allocator); @Override void close(); @Override String getElementText(); @Override Object getProperty(String name); @Override boolean hasNext(); @Override XMLEvent nextEvent(); @Override Object next(); @Override XMLEvent nextTag(); @Override XMLEvent peek(); @Override void remove();  }
@Test public void testStartEndDocument() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<? xml version=\"1.0\" ?>"); Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.END_DOCUMENT, reader.nextEvent().getEventType()); }
@Test public void testStartEndElement() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<alice/>"); Assert.assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.END_ELEMENT, reader.nextEvent().getEventType()); reader = createXmlEventReader("<alice></alice>"); Assert.assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.END_ELEMENT, reader.nextEvent().getEventType()); }
@Test public void testCharactersCData() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<alice>bob</alice>"); Assert.assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.CHARACTERS, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.END_ELEMENT, reader.nextEvent().getEventType()); reader = createXmlEventReader("<alice><![CDATA[bob]]></alice>"); Assert.assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.CDATA, reader.nextEvent().getEventType()); Assert.assertEquals(XMLStreamConstants.END_ELEMENT, reader.nextEvent().getEventType()); }
@Test public void testComment() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<!--james-->"); Assert.assertEquals(XMLStreamConstants.COMMENT, reader.nextEvent().getEventType()); }
@Test public void testProcessingInstruction() throws XMLStreamException { XMLEventReader reader = createXmlEventReader("<?joe?>"); Assert.assertEquals(XMLStreamConstants.PROCESSING_INSTRUCTION, reader.nextEvent().getEventType()); }