private void parseRootNode(SMHierarchicCursor rootCursor, SensorContext context) throws XMLStreamException { String elementName = rootCursor.getLocalName(); if (!OLD_ROOT_ELEMENT.equals(elementName) && !ROOT_ELEMENT.equals(elementName)) { throw new IllegalStateException( "Unknown XML node, expected \"" + ROOT_ELEMENT + "\" but got \"" + elementName + "\" at line " + rootCursor.getCursorLocation().getLineNumber()); } if (OLD_ROOT_ELEMENT.equals(elementName)) { LOG.warn("Using '" + OLD_ROOT_ELEMENT + "' as root element of the report is deprecated. Please change to '" + ROOT_ELEMENT + "'."); } String version = rootCursor.getAttrValue("version"); if (!"1".equals(version)) { throw new IllegalStateException("Unknown report version: " + version + ". This parser only handles version 1."); } parseFiles(rootCursor.childElementCursor(), context); }
SMHierarchicCursor rootC = inputFactory.rootElementCursor(backup); if (!"profile".equals(rootC.getLocalName())) { throw new IllegalArgumentException("Backup XML is not valid. Root element must be <profile>.");
private void parseRootNode(SMHierarchicCursor rootCursor, SensorContext context) throws XMLStreamException { String elementName = rootCursor.getLocalName(); if (!OLD_ROOT_ELEMENT.equals(elementName) && !ROOT_ELEMENT.equals(elementName)) { throw new IllegalStateException( "Unknown XML node, expected \"" + ROOT_ELEMENT + "\" but got \"" + elementName + "\" at line " + rootCursor.getCursorLocation().getLineNumber()); } if (OLD_ROOT_ELEMENT.equals(elementName)) { LOG.warn("Using '" + OLD_ROOT_ELEMENT + "' as root element of the report is deprecated. Please change to '" + ROOT_ELEMENT + "'."); } String version = rootCursor.getAttrValue("version"); if (!"1".equals(version)) { throw new IllegalStateException("Unknown report version: " + version + ". This parser only handles version 1."); } parseFiles(rootCursor.childElementCursor(), context); }
/** * Gets the coverage. * * @param coverageReportFile the coverage report file * @return the coverage */ private static CoverageNode getCoverage(File coverageReportFile) { SMInputFactory inputFactory = JUnitLogParserForPhpUnit.inputFactory(); try { SMHierarchicCursor rootCursor = inputFactory.rootElementCursor(coverageReportFile); rootCursor.advance(); if (!"coverage".equals(rootCursor.getLocalName())) { throw new XMLStreamException("Report should start with <coverage>"); } return parseCoverageNode(rootCursor); } catch (XMLStreamException e) { throw new IllegalStateException("Can't read phpUnit report: " + coverageReportFile.getName(), e); } }
private static TestSuites processRoot(File file, SMInputFactory inputFactory) throws XMLStreamException { SMHierarchicCursor rootCursor = inputFactory.rootElementCursor(file); rootCursor.advance(); if (!"testsuites".equals(rootCursor.getLocalName())) { throw new XMLStreamException("Report should start with <testsuites>"); } SMInputCursor childCursor = rootCursor.childElementCursor("testsuite"); List<TestSuite> testSuites = new ArrayList<>(); while (childCursor.getNext() != null) { testSuites.add(processTestSuite(childCursor)); } return new TestSuites(testSuites); }
/** * Gets the coverage. * * @param coverageReportFile the coverage report file * @return the coverage */ private static CoverageNode getCoverage(File coverageReportFile) { SMInputFactory inputFactory = JUnitLogParserForPhpUnit.inputFactory(); try { SMHierarchicCursor rootCursor = inputFactory.rootElementCursor(coverageReportFile); rootCursor.advance(); if (!"coverage".equals(rootCursor.getLocalName())) { throw new XMLStreamException("Report should start with <coverage>"); } return parseCoverageNode(rootCursor); } catch (XMLStreamException e) { throw new IllegalStateException("Can't read phpUnit report: " + coverageReportFile.getName(), e); } }
private static TestSuites processRoot(File file, SMInputFactory inputFactory) throws XMLStreamException { SMHierarchicCursor rootCursor = inputFactory.rootElementCursor(file); rootCursor.advance(); if (!"testsuites".equals(rootCursor.getLocalName())) { throw new XMLStreamException("Report should start with <testsuites>"); } SMInputCursor childCursor = rootCursor.childElementCursor("testsuite"); List<TestSuite> testSuites = new ArrayList<>(); while (childCursor.getNext() != null) { testSuites.add(processTestSuite(childCursor)); } return new TestSuites(testSuites); }
SMHierarchicCursor rootC = inputFactory.rootElementCursor(backup); if (!"profile".equals(rootC.getLocalName())) { throw new IllegalArgumentException("Backup XML is not valid. Root element must be <profile>.");