XmlParser { public void parseXml(final ParseSession session, final XMLEventReader eventReader) throws Exception { JoinTables joinTables = new JoinTables(); session.start(); while (eventReader.hasNext()) { session.eventProgressed(); final XMLEvent event = eventReader.nextTag(); if (event.isStartElement()) { parseEvent(session, eventReader, event, joinTables); } else if (event.isEndDocument() || event.isEndElement()) { break; } } session.finish(); } XmlParser(ParseContext ctx); void parseXml(final ParseSession session, final XMLEventReader eventReader);  }
@Test public void shouldMatch084On083() throws Exception { MockitoAnnotations.initMocks(this); Configuration config = new Configuration("version", "0.8.4"); when(configurationDao.findById(ConfigurationItem.VERSION.getDbField())).thenReturn(config); String xmlData = "<?xml version=\"1.0\" ?>\n<EHOUR DB_VERSION=\"0.8.3\"></EHOUR>"; XMLInputFactory inputFactory = XMLInputFactory.newInstance(); eventReader = inputFactory.createXMLEventReader(new StringReader(xmlData)); ParseContext ctx = new ParseContext(configurationDao, null, null, null, null, false); XmlParser importer = new XmlParser(ctx); importer.parseXml(new ParseSession(), eventReader); }
@Test(expected = ImportException.class) public void shouldNotMatch084On081() throws Exception { MockitoAnnotations.initMocks(this); Configuration config = new Configuration("version", "0.8.4"); when(configurationDao.findById(ConfigurationItem.VERSION.getDbField())).thenReturn(config); String xmlData = "<?xml version=\"1.0\" ?>\n<EHOUR DB_VERSION=\"0.8.1\"></EHOUR>"; XMLInputFactory inputFactory = XMLInputFactory.newInstance(); eventReader = inputFactory.createXMLEventReader(new StringReader(xmlData)); ParseContext ctx = new ParseContext(configurationDao, null, null, null, null, false); XmlParser importer = new XmlParser(ctx); importer.parseXml(new ParseSession(), eventReader); }