aboutsummaryrefslogtreecommitdiffstats
path: root/it/src
diff options
context:
space:
mode:
authorJulien HENRY <henryju@yahoo.fr>2016-07-05 14:22:33 +0200
committerJulien HENRY <henryju@yahoo.fr>2016-07-05 14:22:33 +0200
commit062cc9de4ac3d480fb5f5544144572a5adee001c (patch)
tree876506a5f1b2a7475af4a1aa40d3dbc172afdf9e /it/src
parent879338a7853b557e353616a85f6371efa1c91605 (diff)
downloadsonar-scanner-cli-062cc9de4ac3d480fb5f5544144572a5adee001c.tar.gz
sonar-scanner-cli-062cc9de4ac3d480fb5f5544144572a5adee001c.zip
Fix ITs (Findbugs not compatible with Java 4.0)
Diffstat (limited to 'it/src')
-rw-r--r--it/src/test/java/com/sonar/runner/it/JavaTest.java65
-rw-r--r--it/src/test/java/com/sonar/runner/it/MultimoduleTest.java22
-rw-r--r--it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java2
-rw-r--r--it/src/test/resources/requires-bytecode-profile.xml4
4 files changed, 20 insertions, 73 deletions
diff --git a/it/src/test/java/com/sonar/runner/it/JavaTest.java b/it/src/test/java/com/sonar/runner/it/JavaTest.java
index 001ed23..7209ea9 100644
--- a/it/src/test/java/com/sonar/runner/it/JavaTest.java
+++ b/it/src/test/java/com/sonar/runner/it/JavaTest.java
@@ -36,7 +36,6 @@ import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import static org.fest.assertions.Assertions.assertThat;
-import static org.junit.Assume.assumeTrue;
public class JavaTest extends ScannerTestCase {
@@ -70,31 +69,16 @@ public class JavaTest extends ScannerTestCase {
assertThat(project.getName()).isEqualTo("Java Sample, with comma");
assertThat(project.getDescription()).isEqualTo("This is a Java sample");
assertThat(project.getVersion()).isEqualTo("1.2.3");
- if (!orchestrator.getServer().version().isGreaterThanOrEquals("4.2")) {
- assertThat(project.getLanguage()).isEqualTo("java");
- }
assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
assertThat(project.getMeasureIntValue("classes")).isEqualTo(2);
assertThat(project.getMeasureIntValue("ncloc")).isGreaterThan(10);
- assertThat(project.getMeasureIntValue("lcom4")).isNull(); // no bytecode
- if (orchestrator.getServer().version().isGreaterThanOrEquals("3.7")) {
- // the squid rules enabled in sonar-way-profile do not exist in SQ 3.0
- assertThat(project.getMeasureIntValue("violations")).isGreaterThan(0);
- }
+ assertThat(project.getMeasureIntValue("violations")).isGreaterThan(0);
Resource file = orchestrator.getServer().getWsClient()
- .find(new ResourceQuery(helloFileKey()).setMetrics("files", "ncloc", "classes", "lcom4", "violations"));
- if (orchestrator.getServer().version().isGreaterThanOrEquals("4.2")) {
- assertThat(file.getName()).isEqualTo("Hello.java");
- } else {
- assertThat(file.getName()).isEqualTo("Hello");
- assertThat(file.getMeasureIntValue("lcom4")).isNull(); // no bytecode
- }
+ .find(new ResourceQuery("java:sample:src/basic/Hello.java").setMetrics("files", "ncloc", "classes", "violations"));
+ assertThat(file.getName()).isEqualTo("Hello.java");
assertThat(file.getMeasureIntValue("ncloc")).isEqualTo(7);
- if (orchestrator.getServer().version().isGreaterThanOrEquals("3.7")) {
- // the squid rules enabled in sonar-way-profile do not exist in SQ 3.0
- assertThat(file.getMeasureIntValue("violations")).isGreaterThan(0);
- }
+ assertThat(file.getMeasureIntValue("violations")).isGreaterThan(0);
}
@Test
@@ -108,20 +92,16 @@ public class JavaTest extends ScannerTestCase {
Resource project = orchestrator.getServer().getWsClient().find(new ResourceQuery("java:bytecode").setMetrics("lcom4", "violations"));
assertThat(project.getName()).isEqualTo("Java Bytecode Sample");
- if (!orchestrator.getServer().version().isGreaterThanOrEquals("4.1")) {
- // SONAR-4853 LCOM4 is no more computed on SQ 4.1
- assertThat(project.getMeasureIntValue("lcom4")).isGreaterThanOrEqualTo(1);
- }
// the squid rules enabled in sonar-way-profile do not exist in SQ 3.0
assertThat(project.getMeasureIntValue("violations")).isGreaterThan(0);
- Resource file = orchestrator.getServer().getWsClient().find(new ResourceQuery(findbugsFileKey()).setMetrics("lcom4", "violations"));
+ Resource file = orchestrator.getServer().getWsClient().find(new ResourceQuery("java:bytecode:src/HasFindbugsViolation.java").setMetrics("lcom4", "violations"));
assertThat(file.getMeasureIntValue("violations")).isGreaterThan(0);
// findbugs is executed on bytecode
- List<Issue> issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().componentRoots("java:bytecode").rules("findbugs:DM_EXIT")).list();
+ List<Issue> issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().componentRoots("java:bytecode").rules("squid:S1147")).list();
assertThat(issues).hasSize(1);
- assertThat(issues.get(0).ruleKey()).isEqualTo("findbugs:DM_EXIT");
+ assertThat(issues.get(0).ruleKey()).isEqualTo("squid:S1147");
// Squid performs analysis of dependencies
issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().componentRoots("java:bytecode").rules("squid:CallToDeprecatedMethod")).list();
@@ -202,22 +182,6 @@ public class JavaTest extends ScannerTestCase {
}
/**
- * SONARPLUGINS-2203
- */
- @Test
- public void should_log_message_when_deprecated_properties_are_used() {
- assumeTrue(!orchestrator.getServer().version().isGreaterThanOrEquals("4.3"));
- SonarScanner build = newScanner(new File("projects/using-deprecated-props"));
-
- BuildResult result = orchestrator.executeBuild(build);
- String logs = result.getLogs();
- assertThat(logs).contains("/!\\ The 'sources' property is deprecated and is replaced by 'sonar.sources'. Don't forget to update your files.");
- assertThat(logs).contains("/!\\ The 'tests' property is deprecated and is replaced by 'sonar.tests'. Don't forget to update your files.");
- assertThat(logs).contains("/!\\ The 'binaries' property is deprecated and is replaced by 'sonar.binaries'. Don't forget to update your files.");
- assertThat(logs).contains("/!\\ The 'libraries' property is deprecated and is replaced by 'sonar.libraries'. Don't forget to update your files.");
- }
-
- /**
* SONARPLUGINS-2256
*/
@Test
@@ -303,19 +267,4 @@ public class JavaTest extends ScannerTestCase {
assertThat(logs).contains("java.lang.OutOfMemoryError");
}
- private String findbugsFileKey() {
- if (orchestrator.getServer().version().isGreaterThanOrEquals("4.2")) {
- return "java:bytecode:src/HasFindbugsViolation.java";
- } else {
- return "java:bytecode:[default].HasFindbugsViolation";
- }
- }
-
- private String helloFileKey() {
- if (orchestrator.getServer().version().isGreaterThanOrEquals("4.2")) {
- return "java:sample:src/basic/Hello.java";
- } else {
- return "java:sample:basic.Hello";
- }
- }
}
diff --git a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java b/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
index 2a7ef0a..2e02948 100644
--- a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
+++ b/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java
@@ -20,7 +20,7 @@
package com.sonar.runner.it;
import com.sonar.orchestrator.build.BuildResult;
-import com.sonar.orchestrator.build.SonarRunner;
+import com.sonar.orchestrator.build.SonarScanner;
import java.io.File;
import org.junit.After;
import org.junit.Test;
@@ -41,7 +41,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_simplest_with_props_on_root() {
- SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-root"));
+ SonarScanner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-root"));
orchestrator.executeBuild(build);
@@ -72,7 +72,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_multi_language_with_same_projectdir() {
- SonarRunner build = newScanner(new File("projects/multi-module/multi-language"));
+ SonarScanner build = newScanner(new File("projects/multi-module/multi-language"));
orchestrator.executeBuild(build);
@@ -95,7 +95,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_simplest_with_props_on_each_module() {
- SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
+ SonarScanner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
orchestrator.executeBuild(build);
@@ -118,7 +118,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_warning_when_source_folder_on_root_module() {
- SonarRunner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
+ SonarScanner build = newScanner(new File("projects/multi-module/simplest/simplest-with-props-on-each-module"));
assertThat(orchestrator.executeBuild(build).getLogs()).contains("/!\\ A multi-module project can't have source folders");
}
@@ -128,7 +128,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_deep_path_for_modules() {
- SonarRunner build = newScanner(new File("projects/multi-module/customization/deep-path-for-modules"));
+ SonarScanner build = newScanner(new File("projects/multi-module/customization/deep-path-for-modules"));
orchestrator.executeBuild(build);
@@ -151,7 +151,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_module_path_with_space() {
- SonarRunner build = newScanner(new File("projects/multi-module/customization/module-path-with-space"));
+ SonarScanner build = newScanner(new File("projects/multi-module/customization/module-path-with-space"));
orchestrator.executeBuild(build);
@@ -174,7 +174,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_overwriting_parent_properties() {
- SonarRunner build = newScanner(new File("projects/multi-module/customization/overwriting-parent-properties"));
+ SonarScanner build = newScanner(new File("projects/multi-module/customization/overwriting-parent-properties"));
orchestrator.executeBuild(build);
@@ -200,7 +200,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void test_using_config_file_property() {
- SonarRunner build = newScanner(new File("projects/multi-module/advanced/using-config-file-prop"));
+ SonarScanner build = newScanner(new File("projects/multi-module/advanced/using-config-file-prop"));
orchestrator.executeBuild(build);
@@ -223,7 +223,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void should_fail_if_unexisting_base_dir() {
- SonarRunner build = newScanner(new File("projects/multi-module/failures/unexisting-base-dir"));
+ SonarScanner build = newScanner(new File("projects/multi-module/failures/unexisting-base-dir"));
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
@@ -238,7 +238,7 @@ public class MultimoduleTest extends ScannerTestCase {
*/
@Test
public void should_fail_if_unexisting_config_file() {
- SonarRunner build = newScanner(new File("projects/multi-module/failures/unexisting-config-file"));
+ SonarScanner build = newScanner(new File("projects/multi-module/failures/unexisting-config-file"));
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
diff --git a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
index b835e67..890fe17 100644
--- a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
+++ b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
@@ -33,8 +33,6 @@ public class SonarScannerTestSuite {
public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
.setOrchestratorProperty("javaVersion", "LATEST_RELEASE")
.addPlugin("java")
- .setOrchestratorProperty("findbugsVersion", "LATEST_RELEASE")
- .addPlugin("findbugs")
.setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE")
.addPlugin("javascript")
.build();
diff --git a/it/src/test/resources/requires-bytecode-profile.xml b/it/src/test/resources/requires-bytecode-profile.xml
index 284596f..0e91e52 100644
--- a/it/src/test/resources/requires-bytecode-profile.xml
+++ b/it/src/test/resources/requires-bytecode-profile.xml
@@ -9,8 +9,8 @@
<priority>MINOR</priority>
</rule>
<rule>
- <repositoryKey>findbugs</repositoryKey>
- <key>DM_EXIT</key>
+ <repositoryKey>squid</repositoryKey>
+ <key>S1147</key>
<priority>MAJOR</priority>
</rule>
</rules>