aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java3
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java8
-rw-r--r--plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java39
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java5
4 files changed, 21 insertions, 34 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
index 5e23416870d..7a5b86c0830 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
@@ -47,8 +47,7 @@ public class FindbugsSensor implements Sensor {
public boolean shouldExecuteOnProject(Project project) {
return project.getFileSystem().hasJavaSourceFiles()
- && !profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).isEmpty()
- && !StringUtils.equalsIgnoreCase(project.getPackaging(), "ear");
+ && !profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).isEmpty();
}
public void analyse(Project project, SensorContext context) {
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
index 24b8e5c9413..c7129175781 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
@@ -57,14 +57,6 @@ public class FindbugsSensorTest extends FindbugsTests {
}
@Test
- public void shouldNotExecuteOnEar() {
- Project project = createProject();
- when(project.getPackaging()).thenReturn("ear");
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithActiveRules(), new FakeRuleFinder(), null);
- assertFalse(analyser.shouldExecuteOnProject(project));
- }
-
- @Test
public void shouldExecuteFindbugsWhenNoReportProvided() throws Exception {
Project project = createProject();
FindbugsExecutor executor = mock(FindbugsExecutor.class);
diff --git a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java
index 15b007f9018..690603fc091 100644
--- a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java
+++ b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java
@@ -73,7 +73,6 @@ public class SurefireSensorTest {
new SurefireSensor().collect(project, mock(SensorContext.class), new File("unknown"));
}
-
private SensorContext mockContext() {
SensorContext context = mock(SensorContext.class);
when(context.isIndexed(any(Resource.class), eq(false))).thenReturn(true);
@@ -83,17 +82,17 @@ public class SurefireSensorTest {
@Test
public void shouldHandleTestSuiteDetails() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/shouldHandleTestSuiteDetails/").toURI()));
// 3 classes, 6 measures by class
- verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
eq(CoreMetrics.SKIPPED_TESTS), anyDouble());
- verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
eq(CoreMetrics.TESTS), anyDouble());
- verify(context, times(18)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(18)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
(Metric) anyObject(), anyDouble());
- verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
argThat(new IsMeasure(CoreMetrics.TEST_DATA)));
verify(context).saveMeasure(eq(new JavaFile("org.sonar.core.ExtensionsFinderTest", true)), eq(CoreMetrics.TESTS), eq(4d));
@@ -127,18 +126,18 @@ public class SurefireSensorTest {
@Test
public void shouldSaveErrorsAndFailuresInXML() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/shouldSaveErrorsAndFailuresInXML/").toURI()));
// 1 classes, 6 measures by class
- verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
eq(CoreMetrics.SKIPPED_TESTS), anyDouble());
- verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
eq(CoreMetrics.TESTS), anyDouble());
- verify(context, times(6)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(6)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
(Metric) anyObject(), anyDouble());
- verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)),
+ verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)),
argThat(new IsMeasure(CoreMetrics.TEST_DATA)));
verify(context).saveMeasure(eq(new JavaFile("org.sonar.core.ExtensionsFinderTest", true)),
@@ -148,7 +147,7 @@ public class SurefireSensorTest {
@Test
public void shouldManageClassesWithDefaultPackage() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/shouldManageClassesWithDefaultPackage/").toURI()));
verify(context).saveMeasure(new JavaFile("NoPackagesTest", true), CoreMetrics.TESTS, 2d);
@@ -157,7 +156,7 @@ public class SurefireSensorTest {
@Test
public void successRatioIsZeroWhenAllTestsFail() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/successRatioIsZeroWhenAllTestsFail/").toURI()));
verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(2d));
@@ -169,7 +168,7 @@ public class SurefireSensorTest {
@Test
public void measuresShouldNotIncludeSkippedTests() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/measuresShouldNotIncludeSkippedTests/").toURI()));
verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(2d));
@@ -182,7 +181,7 @@ public class SurefireSensorTest {
@Test
public void noSuccessRatioIfNoTests() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/noSuccessRatioIfNoTests/").toURI()));
verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(0d));
@@ -195,7 +194,7 @@ public class SurefireSensorTest {
@Test
public void ignoreSuiteAsInnerClass() throws URISyntaxException {
SensorContext context = mockContext();
- new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource(
+ new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource(
"/org/sonar/plugins/surefire/SurefireSensorTest/ignoreSuiteAsInnerClass/").toURI()));
// ignore TestHandler$Input.xml
@@ -232,12 +231,4 @@ public class SurefireSensorTest {
}
};
}
-
- private static Project newJarProject() {
- return new Project("key").setPackaging("jar");
- }
-
- private static Project newPomProject() {
- return new Project("key").setPackaging("pom");
- }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
index c7eb9c41600..8780c8b205e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
@@ -146,7 +146,9 @@ public class Project extends Resource {
/**
* @return the project's packaging
+ * @deprecated in 2.8. See http://jira.codehaus.org/browse/SONAR-2341
*/
+ @Deprecated
public String getPackaging() {
return packaging;
}
@@ -181,7 +183,10 @@ public class Project extends Resource {
/**
* For internal use only.
+ *
+ * @deprecated in 2.8. See http://jira.codehaus.org/browse/SONAR-2341
*/
+ @Deprecated
public Project setPackaging(String packaging) {
this.packaging = packaging;
return this;