aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenInitializer.java24
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java16
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java1
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSensor.java13
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.java53
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java74
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java61
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaPluginTest.java8
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java127
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java106
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java2
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java3
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java1
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java4
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java2
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java8
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java2
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java25
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java4
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java20
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java82
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseBatchCompatibility.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java4
26 files changed, 357 insertions, 292 deletions
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
index 473064784f3..54135a9a7ae 100644
--- 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
@@ -26,10 +26,8 @@ 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.Java;
import org.sonar.api.resources.Project;
import org.sonar.plugins.cobertura.api.CoberturaUtils;
-import org.sonar.plugins.java.api.JavaSettings;
/**
* Provides {@link CoberturaMavenPluginHandler} and configures correct path to report.
@@ -38,26 +36,20 @@ import org.sonar.plugins.java.api.JavaSettings;
public class CoberturaMavenInitializer extends Initializer implements CoverageExtension, DependsUponMavenPlugin {
private CoberturaMavenPluginHandler handler;
- private JavaSettings javaSettings;
+ private CoberturaSettings coberturaSettings;
- public CoberturaMavenInitializer(CoberturaMavenPluginHandler handler, JavaSettings javaSettings) {
+ public CoberturaMavenInitializer(CoberturaMavenPluginHandler handler, CoberturaSettings coberturaSettings) {
this.handler = handler;
- this.javaSettings = javaSettings;
+ this.coberturaSettings = coberturaSettings;
}
public MavenPluginHandler getMavenPluginHandler(Project project) {
- if (project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC)) {
- return handler;
- }
- return null;
+ return project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC) ? handler : null;
}
@Override
public boolean shouldExecuteOnProject(Project project) {
- return Java.KEY.equals(project.getLanguageKey())
- && CoberturaPlugin.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin())
- && !project.getFileSystem().mainFiles(Java.KEY).isEmpty()
- && project.getAnalysisType().isDynamic(true);
+ return coberturaSettings.isEnabled(project);
}
@Override
@@ -78,9 +70,9 @@ public class CoberturaMavenInitializer extends Initializer implements CoverageEx
private static String getReportPathFromPluginConfiguration(Project project) {
MavenPlugin mavenPlugin = MavenPlugin.getPlugin(
- project.getPom(),
- CoberturaUtils.COBERTURA_GROUP_ID,
- CoberturaUtils.COBERTURA_ARTIFACT_ID);
+ project.getPom(),
+ CoberturaUtils.COBERTURA_GROUP_ID,
+ CoberturaUtils.COBERTURA_ARTIFACT_ID);
if (mavenPlugin != null) {
String path = mavenPlugin.getParameter("outputDirectory");
if (path != 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
index 2be357df91e..90628197be7 100644
--- 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
@@ -20,19 +20,17 @@
package org.sonar.plugins.cobertura;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.CoreProperties;
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.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.plugins.cobertura.api.CoberturaUtils;
public class CoberturaMavenPluginHandler implements MavenPluginHandler {
- private Settings settings;
+ private CoberturaSettings settings;
- public CoberturaMavenPluginHandler(Settings settings) {
+ public CoberturaMavenPluginHandler(CoberturaSettings settings) {
this.settings = settings;
}
@@ -72,14 +70,6 @@ public class CoberturaMavenPluginHandler implements MavenPluginHandler {
}
coberturaPlugin.addParameter("instrumentation/excludes/exclude", pattern);
}
- String maxmem = "";
- // http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen")
- if (settings.hasKey("sonar.cobertura.maxmen")) {
- maxmem = settings.getString("sonar.cobertura.maxmen");
- } else {
- // use the "normal" key
- maxmem = settings.getString(CoreProperties.COBERTURA_MAXMEM_PROPERTY);
- }
- coberturaPlugin.setParameter("maxmem", maxmem);
+ 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
index 6bdda1bf9da..8fa103a25b8 100644
--- 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
@@ -47,6 +47,7 @@ public final class CoberturaPlugin extends SonarPlugin {
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
index 91c0347b3a6..2293ff8ca89 100644
--- 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
@@ -24,28 +24,23 @@ 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.Java;
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 org.sonar.plugins.java.api.JavaSettings;
import java.io.File;
public class CoberturaSensor implements Sensor, CoverageExtension {
- private JavaSettings javaSettings;
+ private CoberturaSettings settings;
- public CoberturaSensor(JavaSettings javaSettings) {
- this.javaSettings = javaSettings;
+ public CoberturaSensor(CoberturaSettings settings) {
+ this.settings = settings;
}
public boolean shouldExecuteOnProject(Project project) {
- return Java.KEY.equals(project.getLanguageKey())
- && CoberturaPlugin.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin())
- && !project.getFileSystem().mainFiles(Java.KEY).isEmpty()
- && project.getAnalysisType().isDynamic(true);
+ return settings.isEnabled(project);
}
public void analyse(Project project, SensorContext context) {
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
new file mode 100644
index 00000000000..441274db203
--- /dev/null
+++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaSettings.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.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/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenInitializerTest.java
index 1e3b4790cab..b7788a0902f 100644
--- 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
@@ -19,28 +19,18 @@
*/
package org.sonar.plugins.cobertura;
-import com.google.common.collect.Lists;
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.config.Settings;
-import org.sonar.api.resources.InputFile;
-import org.sonar.api.resources.InputFileUtils;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectFileSystem;
import org.sonar.api.test.MavenTestUtils;
-import org.sonar.plugins.java.api.JavaSettings;
import java.io.File;
-import java.util.ArrayList;
import static org.fest.assertions.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -52,82 +42,34 @@ public class CoberturaMavenInitializerTest {
private Project project;
private CoberturaMavenInitializer initializer;
+ private CoberturaMavenPluginHandler handler;
+ private CoberturaSettings settings;
@Before
public void setUp() {
project = mock(Project.class);
- JavaSettings javaSettings = mock(JavaSettings.class);
- when(javaSettings.getEnabledCoveragePlugin()).thenReturn("cobertura");
- initializer = new CoberturaMavenInitializer(new CoberturaMavenPluginHandler(new Settings()), javaSettings);
+ handler = mock(CoberturaMavenPluginHandler.class);
+ settings = mock(CoberturaSettings.class);
+ initializer = new CoberturaMavenInitializer(handler, settings);
}
- @Test
- public void shouldNotAnalyseIfNoJavaProject() {
- Project project = mock(Project.class);
- when(project.getLanguageKey()).thenReturn("php");
- assertThat(initializer.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldNotAnalyseIfJavaProjectButNoSource() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(new ArrayList<InputFile>());
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- assertThat(initializer.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldNotAnalyseIfJavaProjectWithSourceButStatic() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
- assertThat(initializer.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldAnalyse() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
- assertThat(initializer.shouldExecuteOnProject(project)).isTrue();
- }
-
- @Test
- public void shouldAnalyseIfReuseDynamicReports() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
- assertThat(initializer.shouldExecuteOnProject(project)).isTrue();
- }
@Test
public void doNotExecuteMavenPluginIfReuseReports() {
when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
- assertThat(initializer.getMavenPluginHandler(project), nullValue());
+ assertThat(initializer.getMavenPluginHandler(project)).isNull();
}
@Test
public void doNotExecuteMavenPluginIfStaticAnalysis() {
when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
- assertThat(initializer.getMavenPluginHandler(project), nullValue());
+ assertThat(initializer.getMavenPluginHandler(project)).isNull();
}
@Test
public void executeMavenPluginIfDynamicAnalysis() {
when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
- assertThat(initializer.getMavenPluginHandler(project), not(nullValue()));
- assertThat(initializer.getMavenPluginHandler(project).getArtifactId(), is("cobertura-maven-plugin"));
+ assertThat(initializer.getMavenPluginHandler(project)).isSameAs(handler);
}
@Test
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
index c140ce4be47..756fc211bda 100644
--- 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
@@ -19,38 +19,46 @@
*/
package org.sonar.plugins.cobertura;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
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.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
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 {
- protected CoberturaMavenPluginHandler handler;
+ private CoberturaMavenPluginHandler handler;
+ private CoberturaSettings settings;
@Before
public void before() {
- handler = new CoberturaMavenPluginHandler(new Settings(new PropertyDefinitions(CoberturaPlugin.class)));
+ settings = mock(CoberturaSettings.class);
+ handler = new CoberturaMavenPluginHandler(settings);
}
@Test
- public void notFixedVersion() {
+ 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(new CoberturaMavenPluginHandler(null).isFixedVersion(), is(false));
+ assertThat(handler.isFixedVersion()).isFalse();
}
@Test
- public void activateXmlFormat() {
+ 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());
when(project.getExclusionPatterns()).thenReturn(new String[0]);
@@ -58,38 +66,31 @@ public class CoberturaMavenPluginHandlerTest {
MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null);
handler.configure(project, coberturaPlugin);
- assertThat(coberturaPlugin.getParameter("formats/format"), is("xml"));
+ assertThat(coberturaPlugin.getParameter("formats/format")).isEqualTo("xml");
}
@Test
- public void setCoberturaExclusions() {
+ public void should_set_cobertura_exclusions() {
Project project = mock(Project.class);
when(project.getPom()).thenReturn(new MavenProject());
- when(project.getExclusionPatterns()).thenReturn(new String[] { "**/Foo.java", "com/*Test.*", "com/*" });
+ when(project.getExclusionPatterns()).thenReturn(new String[]{"**/Foo.java", "com/*Test.*", "com/*"});
MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null);
handler.configure(project, coberturaPlugin);
- assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[0], is("**/Foo.class"));
- assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[1], is("com/*Test.*"));
- assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[2], is("com/*.class"));
+ assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")).isEqualTo(new String[]{
+ "**/Foo.class", "com/*Test.*", "com/*.class"
+ });
}
@Test
- // http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen")
- public void checkOldParamNameCompatibility() {
- Settings settings = new Settings(new PropertyDefinitions(CoberturaPlugin.class));
- settings.setProperty("sonar.cobertura.maxmen", "FOO");
- CoberturaMavenPluginHandler coberturaMavenPluginHandler = new CoberturaMavenPluginHandler(settings);
-
- Project project = mock(Project.class);
- when(project.getPom()).thenReturn(new MavenProject());
- when(project.getExclusionPatterns()).thenReturn(new String[0]);
-
+ public void should_set_max_memory() {
+ when(settings.getMaxMemory()).thenReturn("128m");
MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null);
- coberturaMavenPluginHandler.configure(project, coberturaPlugin);
+ Project project = mock(Project.class, Mockito.RETURNS_MOCKS);
+ handler.configure(project, coberturaPlugin);
- assertThat(coberturaPlugin.getParameter("maxmem"), is("FOO"));
+ 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
index deb4fcf7fc2..6d26094addf 100644
--- 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
@@ -19,14 +19,14 @@
*/
package org.sonar.plugins.cobertura;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
+import static org.fest.assertions.Assertions.assertThat;
+
public class CoberturaPluginTest {
@Test
- public void coberturaExtensions() {
- assertThat(new CoberturaPlugin().getExtensions().size(), greaterThan(1));
+ 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
index 6129610d183..3262d8037d1 100644
--- 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
@@ -19,15 +19,12 @@
*/
package org.sonar.plugins.cobertura;
-import com.google.common.collect.Lists;
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.InputFile;
-import org.sonar.api.resources.InputFileUtils;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
import org.sonar.api.resources.Project;
@@ -37,13 +34,10 @@ 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.plugins.java.api.JavaSettings;
import java.io.File;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import static org.fest.assertions.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyDouble;
@@ -63,72 +57,21 @@ public class CoberturaSensorTest {
@Before
public void setUp() {
context = mock(SensorContext.class);
- JavaSettings javaSettings = mock(JavaSettings.class);
- when(javaSettings.getEnabledCoveragePlugin()).thenReturn("cobertura");
- sensor = new CoberturaSensor(javaSettings);
- }
-
- @Test
- public void shouldNotAnalyseIfNoJavaProject() {
- Project project = mock(Project.class);
- when(project.getLanguageKey()).thenReturn("php");
- assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldNotAnalyseIfJavaProjectButNoSource() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(new ArrayList<InputFile>());
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldNotAnalyseIfJavaProjectWithSourceButStatic() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
- assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
- }
-
- @Test
- public void shouldAnalyse() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
- }
-
- @Test
- public void shouldAnalyseIfReuseDynamicReports() {
- Project project = mock(Project.class);
- ProjectFileSystem fs = mock(ProjectFileSystem.class);
- when(fs.mainFiles("java")).thenReturn(Lists.newArrayList(InputFileUtils.create(null, "")));
- when(project.getFileSystem()).thenReturn(fs);
- when(project.getLanguageKey()).thenReturn("java");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
+ 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"));
+ .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);
+ .thenReturn("notFound.xml")
+ .thenReturn(null);
sensor.analyse(project, context);
sensor.analyse(project, context);
@@ -225,52 +168,52 @@ public class CoberturaSensorTest {
@Test
public void shouldInsertCoverageAtFileLevel() throws URISyntaxException {
File coverage = new File(getClass().getResource(
- "/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
+ "/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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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)));
+ 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")));
+ .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
@@ -278,9 +221,9 @@ public class CoberturaSensorTest {
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")));
+ 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
@@ -290,7 +233,7 @@ public class CoberturaSensorTest {
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
+ argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 5.0))); // do not count line 26 twice
}
private File getCoverageReport() throws URISyntaxException {
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
new file mode 100644
index 00000000000..c36661b62c3
--- /dev/null
+++ b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSettingsTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.<InputFile>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-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
index 87355615f77..881c513819e 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
@@ -40,7 +40,7 @@ public class JaCoCoItSensor implements Sensor {
}
public boolean shouldExecuteOnProject(Project project) {
- return StringUtils.isNotBlank(configuration.getItReportPath()) && project.getAnalysisType().isDynamic(true);
+ return configuration.isEnabled(project) && StringUtils.isNotBlank(configuration.getItReportPath());
}
public void analyse(Project project, SensorContext context) {
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
index 4ead9748ed6..84c0c5f0a39 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
@@ -53,8 +53,7 @@ public class JaCoCoOverallSensor implements Sensor {
}
public boolean shouldExecuteOnProject(Project project) {
- return StringUtils.isNotBlank(configuration.getItReportPath())
- && project.getAnalysisType().isDynamic(true);
+ return configuration.isEnabled(project) && StringUtils.isNotBlank(configuration.getItReportPath());
}
public void analyse(Project project, SensorContext context) {
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
index a875b487405..025d4dd1714 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
@@ -20,7 +20,6 @@
package org.sonar.plugins.jacoco;
import com.google.common.collect.ImmutableList;
-import org.sonar.api.BatchExtension;
import org.sonar.api.SonarPlugin;
import java.util.List;
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java
index 8c7a4853563..d5d19c416af 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java
@@ -45,9 +45,7 @@ public class JaCoCoSensor implements Sensor, CoverageExtension {
}
public boolean shouldExecuteOnProject(Project project) {
- return Java.KEY.equals(project.getLanguageKey())
- && configuration.isEnabled()
- && project.getAnalysisType().isDynamic(true);
+ return configuration.isEnabled(project);
}
class UnitTestsAnalyzer extends AbstractAnalyzer {
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java
index 590d6a23ca4..85fefdebecb 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java
@@ -42,7 +42,7 @@ public class JacocoAntInitializer extends Initializer implements CoverageExtensi
@Override
public boolean shouldExecuteOnProject(org.sonar.api.resources.Project project) {
- return project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC);
+ return configuration.isEnabled(project) && project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC);
}
@Override
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java
index 65854800198..7d13a752630 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java
@@ -25,6 +25,8 @@ import org.sonar.api.BatchExtension;
import org.sonar.api.Properties;
import org.sonar.api.Property;
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;
@Properties({
@@ -118,8 +120,10 @@ public class JacocoConfiguration implements BatchExtension {
this.javaSettings = javaSettings;
}
- public boolean isEnabled() {
- return JaCoCoUtils.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin());
+ public boolean isEnabled(Project project) {
+ return Java.KEY.equals(project.getLanguageKey()) &&
+ project.getAnalysisType().isDynamic(true) &&
+ JaCoCoUtils.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin());
}
public String getReportPath() {
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java
index e35dea77564..c7c320537a3 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java
@@ -40,7 +40,7 @@ public class JacocoMavenInitializer extends Initializer implements CoverageExten
@Override
public boolean shouldExecuteOnProject(Project project) {
- return configuration.isEnabled()
+ return configuration.isEnabled(project)
&& project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC)
&& !project.getFileSystem().testFiles(Java.KEY).isEmpty();
}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
index 18d3a641f2b..a36882c4f0a 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
@@ -37,8 +37,7 @@ import org.sonar.test.TestUtils;
import java.io.File;
import java.io.IOException;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.argThat;
@@ -72,7 +71,7 @@ public class JaCoCoItSensorTest {
@Test
public void testSensorDefinition() {
- assertThat(sensor.toString(), is("JaCoCoItSensor"));
+ assertThat(sensor.toString()).isEqualTo("JaCoCoItSensor");
}
@Test
@@ -80,17 +79,27 @@ public class JaCoCoItSensorTest {
Project project = mock(Project.class);
when(configuration.getItReportPath()).thenReturn("");
- assertThat(sensor.shouldExecuteOnProject(project), is(false));
+ assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
}
@Test
- public void shouldExecuteOnProject() {
+ public void shouldExecuteIfReportPathIsDefined() {
Project project = mock(Project.class);
+ when(project.getAnalysisType()).thenReturn(AnalysisType.DYNAMIC).thenReturn(AnalysisType.REUSE_REPORTS);
when(configuration.getItReportPath()).thenReturn("target/it-jacoco.exec");
+ when(configuration.isEnabled(project)).thenReturn(true);
+
+ assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
+ }
+
+ @Test
+ public void shouldNotExecuteIfReportPathIsNotDefined() {
+ Project project = mock(Project.class);
when(project.getAnalysisType()).thenReturn(AnalysisType.DYNAMIC).thenReturn(AnalysisType.REUSE_REPORTS);
+ when(configuration.getItReportPath()).thenReturn(null);
+ when(configuration.isEnabled(project)).thenReturn(true);
- assertThat(sensor.shouldExecuteOnProject(project), is(true));
- assertThat(sensor.shouldExecuteOnProject(project), is(true));
+ assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
}
@Test
@@ -110,7 +119,7 @@ public class JaCoCoItSensorTest {
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_LINES_TO_COVER, 7.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_LINES, 3.0)));
verify(context).saveMeasure(eq(resource),
- argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
+ argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_BY_LINE, "15=2")));
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
index b9cabe9efe8..0525c62b5bc 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
@@ -51,10 +51,10 @@ public class JaCoCoOverallSensorTest {
private final JaCoCoOverallSensor sensor = new JaCoCoOverallSensor(configuration);
@Test
- public void should_execute_on_project() {
+ public void should_execute_if_report_path_is_set() {
Project project = mock(Project.class);
when(configuration.getItReportPath()).thenReturn("target/it-jacoco.exec");
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC).thenReturn(Project.AnalysisType.REUSE_REPORTS);
+ when(configuration.isEnabled(project)).thenReturn(true);
assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java
index 6501a60dbaf..fcc6bacabd7 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java
@@ -26,7 +26,6 @@ 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.Java;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectFileSystem;
@@ -71,7 +70,6 @@ public class JaCoCoSensorTest {
@Before
public void setUp() {
configuration = mock(JacocoConfiguration.class);
- when(configuration.isEnabled()).thenReturn(true);
sensor = new JaCoCoSensor(configuration);
}
@@ -81,20 +79,14 @@ public class JaCoCoSensorTest {
}
@Test
- public void shouldNotExecuteOnProject() {
+ public void shouldExecuteIfEnabled() {
Project project = mock(Project.class);
- when(project.getLanguageKey()).thenReturn("flex");
-
- assertThat(sensor.shouldExecuteOnProject(project), is(false));
- }
-
- @Test
- public void shouldExecuteOnProject() {
- Project project = mock(Project.class);
- when(project.getLanguageKey()).thenReturn(Java.KEY);
- when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
+ when(configuration.isEnabled(project)).thenReturn(true);
assertThat(sensor.shouldExecuteOnProject(project), is(true));
+
+ when(configuration.isEnabled(project)).thenReturn(false);
+ assertThat(sensor.shouldExecuteOnProject(project), is(false));
}
@Test
@@ -114,7 +106,7 @@ public class JaCoCoSensorTest {
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 7.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 3.0)));
verify(context).saveMeasure(eq(resource),
- argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
+ argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.CONDITIONS_BY_LINE, "15=2" +
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java
index 4889553a064..f548d7963b4 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java
@@ -23,20 +23,20 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.config.PropertyDefinitions;
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;
import java.io.File;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class JacocoConfigurationTest {
private Settings settings;
- private JacocoConfiguration jacocoConfiguration;
+ private JacocoConfiguration jacocoSettings;
private JavaSettings javaSettings;
@Before
@@ -45,42 +45,91 @@ public class JacocoConfigurationTest {
when(downloader.getAgentJarFile()).thenReturn(new File("jacocoagent.jar"));
javaSettings = mock(JavaSettings.class);
settings = new Settings(new PropertyDefinitions(JacocoConfiguration.class));
+ jacocoSettings = new JacocoConfiguration(settings, downloader, javaSettings);
+ }
+
+ @Test
+ public void should_be_enabled() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
+ when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
+
+ assertThat(jacocoSettings.isEnabled(project)).isTrue();
+ }
+
+ @Test
+ public void should_be_enabled_if_reuse_report() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
+ when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
+
+ assertThat(jacocoSettings.isEnabled(project)).isTrue();
+ }
+
+ @Test
+ public void should_be_enabled_if_static_analysis_only() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
+ when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
+
+ assertThat(jacocoSettings.isEnabled(project)).isFalse();
+ }
+
+ @Test
+ public void plugin_should_be_disabled() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
+ when(javaSettings.getEnabledCoveragePlugin()).thenReturn("cobertura");
+
+ assertThat(jacocoSettings.isEnabled(project)).isFalse();
+ }
+
+ @Test
+ public void should_be_disabled_if_not_java() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn("flex");
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
+ when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
- jacocoConfiguration = new JacocoConfiguration(settings, downloader, javaSettings);
+ assertThat(jacocoSettings.isEnabled(project)).isFalse();
}
@Test
public void defaults() {
- assertThat(jacocoConfiguration.getReportPath(), is("target/jacoco.exec"));
- assertThat(jacocoConfiguration.getJvmArgument(), is("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,excludes=*_javassist_*"));
+ assertThat(jacocoSettings.getReportPath()).isEqualTo("target/jacoco.exec");
+ assertThat(jacocoSettings.getJvmArgument()).isEqualTo("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,excludes=*_javassist_*");
- assertThat(jacocoConfiguration.getItReportPath(), nullValue());
+ assertThat(jacocoSettings.getItReportPath()).isNull();
- assertThat(jacocoConfiguration.getAntTargets(), is(new String[]{}));
+ assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{});
}
@Test
public void shouldReturnAntTargets() {
settings.setProperty(JacocoConfiguration.ANT_TARGETS_PROPERTY, "test");
- assertThat(jacocoConfiguration.getAntTargets(), is(new String[]{"test"}));
+ assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{"test"});
settings.setProperty(JacocoConfiguration.ANT_TARGETS_PROPERTY, "test1,test2");
- assertThat(jacocoConfiguration.getAntTargets(), is(new String[]{"test1", "test2"}));
+ assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{"test1", "test2"});
}
@Test
public void shouldReturnItReportPath() {
settings.setProperty(JacocoConfiguration.IT_REPORT_PATH_PROPERTY, "target/it-jacoco.exec");
- assertThat(jacocoConfiguration.getItReportPath(), is("target/it-jacoco.exec"));
+ assertThat(jacocoSettings.getItReportPath()).isEqualTo("target/it-jacoco.exec");
}
@Test
public void shouldSetDestfile() {
settings.setProperty(JacocoConfiguration.REPORT_PATH_PROPERTY, "jacoco.exec");
- assertThat(jacocoConfiguration.getReportPath(), is("jacoco.exec"));
- assertThat(jacocoConfiguration.getJvmArgument(), is("-javaagent:jacocoagent.jar=destfile=jacoco.exec,excludes=*_javassist_*"));
+ assertThat(jacocoSettings.getReportPath()).isEqualTo("jacoco.exec");
+ assertThat(jacocoSettings.getJvmArgument()).isEqualTo("-javaagent:jacocoagent.jar=destfile=jacoco.exec,excludes=*_javassist_*");
}
@Test
@@ -89,8 +138,9 @@ public class JacocoConfigurationTest {
settings.setProperty(JacocoConfiguration.EXCLUDES_PROPERTY, "org.sonar.api.*");
settings.setProperty(JacocoConfiguration.EXCLCLASSLOADER_PROPERTY, "sun.reflect.DelegatingClassLoader");
- assertThat(jacocoConfiguration.getJvmArgument(),
- is("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,includes=org.sonar.*,excludes=org.sonar.api.*,exclclassloader=sun.reflect.DelegatingClassLoader"));
+ assertThat(jacocoSettings.getJvmArgument()).isEqualTo(
+ "-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,includes=org.sonar.*,excludes=org.sonar.api.*,exclclassloader=sun.reflect.DelegatingClassLoader"
+ );
}
}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java
index d6acbbd61df..e82fc70ad18 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java
@@ -42,7 +42,7 @@ public class JacocoMavenInitializerTest {
public void setUp() {
mavenPluginHandler = mock(JaCoCoMavenPluginHandler.class);
jacocoSettings = mock(JacocoConfiguration.class);
- when(jacocoSettings.isEnabled()).thenReturn(true);
+ when(jacocoSettings.isEnabled(any(Project.class))).thenReturn(true);
initializer = new JacocoMavenInitializer(mavenPluginHandler, jacocoSettings);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
index 64fbb25f8e7..2adca6754bb 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
@@ -27,8 +27,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.PluginMetadata;
import org.sonar.api.platform.PluginRepository;
@@ -39,7 +37,6 @@ import org.sonar.core.plugins.RemotePlugin;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseBatchCompatibility.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseBatchCompatibility.java
index ebe8342d221..9017d3225bf 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseBatchCompatibility.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseBatchCompatibility.java
@@ -22,12 +22,9 @@ package org.sonar.batch.bootstrap;
import org.sonar.api.BatchComponent;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
-import org.sonar.api.utils.SonarException;
import org.sonar.core.persistence.BadDatabaseVersion;
import org.sonar.core.persistence.DatabaseVersion;
-import java.io.IOException;
-
/**
* Detects if database is not up-to-date with the version required by the batch.
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java
index f76d40def19..8ee876bb65a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java
@@ -21,7 +21,6 @@ package org.sonar.api.platform;
import org.sonar.api.BatchComponent;
import org.sonar.api.Plugin;
-import org.sonar.api.Property;
import org.sonar.api.ServerComponent;
import java.util.Collection;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java b/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java
index 9b678016e9e..ffd6a6f299e 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java
@@ -22,8 +22,6 @@ package org.sonar.server.plugins;
import com.google.common.collect.Sets;
import org.slf4j.LoggerFactory;
import org.sonar.api.Plugin;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
import org.sonar.api.platform.PluginMetadata;
import org.sonar.api.platform.ServerPluginRepository;
import org.sonar.core.plugins.PluginClassloaders;
@@ -94,7 +92,7 @@ public class DefaultServerPluginRepository implements ServerPluginRepository {
return clazz;
}
-public Collection<PluginMetadata> getMetadata() {
+ public Collection<PluginMetadata> getMetadata() {
return deployer.getMetadata();
}