aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-deprecated
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-deprecated')
-rw-r--r--sonar-deprecated/pom.xml6
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java53
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java55
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java89
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFilesDecorator.java55
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java88
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDistributionDecorator.java83
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java2
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/FileFilter.java34
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/charts/AbstractChart.java1
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/checks/NoSonarFilter.java1
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/measures/AverageComplexityFormula.java36
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java73
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java1
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java19
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java134
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java2
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/web/GwtExtension.java31
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/web/GwtPage.java33
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java47
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java89
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java43
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFileComplexityDecoratorTest.java88
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFunctionComplexityDecoratorTest.java88
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java227
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java69
26 files changed, 8 insertions, 1439 deletions
diff --git a/sonar-deprecated/pom.xml b/sonar-deprecated/pom.xml
index de47916f1c3..9c6a5c639fe 100644
--- a/sonar-deprecated/pom.xml
+++ b/sonar-deprecated/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar</artifactId>
- <version>4.5.2-SNAPSHOT</version>
+ <version>5.0-SNAPSHOT</version>
</parent>
<artifactId>sonar-deprecated</artifactId>
<name>SonarQube :: Deprecated</name>
@@ -19,10 +19,6 @@
<artifactId>jfreechart</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
- <dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java
deleted file mode 100644
index f058437513a..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.resources.Project;
-
-/**
- * This class implements the management of the code coverage engine if there are several.
- * It is a pre-implementation for Sensors and Decorators
- *
- * @since 1.10
- * @deprecated since 2.6 was superseded by interface {@link CoverageExtension}
- */
-@Deprecated
-public abstract class AbstractCoverageExtension implements CoverageExtension {
-
- /**
- * The plugin key to retrieve the coverage engine to be used
- */
- public static final String PARAM_PLUGIN = "sonar.core.codeCoveragePlugin";
-
- /**
- * The default value for the code coverage plugin
- */
- public static final String DEFAULT_PLUGIN = "cobertura";
-
- public AbstractCoverageExtension() {
- }
-
- /**
- * Whether to implement the extension on the project
- */
- public boolean shouldExecuteOnProject(Project project) {
- return project.getAnalysisType().isDynamic(true);
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java
deleted file mode 100644
index e8b725357af..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-/**
- * A pre-implementation to decorate the number of directories
- *
- * @since 1.10
- * @deprecated since 2.2, the number of directories is automatically calculated by sonar core (see metric formula)
- */
-@Deprecated
-public abstract class AbstractDirectoriesDecorator implements Decorator {
-
-
- /**
- * @param language this will be use to defined whether the decorator should be executed on a project
- */
- public AbstractDirectoriesDecorator(Language language) {
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean shouldExecuteOnProject(Project project) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void decorate(Resource resource, DecoratorContext context) {
-
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java
deleted file mode 100644
index 9099c22a495..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore
- * @since 1.10
- */
-@Deprecated
-public abstract class AbstractFileComplexityDecorator implements Decorator {
-
- private Language language;
-
- /**
- * @param language this will be use to defined whether the decorator should be executed on a project
- */
- public AbstractFileComplexityDecorator(Language language) {
- this.language = language;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean shouldExecuteOnProject(Project project) {
- return language.equals(project.getLanguage());
- }
-
- /**
- * Used to define upstream dependencies
- */
- @DependsUpon
- public List<Metric> dependsUponFileAndComplexityMetrics() {
- return Arrays.<Metric>asList(CoreMetrics.FILES, CoreMetrics.COMPLEXITY);
- }
-
- /**
- * Used to define downstream dependencies
- */
- @DependedUpon
- public Metric generateFileComplexityMetric() {
- return CoreMetrics.FILE_COMPLEXITY;
- }
-
- /**
- * {@inheritDoc}
- */
- public void decorate(Resource resource, DecoratorContext context) {
- if (!shouldDecorateResource(resource, context)) {
- return;
- }
- Double files = MeasureUtils.getValue(context.getMeasure(CoreMetrics.FILES), null);
- Double complexity = MeasureUtils.getValue(context.getMeasure(CoreMetrics.COMPLEXITY), null);
- if (complexity != null && files != null && files > 0.0) {
- context.saveMeasure(CoreMetrics.FILE_COMPLEXITY, complexity / files);
- }
- }
-
- private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
- return !MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FILE_COMPLEXITY)) && !ResourceUtils.isEntity(resource);
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFilesDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFilesDecorator.java
deleted file mode 100644
index d22b58d27a2..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFilesDecorator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-/**
- * A pre-implementation to decorate the number of files
-
- * @since 1.10
- * @deprecated since 2.2, the number of files is automatically calculated by sonar core (see metric formula)
- */
-@Deprecated
-public abstract class AbstractFilesDecorator implements Decorator {
-
-
- /**
- * @param language this will be use to defined whether the decorator should be executed on a project
- */
- public AbstractFilesDecorator(Language language) {
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean shouldExecuteOnProject(Project project) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void decorate(Resource resource, DecoratorContext context) {
-
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java
deleted file mode 100644
index ab7103bf6d2..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore
- * @since 1.13
- */
-@Deprecated
-public abstract class AbstractFunctionComplexityDecorator implements Decorator {
-
- private Language language;
-
- /**
- * @param language this will be use to defined whether the decorator should be executed on a project
- */
- public AbstractFunctionComplexityDecorator(Language language) {
- this.language = language;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean shouldExecuteOnProject(Project project) {
- return language.equals(project.getLanguage());
- }
-
- /**
- * Used to define upstream dependencies
- */
- @DependsUpon
- public List<Metric> dependsUponFileAndComplexityMetrics() {
- return Arrays.<Metric>asList(CoreMetrics.FUNCTIONS, CoreMetrics.COMPLEXITY);
- }
-
- /**
- * Used to define downstream dependencies
- */
- @DependedUpon
- public Metric generateFileComplexityMetric() {
- return CoreMetrics.FUNCTION_COMPLEXITY;
- }
-
- /**
- * {@inheritDoc}
- */
- public void decorate(Resource resource, DecoratorContext context) {
- if (!shouldDecorateResource(resource, context)) {
- return;
- }
- Double functions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.FUNCTIONS), null);
- Double complexity = MeasureUtils.getValue(context.getMeasure(CoreMetrics.COMPLEXITY), null);
- if (complexity != null && functions != null && functions > 0.0) {
- context.saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, complexity / functions);
- }
- }
-
- private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
- return !MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY));
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDistributionDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDistributionDecorator.java
deleted file mode 100644
index 9d01f1ce16c..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDistributionDecorator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.api.batch;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.CountDistributionBuilder;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-/**
- * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore
- * @since 2.0
- */
-@Deprecated
-public abstract class AbstractFunctionComplexityDistributionDecorator implements Decorator {
-
- private CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
- private Language language;
-
- public AbstractFunctionComplexityDistributionDecorator(Language language) {
- this.language = language;
- }
-
- @DependedUpon
- public Metric generatesMetrics() {
- return CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION;
- }
-
- public boolean shouldExecuteOnProject(Project project) {
- return language.equals(project.getLanguage());
- }
-
- public void decorate(Resource resource, DecoratorContext context) {
- if (shouldDecorateResource(context)) {
- reset();
- saveDistribution(context);
- }
- }
-
- private void saveDistribution(DecoratorContext context) {
- for (Measure childMeasure : context.getChildrenMeasures(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION)) {
- builder.add(childMeasure);
- }
-
- if (!builder.isEmpty()) {
- context.saveMeasure(builder.build());
- }
- }
-
- private void reset() {
- builder.clear();
- }
-
- private boolean shouldDecorateResource(DecoratorContext context) {
- return context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION) == null;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
index 084c505139f..f453c1e6579 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
@@ -43,10 +43,12 @@ public abstract class AbstractSourceImporter implements Sensor {
this.language = language;
}
+ @Override
public boolean shouldExecuteOnProject(Project project) {
return false;
}
+ @Override
public void analyse(Project project, SensorContext context) {
// Do not remove for backward compatibility
}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/FileFilter.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/FileFilter.java
deleted file mode 100644
index 22d7e693352..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/FileFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.sonar.api.scan.filesystem.FileSystemFilter;
-
-import java.io.File;
-
-/**
- * @deprecated in 3.5. Replaced by {@link org.sonar.api.scan.filesystem.FileSystemFilter}
- */
-@Deprecated
-public abstract class FileFilter implements java.io.FileFilter, FileSystemFilter {
- public final boolean accept(File file, FileSystemFilter.Context context) {
- return accept(file);
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/charts/AbstractChart.java b/sonar-deprecated/src/main/java/org/sonar/api/charts/AbstractChart.java
index 016ab133322..acbeb318b96 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/charts/AbstractChart.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/charts/AbstractChart.java
@@ -56,6 +56,7 @@ public abstract class AbstractChart implements Chart {
* @param params the chart parameters
* @return the generated chart
*/
+ @Override
public BufferedImage generateImage(ChartParameters params) {
JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, getPlot(params), hasLegend());
improveChart(chart, params);
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/NoSonarFilter.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/NoSonarFilter.java
index 05c4bd9bfaf..ad2e60488ff 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/checks/NoSonarFilter.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/NoSonarFilter.java
@@ -53,6 +53,7 @@ public class NoSonarFilter implements ViolationFilter {
}
}
+ @Override
public boolean isIgnored(Violation violation) {
boolean ignored = false;
if (violation.getResource() != null && violation.getLineId() != null) {
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/measures/AverageComplexityFormula.java b/sonar-deprecated/src/main/java/org/sonar/api/measures/AverageComplexityFormula.java
deleted file mode 100644
index 8fdd195314d..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/measures/AverageComplexityFormula.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.api.measures;
-
-/**
- * Compute complexity by 'X', where 'X' can be any metric, like "file" for instance.
- *
- * @since 2.1
- * @deprecated since 3.0. Use {@link AverageFormula} instead.
- */
-@Deprecated
-public class AverageComplexityFormula extends AverageFormula {
-
- public AverageComplexityFormula(Metric byMetric) {
- super(CoreMetrics.COMPLEXITY, byMetric);
- }
-
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java
deleted file mode 100644
index d3b84256aba..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.resources;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @deprecated replaced by {@link org.sonar.api.scan.filesystem.ModuleFileSystem} and {@link org.sonar.api.scan.filesystem.PathResolver} in 3.5
- */
-@Deprecated
-public class DefaultProjectFileSystem {
- /**
- * getRelativePath("c:/foo/src/my/package/Hello.java", "c:/foo/src") is "my/package/Hello.java"
- *
- * @return null if file is not in dir (including recursive subdirectories)
- */
- public static String getRelativePath(java.io.File file, java.io.File dir) {
- return getRelativePath(file, Arrays.asList(dir));
- }
-
- /**
- * getRelativePath("c:/foo/src/my/package/Hello.java", ["c:/bar", "c:/foo/src"]) is "my/package/Hello.java".
- * <p>
- * Relative path is composed of slashes. Windows backslaches are replaced by /
- * </p>
- *
- * @return null if file is not in dir (including recursive subdirectories)
- */
- public static String getRelativePath(java.io.File file, List<java.io.File> dirs) {
- List<String> stack = new ArrayList<String>();
- String path = FilenameUtils.normalize(file.getAbsolutePath());
- java.io.File cursor = new java.io.File(path);
- while (cursor != null) {
- if (containsFile(dirs, cursor)) {
- return StringUtils.join(stack, "/");
- }
- stack.add(0, cursor.getName());
- cursor = cursor.getParentFile();
- }
- return null;
- }
-
- private static boolean containsFile(List<java.io.File> dirs, java.io.File cursor) {
- for (java.io.File dir : dirs) {
- if (FilenameUtils.equalsNormalizedOnSystem(dir.getAbsolutePath(), cursor.getAbsolutePath())) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
index f5c5b1a97b2..67b27bb4da8 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
@@ -67,6 +67,7 @@ public class Java extends AbstractLanguage {
*
* @see AbstractLanguage#getFileSuffixes()
*/
+ @Override
public String[] getFileSuffixes() {
return SUFFIXES;
}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
index b754732e01b..d852edd82d6 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
@@ -20,7 +20,6 @@
package org.sonar.api.resources;
import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
import java.util.Collection;
import java.util.List;
@@ -37,24 +36,6 @@ public final class ProjectUtils {
}
/**
- * @deprecated since 2.6 use JavaUtils.getTargetVersion() instead.
- */
- @Deprecated
- public static String getJavaVersion(Project project) {
- String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.target") : null;
- return StringUtils.isNotBlank(version) ? version : "1.5";
- }
-
- /**
- * @deprecated since 2.6 use JavaUtils.getSourceVersion() instead.
- */
- @Deprecated
- public static String getJavaSourceVersion(Project project) {
- String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.source") : null;
- return StringUtils.isNotBlank(version) ? version : "1.5";
- }
-
- /**
* @since 2.7
* @deprecated in 4.2. Replaced by org.sonar.api.resources.InputFileUtils#toFiles()
*/
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java
deleted file mode 100644
index 45ee16dc594..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.utils;
-
-import com.google.common.collect.Maps;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.staxmate.in.SMHierarchicCursor;
-import org.codehaus.staxmate.in.SMInputCursor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoverageMeasuresBuilder;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Resource;
-
-import javax.xml.stream.XMLStreamException;
-
-import java.io.File;
-import java.text.ParseException;
-import java.util.Map;
-
-import static java.util.Locale.ENGLISH;
-import static org.sonar.api.utils.ParsingUtils.parseNumber;
-
-/**
- * @since 3.7
- * @deprecated in 4.2. This class should be handled internally by plugins
- */
-@Deprecated
-public class CoberturaReportParserUtils {
-
- private CoberturaReportParserUtils() {
- }
-
- public interface FileResolver {
-
- /**
- * Return a SonarQube file resource from a filename present in Cobertura report
- */
- Resource resolve(String filename);
- }
-
- /**
- * Parse a Cobertura xml report and create measures accordingly
- */
- public static void parseReport(File xmlFile, final SensorContext context, final FileResolver fileResolver) {
- try {
- StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
-
- public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
- rootCursor.advance();
- collectPackageMeasures(rootCursor.descendantElementCursor("package"), context, fileResolver);
- }
- });
- parser.parse(xmlFile);
- } catch (XMLStreamException e) {
- throw new XmlParserException(e);
- }
- }
-
- private static void collectPackageMeasures(SMInputCursor pack, SensorContext context, final FileResolver fileResolver) throws XMLStreamException {
- while (pack.getNext() != null) {
- Map<String, CoverageMeasuresBuilder> builderByFilename = Maps.newHashMap();
- collectFileMeasures(pack.descendantElementCursor("class"), builderByFilename);
- for (Map.Entry<String, CoverageMeasuresBuilder> entry : builderByFilename.entrySet()) {
- String filename = sanitizeFilename(entry.getKey());
- Resource file = fileResolver.resolve(filename);
- if (fileExists(context, file)) {
- for (Measure measure : entry.getValue().createMeasures()) {
- context.saveMeasure(file, measure);
- }
- }
- }
- }
- }
-
- private static boolean fileExists(SensorContext context, Resource file) {
- return context.getResource(file) != null;
- }
-
- private static void collectFileMeasures(SMInputCursor clazz, Map<String, CoverageMeasuresBuilder> builderByFilename) throws XMLStreamException {
- while (clazz.getNext() != null) {
- String fileName = clazz.getAttrValue("filename");
- CoverageMeasuresBuilder builder = builderByFilename.get(fileName);
- if (builder == null) {
- builder = CoverageMeasuresBuilder.create();
- builderByFilename.put(fileName, builder);
- }
- collectFileData(clazz, builder);
- }
- }
-
- private static void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder) throws XMLStreamException {
- SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
- while (line.getNext() != null) {
- int lineId = Integer.parseInt(line.getAttrValue("number"));
- try {
- builder.setHits(lineId, (int) parseNumber(line.getAttrValue("hits"), ENGLISH));
- } catch (ParseException e) {
- throw new XmlParserException(e);
- }
-
- String isBranch = line.getAttrValue("branch");
- String text = line.getAttrValue("condition-coverage");
- if (StringUtils.equals(isBranch, "true") && StringUtils.isNotBlank(text)) {
- String[] conditions = StringUtils.split(StringUtils.substringBetween(text, "(", ")"), "/");
- builder.setConditions(lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
- }
- }
- }
-
- private static String sanitizeFilename(String s) {
- String fileName = FilenameUtils.removeExtension(s);
- fileName = fileName.replace('/', '.').replace('\\', '.');
- return fileName;
- }
-
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java b/sonar-deprecated/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java
index 3937abbabfa..addab4dca69 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java
@@ -26,10 +26,12 @@ package org.sonar.api.web;
@Deprecated
public abstract class AbstractDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ @Override
public String getId() {
return getClass().getSimpleName();
}
+ @Override
public String getTitle() {
return getClass().getSimpleName();
}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/web/GwtExtension.java b/sonar-deprecated/src/main/java/org/sonar/api/web/GwtExtension.java
deleted file mode 100644
index 1d50831f4fc..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/web/GwtExtension.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.web;
-
-import org.sonar.api.ServerExtension;
-
-/**
- * @since 1.10
- * @deprecated in 3.7. Replaced by Ruby on Rails extensions
- */
-@Deprecated
-public interface GwtExtension extends ServerExtension {
- String getGwtId();
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/web/GwtPage.java b/sonar-deprecated/src/main/java/org/sonar/api/web/GwtPage.java
deleted file mode 100644
index e3f69cb41ee..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/web/GwtPage.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.web;
-
-/**
- * @since 1.11
- * @deprecated in 3.7. Replaced by Ruby on Rails pages.
- */
-@Deprecated
-public abstract class GwtPage implements Page, GwtExtension {
-
- public final String getId() {
- return getGwtId();
- }
-
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java b/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java
deleted file mode 100644
index c653ea92923..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.cobertura.api;
-
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.utils.CoberturaReportParserUtils;
-import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver;
-
-import java.io.File;
-
-/**
- * @since 2.4
- * @deprecated since 3.7 Used to keep backward compatibility since extraction
- * of Cobertura plugin.
- */
-@Deprecated
-public abstract class AbstractCoberturaParser {
-
- public void parseReport(File xmlFile, final SensorContext context) {
- CoberturaReportParserUtils.parseReport(xmlFile, context, new FileResolver() {
- @Override
- public Resource resolve(String filename) {
- return getResource(filename);
- }
- });
- }
-
- protected abstract Resource getResource(String fileName);
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
deleted file mode 100644
index e1baa0dce95..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.cobertura.api;
-
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenUtils;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.Logs;
-
-import java.io.File;
-
-/**
- * @since 2.4
- * @deprecated since 3.7 Used to keep backward compatibility since extraction
- * of Cobertura plugin. Should be duplicated in each project.
- */
-@Deprecated
-public final class CoberturaUtils {
-
- public static final String COBERTURA_GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
- public static final String COBERTURA_ARTIFACT_ID = "cobertura-maven-plugin";
- public static final String COBERTURA_REPORT_PATH_PROPERTY = "sonar.cobertura.reportPath";
-
- /**
- * @deprecated in 2.8, because assumes that Sonar executed from Maven. Not used any more in sonar-cobertura-plugin.
- * See http://jira.codehaus.org/browse/SONAR-2321
- * Used in groovy and flex plugins.
- */
- @Deprecated
- public static File getReport(Project project) {
- File report = getReportFromProperty(project);
- if (report == null) {
- report = getReportFromPluginConfiguration(project);
- }
- if (report == null) {
- report = getReportFromDefaultPath(project);
- }
-
- if (report == null || !report.exists() || !report.isFile()) {
- Logs.INFO.warn("Cobertura report not found at {}", report);
- report = null;
- }
- return report;
- }
-
- private static File getReportFromProperty(Project project) {
- String path = (String) project.getProperty(COBERTURA_REPORT_PATH_PROPERTY);
- if (path != null) {
- return project.getFileSystem().resolvePath(path);
- }
- return null;
- }
-
- private static File getReportFromPluginConfiguration(Project project) {
- MavenPlugin mavenPlugin = MavenPlugin.getPlugin(project.getPom(), COBERTURA_GROUP_ID, COBERTURA_ARTIFACT_ID);
- if (mavenPlugin != null) {
- String path = mavenPlugin.getParameter("outputDirectory");
- if (path != null) {
- return new File(project.getFileSystem().resolvePath(path), "coverage.xml");
- }
- }
- return null;
- }
-
- private static File getReportFromDefaultPath(Project project) {
- return new File(project.getFileSystem().getReportOutputDir(), "cobertura/coverage.xml");
- }
-
- private CoberturaUtils() {
- }
-
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java b/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java
deleted file mode 100644
index 71a6420d733..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.junit.Test;
-import org.sonar.api.resources.Project;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class AbstractCoverageExtensionTest {
- @Test
- public void should_execute_if_dynamic_analysis() {
- Project project = new Project("foo");
- AbstractCoverageExtension extension = new AbstractCoverageExtension() {
- };
-
- project.setAnalysisType(Project.AnalysisType.DYNAMIC);
- assertThat(extension.shouldExecuteOnProject(project)).isTrue();
-
- project.setAnalysisType(Project.AnalysisType.REUSE_REPORTS);
- assertThat(extension.shouldExecuteOnProject(project)).isTrue();
-
- project.setAnalysisType(Project.AnalysisType.STATIC);
- assertThat(extension.shouldExecuteOnProject(project)).isFalse();
- }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFileComplexityDecoratorTest.java b/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFileComplexityDecoratorTest.java
deleted file mode 100644
index 79675c3db57..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFileComplexityDecoratorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.junit.Test;
-import static org.mockito.Mockito.*;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.File;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Resource;
-
-public class AbstractFileComplexityDecoratorTest {
-
- @Test
- public void calculateFileComplexity() {
-
- Resource directory = new Directory("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 20.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
-
- new AbstractFileComplexityDecorator(Java.INSTANCE) {
- }.decorate(directory, context);
-
- verify(context).saveMeasure(CoreMetrics.FILE_COMPLEXITY, 25.0);
- }
-
- @Test
- public void noAverageIfMissingData() {
-
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 20.0));
- Resource directory = new Directory("fake");
-
- new AbstractFileComplexityDecorator(Java.INSTANCE) {
- }.decorate(directory, context);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.FILE_COMPLEXITY), anyDouble());
- }
-
- @Test
- public void noAverageIfZeroFiles() {
- AbstractFileComplexityDecorator decorator = new AbstractFileComplexityDecorator(Java.INSTANCE) {
- };
-
- Resource directory = new Directory("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 0.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
-
- decorator.decorate(directory, context);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.FILE_COMPLEXITY), anyDouble());
- }
-
- @Test
- public void doNotCalculateOnFiles() {
-
- Resource file = new File("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 1.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 25.0));
-
- new AbstractFileComplexityDecorator(Java.INSTANCE) {
- }.decorate(file, context);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.FILE_COMPLEXITY), anyDouble());
- }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFunctionComplexityDecoratorTest.java b/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFunctionComplexityDecoratorTest.java
deleted file mode 100644
index bb89a46f3a6..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractFunctionComplexityDecoratorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.junit.Test;
-import static org.mockito.Mockito.*;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.File;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Resource;
-
-public class AbstractFunctionComplexityDecoratorTest {
-
- @Test
- public void calculateFunctionComplexity() {
-
- Resource directory = new Directory("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 200.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
-
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
- }.decorate(directory, context);
-
- verify(context).saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, 2.5);
- }
-
- @Test
- public void noAverageIfMissingData() {
-
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 20.0));
- Resource directory = new Directory("fake");
-
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
- }.decorate(directory, context);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
- }
-
- @Test
- public void noAverageIfZeroFiles() {
- AbstractFunctionComplexityDecorator decorator = new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
- };
-
- Resource directory = new Directory("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 0.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
-
- decorator.decorate(directory, context);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
- }
-
- @Test
- public void doNotCalculateOnFiles() {
-
- Resource file = new File("fake");
- DecoratorContext context = mock(DecoratorContext.class);
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 1.0));
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 25.0));
-
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
- }.decorate(file, context);
-
- verify(context).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
- }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
deleted file mode 100644
index 60b63e84de1..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaPackage;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.api.test.IsResource;
-import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.Matchers.is;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CoberturaReportParserUtilsTest {
-
- private SensorContext context;
-
- @Before
- public void setUp() {
- context = mock(SensorContext.class);
- }
-
- private static FileResolver JAVA_FILE_RESOLVER = new FileResolver() {
-
- @Override
- public Resource resolve(String filename) {
- return new org.sonar.api.resources.File(filename);
- }
- };
-
- @Test
- public void doNotCollectProjectCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.COVERAGE), anyDouble());
- }
-
- @Test
- public void doNotCollectProjectLineCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.LINE_COVERAGE), anyDouble());
- verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA)));
- }
-
- @Test
- public void doNotCollectProjectBranchCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure(eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
- }
-
- @Test
- public void collectPackageLineCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.LINE_COVERAGE), anyDouble());
- verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.UNCOVERED_LINES), anyDouble());
- }
-
- @Test
- public void collectPackageBranchCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
- verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());
- }
-
- @Test
- public void packageCoverageIsCalculatedLaterByDecorator() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.COVERAGE), anyDouble());
- }
-
- @Test
- public void collectFileLineCoverage() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
- verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 30.0)));
- verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 5.0)));
- }
-
- @Test
- public void collectFileBranchCoverage() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
- verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 6.0)));
- verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 2.0)));
- }
-
- @Test
- public void testDoNotSaveMeasureOnResourceWhichDoesntExistInTheContext() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(null);
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
- verify(context, never()).saveMeasure(any(Resource.class), any(Measure.class));
- }
-
- @Test
- public void javaInterfaceHasNoCoverage() throws URISyntaxException {
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
- final org.sonar.api.resources.File interfaze = new org.sonar.api.resources.File("org.apache.commons.chain.Chain");
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.COVERAGE)));
-
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.LINE_COVERAGE)));
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.BRANCH_COVERAGE)));
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
- verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
- }
-
- @Test
- public void shouldInsertCoverageAtFileLevel() throws URISyntaxException {
- File coverage = new File(getClass().getResource(
- "/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
- when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
- CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
-
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 35.0)));
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 22.0)));
-
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 4.0)));
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 3.0)));
-
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
- verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
- verify(context)
- .saveMeasure(
- eq(new org.sonar.api.resources.File("org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(
- CoreMetrics.COVERAGE_LINE_HITS_DATA,
- "22=2;25=0;26=0;29=0;30=0;31=0;34=1;35=1;36=1;37=0;39=1;41=1;44=2;46=1;47=1;50=0;51=0;52=0;53=0;55=0;57=0;60=0;61=0;64=1;71=1;73=1;76=0;77=0;80=0;81=0;85=0;87=0;91=0;93=0;96=1")));
- }
-
- @Test
- public void collectFileLineHitsData() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
- CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
- verify(context).saveMeasure(
- eq(new org.sonar.api.resources.File("org.apache.commons.chain.impl.CatalogBase")),
- argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA,
- "48=117;56=234;66=0;67=0;68=0;84=999;86=999;98=318;111=18;121=0;122=0;125=0;126=0;127=0;128=0;131=0;133=0")));
- }
-
- @Test
- public void shouldNotCountTwiceAnonymousClasses() throws URISyntaxException {
- File coverage = new File(getClass().getResource("/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldNotCountTwiceAnonymousClasses.xml").toURI());
- when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.samples.MyClass"));
- CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
-
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.MyFile")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 5.0))); // do not count line 26 twice
- }
-
- private File getCoverageReport() throws URISyntaxException {
- return new File(getClass().getResource("/org/sonar/api/utils/CoberturaReportParserUtilsTest/commons-chain-coverage.xml").toURI());
- }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java
deleted file mode 100644
index f8f1348645a..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.cobertura.api;
-
-import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.test.MavenTestUtils;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CoberturaUtilsTest {
- @Test
- public void shouldGetReportPathFromProperty() throws URISyntaxException {
- ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
- when(fileSystem.resolvePath("foo")).thenReturn(getCoverageReport());
-
- Project project = mock(Project.class);
- when(project.getFileSystem()).thenReturn(fileSystem);
- when(project.getProperty(CoberturaUtils.COBERTURA_REPORT_PATH_PROPERTY)).thenReturn("foo");
-
- File report = CoberturaUtils.getReport(project);
- verify(fileSystem).resolvePath("foo");
- assertNotNull(report);
- }
-
- @Test
- public void shouldGetReportPathFromPom() {
- MavenProject pom = MavenTestUtils.loadPom("/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml");
-
- ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
-
- Project project = mock(Project.class);
- when(project.getPom()).thenReturn(pom);
- when(project.getFileSystem()).thenReturn(fileSystem);
-
- CoberturaUtils.getReport(project);
-
- verify(fileSystem).resolvePath("overridden/dir");
- }
-
- private File getCoverageReport() throws URISyntaxException {
- return new File(getClass().getResource("/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml").toURI());
- }
-}