Exemplo n.º 1
0
  private void executeCheck() throws MojoExecutionException {
    final IBundleCoverage bundle = loadBundle();
    violations = false;

    final RulesChecker checker = new RulesChecker();
    final List<Rule> checkerrules = new ArrayList<Rule>();
    for (final RuleConfiguration r : rules) {
      checkerrules.add(r.rule);
    }
    checker.setRules(checkerrules);

    final IReportVisitor visitor = checker.createVisitor(this);
    try {
      visitor.visitBundle(bundle, null);
    } catch (final IOException e) {
      throw new MojoExecutionException("Error while checking code coverage: " + e.getMessage(), e);
    }
    if (violations) {
      if (this.haltOnFailure) {
        throw new MojoExecutionException(CHECK_FAILED);
      } else {
        this.getLog().warn(CHECK_FAILED);
      }
    } else {
      this.getLog().info(CHECK_SUCCESS);
    }
  }
Exemplo n.º 2
0
 private void createReport(IProgressMonitor monitor) throws CoreException, IOException {
   final int work = session.getScope().size();
   monitor.beginTask(
       NLS.bind(CoreMessages.ExportingSession_task, session.getDescription()), work * 2);
   final SessionAnalyzer analyzer = new SessionAnalyzer();
   final IJavaModelCoverage modelCoverage =
       analyzer.processSession(session, new SubProgressMonitor(monitor, work));
   final IReportVisitor formatter = createFormatter();
   formatter.visitInfo(analyzer.getSessionInfos(), analyzer.getExecutionData());
   final IReportGroupVisitor modelgroup = formatter.visitGroup(session.getDescription());
   for (IJavaProject project : modelCoverage.getProjects()) {
     final IReportGroupVisitor projectgroup = modelgroup.visitGroup(project.getElementName());
     for (IPackageFragmentRoot root : project.getPackageFragmentRoots()) {
       final IBundleCoverage coverage = (IBundleCoverage) modelCoverage.getCoverageFor(root);
       if (coverage != null) {
         projectgroup.visitBundle(coverage, createSourceFileLocator(root));
         monitor.worked(1);
       }
     }
   }
   formatter.visitEnd();
   monitor.done();
 }