public Object buildModel(final Map<String, Object> models) { final LocatedJDOMFactory locatedJDOMFactory = new LocatedJDOMFactory(); final SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setJDOMFactory(locatedJDOMFactory); final MavenProject mavenProject = (MavenProject) models.get(MAVEN_PROJECT); try { Document document = saxBuilder.build(mavenProject.getFile()); return document; } catch (JDOMException e) { throw new RuntimeException("Unable to build JDOM2 model", e); } catch (IOException e) { throw new RuntimeException("Unable to build JDOM2 model", e); } }
public TestRun createTestRun(File testFile, int runIndex) { try { SAXBuilder builder = new SAXBuilder( ); builder.setJDOMFactory(new LocatedJDOMFactory()); Document document = builder.build(new FileInputStream(testFile)); Element runElement = document.getRootElement(); if (!runElement.getName().equalsIgnoreCase("run")) { throw new TestParseException( "Expected <run> but encountered <" + runElement.getName() + ">"); } return parseTestRun(runElement, testFile, runIndex); } catch (Exception e) { parsingProblems.add( "An exception occurred while parsing " + testFile + ": " + e.toString()); return null; } }