public void testXmlError() throws Exception {
InputStream stream = new ByteArrayInputStream(
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><document><text></document>"
.getBytes());
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLEventReader reader = factory.createXMLEventReader(stream);
StartDocument startdoc = (StartDocument) reader.nextEvent();
assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
assertEquals("1.0", startdoc.getVersion());
assertTrue(reader.hasNext());
XMLEvent event = reader.nextEvent();
assertTrue(event.isStartElement());
event = reader.nextEvent();
assertTrue(event.isCharacters());
String c = event.asCharacters().getData();
event = reader.nextEvent();
assertTrue(event.isCharacters());
c+=event.asCharacters().getData();
assertEquals("<text>",c); //FAILURE expected "<text>" but was "<text"
event = reader.nextEvent();
assertTrue(event.isEndElement());
}