Examples of StaxParser


Examples of org.sonar.api.utils.StaxParser

   */
  public void parseReport(File xmlFile, final Map<String, CoverageMeasuresBuilder> coverageData)
    throws XMLStreamException {
    CxxUtils.LOG.info("Parsing report '{}'", xmlFile);

    StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
      /**
       * {@inheritDoc}
       */
      public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
        rootCursor.advance();
        collectModuleMeasures(rootCursor.descendantElementCursor("module"), coverageData);
      }
    });
    parser.parse(xmlFile);
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

  public void parseReport(File xmlFile, final Map<String, CoverageMeasuresBuilder> coverageData)
      throws XMLStreamException
  {
    CxxUtils.LOG.info("Parsing report '{}'", xmlFile);

    StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
      /**
       * {@inheritDoc}
       */
      public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
        rootCursor.advance();
        collectPackageMeasures(rootCursor.descendantElementCursor("package"), coverageData);
      }
    });
    parser.parse(xmlFile);
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

  }

  private void parse(String path) throws XMLStreamException {
    File xml = TestUtils.getResource(getClass(), path);
    SurefireStaxHandler staxParser = new SurefireStaxHandler(index);
    StaxParser parser = new StaxParser(staxParser, false);
    parser.parse(xml);
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    save(index, context);
  }

  private void parseFiles(File[] reports, UnitTestIndex index) {
    SurefireStaxHandler staxParser = new SurefireStaxHandler(index);
    StaxParser parser = new StaxParser(staxParser, false);
    for (File report : reports) {
      try {
        parser.parse(report);
      } catch (XMLStreamException e) {
        throw new SonarException("Fail to parse the Surefire report: " + report, e);
      }
    }
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(VIOLATION_LINE, parseResults.get(0).getLineId());
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(RulePriority.MAJOR, parseResults.get(0).getRule().getSeverity());
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(RULE_KEY, parseResults.get(0).getRule().getKey());
  }
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    public Map<String, CoverageMeasuresBuilder> parseReport(
            final InputStream xmlFile) {

        final Map<String, CoverageMeasuresBuilder> measuresForReport = new HashMap<String, CoverageMeasuresBuilder>();
        try {
            final StaxParser parser = new StaxParser(
                    new CoberturaXMLStreamHandler(measuresForReport));
            parser.parse(xmlFile);
        } catch (final XMLStreamException e) {
            LoggerFactory.getLogger(getClass()).error(
                    "Error while parsing XML stream.", e);
        }
        return measuresForReport;
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

    }

    public Collection<Violation> parseReport(final InputStream inputStream) {
        final Collection<Violation> violations = new ArrayList<Violation>();
        try {
            final StaxParser parser = new StaxParser(
                    new OCLintXMLStreamHandler(violations, project, context));
            parser.parse(inputStream);
            LoggerFactory.getLogger(getClass()).error(
                    "Reporting {} violations.", violations.size());
        } catch (final XMLStreamException e) {
            LoggerFactory.getLogger(getClass()).error(
                    "Error while parsing XML stream.", e);
View Full Code Here

Examples of org.sonar.api.utils.StaxParser

  private final int BRANCH_LINE = 35;

  @Test
  public void streamLeavesTheMapEmptyWhenNoLinesAreFound() throws XMLStreamException {
    final Map<String, CoverageMeasuresBuilder> parseResults = new HashMap<String, CoverageMeasuresBuilder>();
    final StaxParser parser = new StaxParser(new CoberturaXMLStreamHandler(parseResults));

    parser.parse(new StringInputStream(EMPTY_REPORT));

    assertTrue(parseResults.isEmpty());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.