Package hudson.plugins.cobertura.targets

Examples of hudson.plugins.cobertura.targets.CoverageResult


        if (healthyTarget == null || unhealthyTarget == null) {
            return null;
        }

        if (result == null) {
            CoverageResult projectCoverage = getResult();
            result = new EnumMap<CoverageMetric, Ratio>(CoverageMetric.class);
            result.putAll(projectCoverage.getResults());
        }
        Map<CoverageMetric, Integer> scores = healthyTarget.getRangeScores(unhealthyTarget, result);
        int minValue = 100;
        CoverageMetric minKey = null;
        for (Map.Entry<CoverageMetric, Integer> e : scores.entrySet()) {
View Full Code Here


     * Obtains the detailed
     * {@link hudson.plugins.cobertura.targets.CoverageResult} instance.
     */
    public synchronized CoverageResult getResult() {
        if (report != null) {
            CoverageResult r = report.get();
            if (r != null) {
                return r;
            }
        }

        CoverageResult r = null;
        for (File reportFile : CoberturaPublisher.getCoberturaReports(owner)) {
            try {
                r = CoberturaCoverageParser.parse(reportFile, r);
            } catch (IOException e) {
                logger.log(Level.WARNING, "Failed to load " + reportFile, e);
            }
        }
        if (r != null) {
            r.setOwner(owner);
            report = new WeakReference<CoverageResult>(r);
            return r;
        } else {
            return null;
        }
View Full Code Here

      Util.displayIOException(e, listener);
      e.printStackTrace(listener.fatalError("Unable to copy " + reportFilePath + " to " + target));
      build.setResult(Result.FAILURE);
    }

    CoverageResult result = null;
    Set<String> sourcePaths = new HashSet<String>();

    try {
      result = CoberturaCoverageParser.parse(reportFile, null, sourcePaths);
    } catch (IOException e) {
      Util.displayIOException(e, listener);
      e.printStackTrace(listener.fatalError("Unable to parse " + reportFilePath));
      build.setResult(Result.FAILURE);
    }

    if (result != null) {
      result.setOwner(null);
      final FilePath paintedSourcesPath = build.getProjectRootDir().child("cobertura");
      paintedSourcesPath.mkdirs();
      // Get System default encoding;
      SourceEncoding encoding = SourceEncoding.getEncoding(System.getProperty("file.encoding"));
      SourceCodePainter painter = new SourceCodePainter(paintedSourcesPath, sourcePaths, result.getPaintedSources(), listener,
          encoding);

      new FilePath(pom.getBasedir()).act(painter);
      if (!build.execute(new MavenCoberturaActionAdder(listener))) {
        listener.getLogger().println("[JENKINS] Unable to add link to cobertura results");
View Full Code Here

    public Boolean call(MavenBuild build) throws IOException {
      try {
        CoberturaBuildAction cba = build.getAction(CoberturaBuildAction.class);
        if (cba == null) {
          File cvgxml = new File(build.getRootDir(), "coverage.xml");
          CoverageResult result = CoberturaCoverageParser.parse(cvgxml, null, new HashSet<String>());
          result.setOwner(build);

          CoberturaBuildAction o = CoberturaBuildAction.load(build, result, null, null, false, false, false, false, false);
          build.getActions().add(o);
        } else {
          return false;
View Full Code Here

     * {@inheritDoc}
     */
    public void startDocument() throws SAXException {
        super.startDocument();
        if (this.rootCoverage == null) {
            this.rootCoverage = new CoverageResult(CoverageElement.PROJECT, null, Messages.CoberturaCoverageParser_name());
        }
        stack.clear();
        inSource = false;
        inSources = false;
    }
View Full Code Here

        }
        super.endDocument();    //To change body of overridden methods use File | Settings | File Templates.
    }

    private void descend(CoverageElement childType, String childName) {
        CoverageResult child = rootCoverage.getChild(childName);
        stack.push(rootCoverage);
        if (child == null) {
            rootCoverage = new CoverageResult(childType, rootCoverage, childName);
        } else {
            rootCoverage = child;
        }
    }
View Full Code Here

            }
        }

        listener.getLogger().println("Publishing Cobertura coverage results...");
        Set<String> sourcePaths = new HashSet<String>();
        CoverageResult result = null;
        for (File coberturaXmlReport : getCoberturaReports(build)) {
            try {
                result = CoberturaCoverageParser.parse(coberturaXmlReport, result, sourcePaths);
            } catch (IOException e) {
                Util.displayIOException(e, listener);
                e.printStackTrace(listener.fatalError("Unable to parse " + coberturaXmlReport));
                build.setResult(Result.FAILURE);
            }
        }
        if (result != null) {
            listener.getLogger().println("Cobertura coverage report found.");
            result.setOwner(build);
            final FilePath paintedSourcesPath = new FilePath(new File(build.getProject().getRootDir(), "cobertura"));
            paintedSourcesPath.mkdirs();
            SourceCodePainter painter = new SourceCodePainter(paintedSourcesPath, sourcePaths,
                    result.getPaintedSources(), listener, getSourceEncoding());

            moduleRoot.act(painter);

            final CoberturaBuildAction action = CoberturaBuildAction.load(build, result, healthyTarget,
                    unhealthyTarget, getOnlyStable(), getFailUnhealthy(), getFailUnstable(), getAutoUpdateHealth(), getAutoUpdateStability());
View Full Code Here

  @Test(expected = NullPointerException.class)
  public void oneResult() throws Exception
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl ).data().create();
    new CoverageChart( result, true, 0 );
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void simple() throws IOException
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl ).data().data().create();
    CoverageChart chartData = new CoverageChart( result, true, 0 );
    Assert.assertEquals( 74, chartData.getLowerBound() );
    Assert.assertEquals( 101, chartData.getUpperBound() );
    assertEquals( Arrays.asList( "#1", "#2" ), chartData.getDataset().getColumnKeys() );
    complete( chartData, new File( TEMP_IMAGE_FOLDER, "chart_simple.png" ).getPath() );
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void someMore() throws IOException
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl )//
        .result( 100, 100, 200, 300, 400, 500 )//
        .result( 100, 100, 200, 300, 400, 500 )//
        .result( 100, 200, 300, 400, 500, 600 )//
        .create();
    CoverageChart chartData = new CoverageChart( result, true, 0 );
View Full Code Here

TOP

Related Classes of hudson.plugins.cobertura.targets.CoverageResult

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.