Package org.apache.tools.ant.filters

Examples of org.apache.tools.ant.filters.StringInputStream


  private final String VALID_REPORT = "<pmd version=\"violations-0.8dev\"><file name=\"/dummy/TEST_FILE\"><violation beginline=\"19\" endline=\"19\" begincolumn=\"13\" endcolumn=\"20\" rule=\"UselessOperationOnImmutable\" ruleset=\"Basic Rules\" package=\"org.sprunck.bee\" class=\"Bee\" method=\"toString\" externalInfoUrl=\"http://pmd.sourceforge.net/rules/basic.html#UselessOperationOnImmutable\" priority=\"3\">An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself</violation></file></pmd>";

  @Test
  public void parseReportShouldReturnAnEmptyCollectionWhenTheReportIsInvalid() {
    final OCLintParser testedParser = new OCLintParser(null, null);
    final Collection<Violation> violations = testedParser.parseReport(new StringInputStream(""));

    assertTrue(violations.isEmpty());
  }
View Full Code Here


    sourceDirs.add(new File("/dummy"));
    when(fileSystem.getSourceDirs()).thenReturn(sourceDirs);
    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);
    project.setFileSystem(fileSystem);

    final Collection<Violation> violations = testedParser.parseReport(new StringInputStream(VALID_REPORT));
    assertFalse(violations.isEmpty());
  }
View Full Code Here

  private final String VALID_REPORT = "<?xml version=\"1.0\" ?><!DOCTYPE coverage SYSTEM \'http://cobertura.sourceforge.net/xml/coverage-03.dtd\'><coverage branch-rate=\"0.0\" line-rate=\"0.0679012345679\" timestamp=\"1373572927\" version=\"gcovr 2.5-prerelease (r2876)\"><sources><source>.</source></sources><packages><package branch-rate=\"0.0\" complexity=\"0.0\" line-rate=\"0.0679012345679\" name=\"REPORTNAME\"><classes><class branch-rate=\"0.0\" complexity=\"0.0\" filename=\"FILEPATH\" line-rate=\"0.0679012345679\" name=\"FILENAME\"><lines></lines></class></classes></package></packages></coverage>";

  @Test
  public void parseReportShouldReturnAnEmptyMapWhenTheReportIsInvalid() {
    final CoberturaParser coberturaParser = new CoberturaParser();
    final Map<String, CoverageMeasuresBuilder> measures = coberturaParser.parseReport(new StringInputStream(""));

    assertTrue(measures.isEmpty());
  }
View Full Code Here

  }

  @Test
  public void parseReportShouldReturnAMapOfFileToMeasuresWhenTheReportIsValid() {
    final CoberturaParser coberturaParser = new CoberturaParser();
    final Map<String, CoverageMeasuresBuilder> measures = coberturaParser.parseReport(new StringInputStream(VALID_REPORT));

    assertNotNull(measures.get(VALID_REPORT_FILE_PATH));
  }
View Full Code Here

  @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

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

    parser.parse(new StringInputStream(VALID_REPORT));

    assertNotNull(parseResults.get(FILE_PATH));
  }
View Full Code Here

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

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(0), parseResults.get(FILE_PATH).getHitsByLine().get(NO_HIT_LINE));
  }
View Full Code Here

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

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(1), parseResults.get(FILE_PATH).getHitsByLine().get(NO_BRANCH_LINE));
  }
View Full Code Here

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

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(10), parseResults.get(FILE_PATH).getHitsByLine().get(BRANCH_LINE));
  }
View Full Code Here

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

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(2), parseResults.get(FILE_PATH).getConditionsByLine().get(BRANCH_LINE));
  }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.filters.StringInputStream

Copyright © 2018 www.massapicom. 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.