From 12c0921e08cb4176b3fe76824fb478350a70d0a0 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 6 Nov 2012 17:46:01 +0100 Subject: [PATCH] SONAR-3934 Extract sonar-cobertura-plugin into Sonar Java --- .../sonar-cobertura-plugin/infinitest.args | 1 - plugins/sonar-cobertura-plugin/pom.xml | 83 - .../cobertura/CoberturaMavenInitializer.java | 85 - .../CoberturaMavenPluginHandler.java | 65 - .../plugins/cobertura/CoberturaPlugin.java | 55 - .../plugins/cobertura/CoberturaSensor.java | 76 - .../plugins/cobertura/CoberturaSettings.java | 53 - .../api/AbstractCoberturaParser.java | 120 - .../plugins/cobertura/api/CoberturaUtils.java | 85 - .../CoberturaMavenInitializerTest.java | 104 - .../CoberturaMavenPluginHandlerTest.java | 81 - .../cobertura/CoberturaPluginTest.java | 32 - .../cobertura/CoberturaSensorTest.java | 242 - .../cobertura/CoberturaSettingsTest.java | 106 - .../cobertura/api/CoberturaUtilsTest.java | 70 - .../commons-chain-coverage.xml | 10201 ---------------- .../shouldGetReportPathFromPom/pom.xml | 21 - .../coverage.xml | 180 - .../shouldNotCountTwiceAnonymousClasses.xml | 40 - pom.xml | 6 +- sonar-application/pom.xml | 3 +- sonar-server/pom.xml | 4 +- 22 files changed, 8 insertions(+), 11705 deletions(-) delete mode 100644 plugins/sonar-cobertura-plugin/infinitest.args delete mode 100644 plugins/sonar-cobertura-plugin/pom.xml delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenInitializer.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSensor.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java delete mode 100644 plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaPluginTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java delete mode 100644 plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml delete mode 100644 plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml delete mode 100644 plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml delete mode 100644 plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldNotCountTwiceAnonymousClasses.xml diff --git a/plugins/sonar-cobertura-plugin/infinitest.args b/plugins/sonar-cobertura-plugin/infinitest.args deleted file mode 100644 index ed9f41dadc7..00000000000 --- a/plugins/sonar-cobertura-plugin/infinitest.args +++ /dev/null @@ -1 +0,0 @@ --Djava.awt.headless=true \ No newline at end of file diff --git a/plugins/sonar-cobertura-plugin/pom.xml b/plugins/sonar-cobertura-plugin/pom.xml deleted file mode 100644 index 8533e1158d1..00000000000 --- a/plugins/sonar-cobertura-plugin/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - sonar - 3.4-SNAPSHOT - ../.. - - org.codehaus.sonar.plugins - sonar-cobertura-plugin - sonar-plugin - Sonar :: Plugins :: Cobertura - - - - org.codehaus.sonar - sonar-plugin-api - provided - - - org.codehaus.sonar-plugins.java - sonar-java-plugin - ${sonarJava.version} - provided - - - - - - org.apache.maven - maven-project - provided - - - - org.codehaus.sonar - sonar-testing-harness - test - - - org.easytesting - fest-assert - test - - - - - - - ${basedir}/src/main/resources - - - ${basedir}/src/test/resources - - - - - org.codehaus.sonar - sonar-packaging-maven-plugin - - cobertura - Cobertura - org.sonar.plugins.cobertura.CoberturaPlugin - Cobertura.]]> - - - - - org.apache.maven.plugins - maven-surefire-plugin - - classes - 3 - true - - - - - diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenInitializer.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenInitializer.java deleted file mode 100644 index 54135a9a7ae..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenInitializer.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.apache.commons.configuration.Configuration; -import org.sonar.api.CoreProperties; -import org.sonar.api.batch.CoverageExtension; -import org.sonar.api.batch.Initializer; -import org.sonar.api.batch.maven.DependsUponMavenPlugin; -import org.sonar.api.batch.maven.MavenPlugin; -import org.sonar.api.batch.maven.MavenPluginHandler; -import org.sonar.api.resources.Project; -import org.sonar.plugins.cobertura.api.CoberturaUtils; - -/** - * Provides {@link CoberturaMavenPluginHandler} and configures correct path to report. - * Enabled only in Maven environment. - */ -public class CoberturaMavenInitializer extends Initializer implements CoverageExtension, DependsUponMavenPlugin { - - private CoberturaMavenPluginHandler handler; - private CoberturaSettings coberturaSettings; - - public CoberturaMavenInitializer(CoberturaMavenPluginHandler handler, CoberturaSettings coberturaSettings) { - this.handler = handler; - this.coberturaSettings = coberturaSettings; - } - - public MavenPluginHandler getMavenPluginHandler(Project project) { - return project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC) ? handler : null; - } - - @Override - public boolean shouldExecuteOnProject(Project project) { - return coberturaSettings.isEnabled(project); - } - - @Override - public void execute(Project project) { - Configuration conf = project.getConfiguration(); - if (!conf.containsKey(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY)) { - String report = getReportPathFromPluginConfiguration(project); - if (report == null) { - report = getDefaultReportPath(project); - } - conf.setProperty(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY, report); - } - } - - private static String getDefaultReportPath(Project project) { - return project.getFileSystem().getReportOutputDir() + "/cobertura/coverage.xml"; - } - - private static String getReportPathFromPluginConfiguration(Project project) { - MavenPlugin mavenPlugin = MavenPlugin.getPlugin( - project.getPom(), - CoberturaUtils.COBERTURA_GROUP_ID, - CoberturaUtils.COBERTURA_ARTIFACT_ID); - if (mavenPlugin != null) { - String path = mavenPlugin.getParameter("outputDirectory"); - if (path != null) { - return path + "/coverage.xml"; - } - } - return null; - } - -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java deleted file mode 100644 index 20a2aa9fcd0..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.sonar.api.batch.maven.MavenPlugin; -import org.sonar.api.batch.maven.MavenPluginHandler; -import org.sonar.api.batch.maven.MavenSurefireUtils; -import org.sonar.api.resources.Project; -import org.sonar.plugins.cobertura.api.CoberturaUtils; - -public class CoberturaMavenPluginHandler implements MavenPluginHandler { - - private final CoberturaSettings settings; - - public CoberturaMavenPluginHandler(CoberturaSettings settings) { - this.settings = settings; - } - - public String getGroupId() { - return CoberturaUtils.COBERTURA_GROUP_ID; - } - - public String getArtifactId() { - return CoberturaUtils.COBERTURA_ARTIFACT_ID; - } - - public String getVersion() { - return "2.5.1"; - } - - public boolean isFixedVersion() { - return false; - } - - public String[] getGoals() { - return new String[] {"cobertura"}; - } - - public void configure(Project project, MavenPlugin coberturaPlugin) { - configureCobertura(coberturaPlugin); - MavenSurefireUtils.configure(project); - } - - private void configureCobertura(MavenPlugin coberturaPlugin) { - coberturaPlugin.setParameter("formats/format", "xml"); - coberturaPlugin.setParameter("maxmem", settings.getMaxMemory()); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java deleted file mode 100644 index 8fa103a25b8..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import com.google.common.collect.ImmutableList; -import org.sonar.api.CoreProperties; -import org.sonar.api.Properties; -import org.sonar.api.Property; -import org.sonar.api.SonarPlugin; - -import java.util.List; - -@Properties({ - @Property( - key = CoreProperties.COBERTURA_REPORT_PATH_PROPERTY, - name = "Report path", - description = "Path (absolute or relative) to Cobertura xml report file.", - project = true, - global = false), - @Property( - key = CoreProperties.COBERTURA_MAXMEM_PROPERTY, - defaultValue = CoreProperties.COBERTURA_MAXMEM_DEFAULT_VALUE, - name = "Maxmem", - description = "Maximum memory to pass to JVM of Cobertura processes", - project = true, - global = true)}) -public final class CoberturaPlugin extends SonarPlugin { - - static final String PLUGIN_KEY = "cobertura"; - - public List getExtensions() { - return ImmutableList.of( - CoberturaSettings.class, - CoberturaSensor.class, - CoberturaMavenPluginHandler.class, - CoberturaMavenInitializer.class); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSensor.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSensor.java deleted file mode 100644 index 2293ff8ca89..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSensor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.slf4j.LoggerFactory; -import org.sonar.api.CoreProperties; -import org.sonar.api.batch.CoverageExtension; -import org.sonar.api.batch.Sensor; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; -import org.sonar.plugins.cobertura.api.AbstractCoberturaParser; - -import java.io.File; - -public class CoberturaSensor implements Sensor, CoverageExtension { - - private CoberturaSettings settings; - - public CoberturaSensor(CoberturaSettings settings) { - this.settings = settings; - } - - public boolean shouldExecuteOnProject(Project project) { - return settings.isEnabled(project); - } - - public void analyse(Project project, SensorContext context) { - String path = (String) project.getProperty(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY); - if (path == null) { - // wasn't configured - skip - return; - } - File report = project.getFileSystem().resolvePath(path); - if (!report.exists() || !report.isFile()) { - LoggerFactory.getLogger(getClass()).warn("Cobertura report not found at {}", report); - return; - } - parseReport(report, context); - } - - protected void parseReport(File xmlFile, final SensorContext context) { - LoggerFactory.getLogger(CoberturaSensor.class).info("parsing {}", xmlFile); - new JavaCoberturaParser().parseReport(xmlFile, context); - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } - - private static final class JavaCoberturaParser extends AbstractCoberturaParser { - @Override - protected Resource getResource(String fileName) { - return new JavaFile(fileName); - } - } -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.java deleted file mode 100644 index 441274db203..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.BatchExtension; -import org.sonar.api.CoreProperties; -import org.sonar.api.config.Settings; -import org.sonar.api.resources.Java; -import org.sonar.api.resources.Project; -import org.sonar.plugins.java.api.JavaSettings; - -public class CoberturaSettings implements BatchExtension { - private Settings settings; - private JavaSettings javaSettings; - - public CoberturaSettings(Settings settings, JavaSettings javaSettings) { - this.settings = settings; - this.javaSettings = javaSettings; - } - - public boolean isEnabled(Project project) { - return Java.KEY.equals(project.getLanguageKey()) - && CoberturaPlugin.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin()) - && !project.getFileSystem().mainFiles(Java.KEY).isEmpty() - && project.getAnalysisType().isDynamic(true); - } - - public String getMaxMemory() { - // http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen") - return StringUtils.defaultIfEmpty( - settings.getString("sonar.cobertura.maxmen"), - settings.getString(CoreProperties.COBERTURA_MAXMEM_PROPERTY) - ); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java deleted file mode 100644 index c2b4534717a..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura.api; - -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 org.sonar.api.utils.StaxParser; -import org.sonar.api.utils.XmlParserException; - -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 2.4 - */ -public abstract class AbstractCoberturaParser { - - public void parseReport(File xmlFile, final SensorContext context) { - try { - StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { - - public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { - try { - rootCursor.advance(); - collectPackageMeasures(rootCursor.descendantElementCursor("package"), context); - } catch (ParseException e) { - throw new XMLStreamException(e); - } - } - }); - parser.parse(xmlFile); - } catch (XMLStreamException e) { - throw new XmlParserException(e); - } - } - - private void collectPackageMeasures(SMInputCursor pack, SensorContext context) throws ParseException, XMLStreamException { - while (pack.getNext() != null) { - Map builderByFilename = Maps.newHashMap(); - collectFileMeasures(pack.descendantElementCursor("class"), builderByFilename); - for (Map.Entry entry : builderByFilename.entrySet()) { - String filename = sanitizeFilename(entry.getKey()); - Resource file = getResource(filename); - if (fileExists(context, file)) { - for (Measure measure : entry.getValue().createMeasures()) { - context.saveMeasure(file, measure); - } - } - } - } - } - - private boolean fileExists(SensorContext context, Resource file) { - return context.getResource(file) != null; - } - - private void collectFileMeasures(SMInputCursor clazz, Map builderByFilename) throws ParseException, 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 void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder) throws ParseException, XMLStreamException { - SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line"); - while (line.getNext() != null) { - int lineId = Integer.parseInt(line.getAttrValue("number")); - builder.setHits(lineId, (int) parseNumber(line.getAttrValue("hits"), ENGLISH)); - - 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 String sanitizeFilename(String s) { - String fileName = FilenameUtils.removeExtension(s); - fileName = fileName.replace('/', '.').replace('\\', '.'); - return fileName; - } - - protected abstract Resource getResource(String fileName); -} diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java deleted file mode 100644 index 36540c4af9f..00000000000 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura.api; - -import org.sonar.api.CoreProperties; -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 - */ -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"; - - /** - * @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 - */ - @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(CoreProperties.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/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java deleted file mode 100644 index b7788a0902f..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.apache.commons.configuration.Configuration; -import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.CoreProperties; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.test.MavenTestUtils; - -import java.io.File; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Matchers.anyString; -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 CoberturaMavenInitializerTest { - - private Project project; - private CoberturaMavenInitializer initializer; - private CoberturaMavenPluginHandler handler; - private CoberturaSettings settings; - - @Before - public void setUp() { - project = mock(Project.class); - handler = mock(CoberturaMavenPluginHandler.class); - settings = mock(CoberturaSettings.class); - initializer = new CoberturaMavenInitializer(handler, settings); - } - - - @Test - public void doNotExecuteMavenPluginIfReuseReports() { - when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS); - assertThat(initializer.getMavenPluginHandler(project)).isNull(); - } - - @Test - public void doNotExecuteMavenPluginIfStaticAnalysis() { - when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC); - assertThat(initializer.getMavenPluginHandler(project)).isNull(); - } - - @Test - public void executeMavenPluginIfDynamicAnalysis() { - when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC); - assertThat(initializer.getMavenPluginHandler(project)).isSameAs(handler); - } - - @Test - public void doNotSetReportPathIfAlreadyConfigured() { - Configuration configuration = mock(Configuration.class); - when(configuration.containsKey(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY)).thenReturn(true); - when(project.getConfiguration()).thenReturn(configuration); - initializer.execute(project); - verify(configuration, never()).setProperty(eq(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY), anyString()); - } - - @Test - public void shouldSetReportPathFromPom() { - Configuration configuration = mock(Configuration.class); - when(project.getConfiguration()).thenReturn(configuration); - MavenProject pom = MavenTestUtils.loadPom("/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml"); - when(project.getPom()).thenReturn(pom); - initializer.execute(project); - verify(configuration).setProperty(eq(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY), eq("overridden/dir/coverage.xml")); - } - - @Test - public void shouldSetDefaultReportPath() { - ProjectFileSystem pfs = mock(ProjectFileSystem.class); - when(pfs.getReportOutputDir()).thenReturn(new File("reportOutputDir")); - Configuration configuration = mock(Configuration.class); - when(project.getConfiguration()).thenReturn(configuration); - when(project.getFileSystem()).thenReturn(pfs); - initializer.execute(project); - verify(configuration).setProperty(eq(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY), eq("reportOutputDir/cobertura/coverage.xml")); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java deleted file mode 100644 index 037bb749193..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.api.batch.maven.MavenPlugin; -import org.sonar.api.resources.Project; -import org.sonar.plugins.cobertura.api.CoberturaUtils; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CoberturaMavenPluginHandlerTest { - - private CoberturaMavenPluginHandler handler; - private CoberturaSettings settings; - - @Before - public void before() { - settings = mock(CoberturaSettings.class); - handler = new CoberturaMavenPluginHandler(settings); - } - - @Test - public void users_could_change_version() { - // first of all, version was fixed : see http://jira.codehaus.org/browse/SONAR-1055 - // but it's more reasonable to let users change the version : see http://jira.codehaus.org/browse/SONAR-1310 - assertThat(handler.isFixedVersion()).isFalse(); - } - - @Test - public void test_metadata() { - assertThat(handler.getGroupId()).isEqualTo("org.codehaus.mojo"); - assertThat(handler.getArtifactId()).isEqualTo("cobertura-maven-plugin"); - assertThat(handler.getVersion()).isEqualTo("2.5.1"); - assertThat(handler.getGoals()).containsOnly("cobertura"); - } - - @Test - public void should_enable_xml_format() { - Project project = mock(Project.class); - when(project.getPom()).thenReturn(new MavenProject()); - - MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null); - handler.configure(project, coberturaPlugin); - - assertThat(coberturaPlugin.getParameter("formats/format")).isEqualTo("xml"); - } - - @Test - public void should_set_max_memory() { - when(settings.getMaxMemory()).thenReturn("128m"); - MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null); - - Project project = mock(Project.class, Mockito.RETURNS_MOCKS); - handler.configure(project, coberturaPlugin); - - assertThat(coberturaPlugin.getParameter("maxmem")).isEqualTo("128m"); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaPluginTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaPluginTest.java deleted file mode 100644 index 6d26094addf..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaPluginTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.junit.Test; - -import static org.fest.assertions.Assertions.assertThat; - -public class CoberturaPluginTest { - - @Test - public void test_getExtensions() { - assertThat(new CoberturaPlugin().getExtensions().size()).isGreaterThan(1); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java deleted file mode 100644 index 3262d8037d1..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.CoreProperties; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.JavaPackage; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectFileSystem; -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 java.io.File; -import java.net.URISyntaxException; - -import static org.hamcrest.CoreMatchers.is; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyDouble; -import static org.mockito.Matchers.anyString; -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 CoberturaSensorTest { - - private SensorContext context; - private CoberturaSensor sensor; - - @Before - public void setUp() { - context = mock(SensorContext.class); - CoberturaSettings settings = mock(CoberturaSettings.class); - sensor = new CoberturaSensor(settings); - } - - @Test - public void shouldNotFailIfReportNotSpecifiedOrNotFound() { - ProjectFileSystem pfs = mock(ProjectFileSystem.class); - when(pfs.resolvePath(anyString())) - .thenReturn(new File("notFound.xml")); - - Project project = mock(Project.class); - when(project.getFileSystem()).thenReturn(pfs); - when(project.getProperty(eq(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY))) - .thenReturn("notFound.xml") - .thenReturn(null); - - sensor.analyse(project, context); - sensor.analyse(project, context); - } - - @Test - public void doNotCollectProjectCoverage() throws URISyntaxException { - sensor.parseReport(getCoverageReport(), context); - - verify(context, never()).saveMeasure(eq(CoreMetrics.COVERAGE), anyDouble()); - } - - @Test - public void doNotCollectProjectLineCoverage() throws URISyntaxException { - sensor.parseReport(getCoverageReport(), context); - - 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 { - sensor.parseReport(getCoverageReport(), context); - - verify(context, never()).saveMeasure(eq(CoreMetrics.BRANCH_COVERAGE), anyDouble()); - } - - @Test - public void collectPackageLineCoverage() throws URISyntaxException { - sensor.parseReport(getCoverageReport(), context); - - 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 { - sensor.parseReport(getCoverageReport(), context); - - 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 { - sensor.parseReport(getCoverageReport(), context); - - 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 JavaFile("org.sonar.MyClass")); - sensor.parseReport(getCoverageReport(), context); - - final JavaFile file = new JavaFile("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 JavaFile("org.sonar.MyClass")); - sensor.parseReport(getCoverageReport(), context); - - final JavaFile file = new JavaFile("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); - sensor.parseReport(getCoverageReport(), context); - verify(context, never()).saveMeasure(any(Resource.class), any(Measure.class)); - } - - @Test - public void javaInterfaceHasNoCoverage() throws URISyntaxException { - sensor.parseReport(getCoverageReport(), context); - - final JavaFile interfaze = new JavaFile("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/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI()); - when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass")); - sensor.parseReport(coverage, context); - - verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")), - argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 35.0))); - verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 22.0))); - - verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")), - argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 4.0))); - verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 3.0))); - - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")), - argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")), - argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES))); - - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")), - argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")), - argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS))); - verify(context, never()).saveMeasure( - argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")), - argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES))); - - verify(context) - .saveMeasure( - eq(new JavaFile("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 JavaFile("org.sonar.MyClass")); - sensor.parseReport(getCoverageReport(), context); - verify(context).saveMeasure( - eq(new JavaFile("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/plugins/cobertura/CoberturaSensorTest/shouldNotCountTwiceAnonymousClasses.xml").toURI()); - when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.samples.MyClass")); - sensor.parseReport(coverage, context); - - verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "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/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml").toURI()); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java deleted file mode 100644 index c36661b62c3..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.config.Settings; -import org.sonar.api.resources.InputFile; -import org.sonar.api.resources.InputFileUtils; -import org.sonar.api.resources.Java; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.plugins.java.api.JavaSettings; - -import java.util.Arrays; -import java.util.Collections; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CoberturaSettingsTest { - - private Settings settings; - private JavaSettings javaSettings; - private ProjectFileSystem fileSystem; - private Project javaProject; - private CoberturaSettings coberturaSettings; - - @Before - public void before() { - settings = new Settings(); - javaSettings = mock(JavaSettings.class); - when(javaSettings.getEnabledCoveragePlugin()).thenReturn("cobertura"); - fileSystem = mock(ProjectFileSystem.class); - when(fileSystem.mainFiles(Java.KEY)).thenReturn(Arrays.asList(InputFileUtils.create(null, ""))); - javaProject = mock(Project.class); - when(javaProject.getLanguageKey()).thenReturn(Java.KEY); - when(javaProject.getFileSystem()).thenReturn(fileSystem); - when(javaProject.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC); - coberturaSettings = new CoberturaSettings(settings, javaSettings); - } - - @Test - public void should_be_enabled_if_project_with_java_sources() { - assertThat(coberturaSettings.isEnabled(javaProject)).isTrue(); - } - - @Test - public void should_be_disabled_if_not_java() { - Project phpProject = mock(Project.class); - when(phpProject.getLanguageKey()).thenReturn("php"); - - assertThat(coberturaSettings.isEnabled(phpProject)).isFalse(); - } - - @Test - public void should_be_disabled_if_java_project_without_sources() { - when(fileSystem.mainFiles(Java.KEY)).thenReturn(Collections.emptyList()); - assertThat(coberturaSettings.isEnabled(javaProject)).isFalse(); - } - - @Test - public void should_be_disabled_if_static_analysis_only() { - when(javaProject.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC); - assertThat(coberturaSettings.isEnabled(javaProject)).isFalse(); - } - - @Test - public void should_be_enabled_if_reuse_report_mode() { - when(javaProject.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS); - assertThat(coberturaSettings.isEnabled(javaProject)).isTrue(); - } - - @Test - public void should_configure_max_memory() { - settings.setProperty("sonar.cobertura.maxmem", "128m"); - assertThat(coberturaSettings.getMaxMemory()).isEqualTo("128m"); - } - - /** - * http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen") - */ - @Test - public void should_support_deprecated_max_memory() { - settings.setProperty("sonar.cobertura.maxmen", "128m"); - assertThat(coberturaSettings.getMaxMemory()).isEqualTo("128m"); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java deleted file mode 100644 index 6db58710e88..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.cobertura.api; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.maven.project.MavenProject; -import org.junit.Test; -import org.sonar.api.CoreProperties; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.resources.Project; -import org.sonar.api.test.MavenTestUtils; - -import java.io.File; -import java.net.URISyntaxException; - -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(CoreProperties.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()); - } -} diff --git a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml b/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml deleted file mode 100644 index adb4f7b8c00..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml +++ /dev/null @@ -1,10201 +0,0 @@ - - - - - - /Users/simon/projects/commons-chain/src/java - --source - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml b/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml deleted file mode 100644 index ebef5af6643..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - 4.0.0 - fake.group - fake.artifactId - jar - 1.0-SNAPSHOT - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.2 - - overridden/dir - - - - - \ No newline at end of file diff --git a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml b/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml deleted file mode 100644 index 0f9517a4adc..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - /Users/simon/projects/sonar/trunk/tests/integration/reference-projects/reference/src/main/java - --source - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldNotCountTwiceAnonymousClasses.xml b/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldNotCountTwiceAnonymousClasses.xml deleted file mode 100644 index 55fa2986d6a..00000000000 --- a/plugins/sonar-cobertura-plugin/src/test/resources/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldNotCountTwiceAnonymousClasses.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - /Users/simon/projects/sonar/trunk/tests/integration/reference-projects/reference/src/main/java - --source - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 5a2596a7ace..e2b0c28e1e5 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,6 @@ plugins/sonar-core-gwt plugins/sonar-core-plugin plugins/sonar-dbcleaner-plugin - plugins/sonar-cobertura-plugin plugins/sonar-findbugs-plugin plugins/sonar-cpd-plugin plugins/sonar-design-plugin @@ -630,6 +629,11 @@ sonar-surefire-plugin ${sonarJava.version} + + org.codehaus.sonar-plugins.java + sonar-cobertura-plugin + ${sonarJava.version} + asm asm-all diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml index 9425fc70f28..ac950cdabfd 100644 --- a/sonar-application/pom.xml +++ b/sonar-application/pom.xml @@ -109,9 +109,8 @@ runtime - org.codehaus.sonar.plugins + org.codehaus.sonar-plugins.java sonar-cobertura-plugin - ${project.version} runtime diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml index 481d68de489..bf96e6d43df 100644 --- a/sonar-server/pom.xml +++ b/sonar-server/pom.xml @@ -440,9 +440,9 @@ provided - org.codehaus.sonar.plugins + org.codehaus.sonar-plugins.java sonar-cobertura-plugin - ${project.version} + ${sonarJava.version} sonar-plugin provided -- 2.39.5