From 0935f7db60ce855eff8f6f52313f96392ea10577 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 4 Nov 2012 19:35:00 +0100 Subject: [PATCH] Temporarily revert org.sonar.api.batch.AbstractCoverageExtension --- sonar-deprecated/pom.xml | 19 +------ .../api/batch/AbstractCoverageExtension.java | 53 +++++++++++++++++++ .../batch/AbstractCoverageExtensionTest.java | 43 +++++++++++++++ 3 files changed, 98 insertions(+), 17 deletions(-) create mode 100644 sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java create mode 100644 sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java diff --git a/sonar-deprecated/pom.xml b/sonar-deprecated/pom.xml index be48c583afc..156a4667298 100644 --- a/sonar-deprecated/pom.xml +++ b/sonar-deprecated/pom.xml @@ -18,11 +18,6 @@ ${project.groupId} sonar-plugin-api - - xmlunit - xmlunit - test - junit junit @@ -34,18 +29,8 @@ test - org.hamcrest - hamcrest-all - test - - - org.dbunit - dbunit - test - - - ch.qos.logback - logback-classic + org.easytesting + fest-assert test 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 new file mode 100644 index 00000000000..36e696d2f07 --- /dev/null +++ b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java @@ -0,0 +1,53 @@ +/* + * 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.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/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java b/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java new file mode 100644 index 00000000000..4a1b303d87d --- /dev/null +++ b/sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractCoverageExtensionTest.java @@ -0,0 +1,43 @@ +/* + * 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.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(); + } +} -- 2.39.5