From 2e23725e0457ab7a44e7701472c4d7a730699e2a Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 14 Jan 2019 16:48:56 +0100 Subject: [PATCH] Fix ITs after the drop of modules --- it/pom.xml | 14 +-- .../scanner/it/MultimoduleTest.java | 86 +++++++++++++------ .../sonarsource/scanner/it/ScannerTest.java | 6 +- .../scanner/it/SonarScannerTestSuite.java | 5 +- 4 files changed, 68 insertions(+), 43 deletions(-) diff --git a/it/pom.xml b/it/pom.xml index 663899c..dd5d845 100644 --- a/it/pom.xml +++ b/it/pom.xml @@ -22,7 +22,7 @@ - 5.6 + 6.7 @@ -36,7 +36,7 @@ org.sonarsource.orchestrator sonar-orchestrator - 3.15.1.1274 + 3.22.0.1791 junit @@ -53,18 +53,12 @@ org.sonarsource.sonarqube sonar-ws - 5.6 - - - org.easytesting - fest-assert - 1.4 - test + 6.7 org.assertj assertj-core - 2.1.0 + 3.11.1 diff --git a/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java b/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java index ecbfd7a..3346c71 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java @@ -26,7 +26,7 @@ import org.junit.After; import org.junit.Test; import org.sonarqube.ws.WsComponents.Component; -import static org.fest.assertions.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; public class MultimoduleTest extends ScannerTestCase { @@ -46,10 +46,15 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(getComponent("simplest-with-props-on-root").getName()).isEqualTo("Simplest multi-module project with all properties set on the root project"); - // Verify that we have the modules - assertThat(getComponent("simplest-with-props-on-root:module1").getName()).isEqualTo("module1"); - - assertThat(getComponent("simplest-with-props-on-root:module2").getName()).isEqualTo("module2"); + if (noMoreModules()) { + // Verify that we have the folders + assertThat(getComponent("simplest-with-props-on-root:module1/src").getName()).isEqualTo("module1/src"); + assertThat(getComponent("simplest-with-props-on-root:module2/src").getName()).isEqualTo("module2/src"); + } else { + // Verify that we have the modules + assertThat(getComponent("simplest-with-props-on-root:module1").getName()).isEqualTo("module1"); + assertThat(getComponent("simplest-with-props-on-root:module2").getName()).isEqualTo("module2"); + } // And verify that the working directories are all located in the root folder File workDir = new File("projects/multi-module/simplest/simplest-with-props-on-root/.scannerwork"); @@ -71,10 +76,14 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(getComponent("simplest-with-props-each-module").getName()).isEqualTo("Simplest multi-module project with properties set on each module"); - // Verify that we have the modules - assertThat(getComponent("simplest-with-props-each-module:module1").getName()).isEqualTo("module1"); - - assertThat(getComponent("simplest-with-props-each-module:overridden-key-for-module2").getName()).isEqualTo("Module 2"); + if (noMoreModules()) { + assertThat(getComponent("simplest-with-props-each-module:module1/src").getName()).isEqualTo("module1/src"); + assertThat(getComponent("simplest-with-props-each-module:module2/src").getName()).isEqualTo("module2/src"); + } else { + // Verify that we have the modules + assertThat(getComponent("simplest-with-props-each-module:module1").getName()).isEqualTo("module1"); + assertThat(getComponent("simplest-with-props-each-module:overridden-key-for-module2").getName()).isEqualTo("Module 2"); + } } /** @@ -88,10 +97,14 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(getComponent("deep-path-for-modules").getName()).isEqualTo("Project with deep path for modules"); - // Verify that we have the modules - assertThat(getComponent("deep-path-for-modules:mod1").getName()).isEqualTo("Module 1"); - - assertThat(getComponent("deep-path-for-modules:mod2").getName()).isEqualTo("Module 2"); + if (noMoreModules()) { + assertThat(getComponent("deep-path-for-modules:modules/module1/src").getName()).isEqualTo("module1/src"); + assertThat(getComponent("deep-path-for-modules:modules/module2/src").getName()).isEqualTo("module2/src"); + } else { + // Verify that we have the modules + assertThat(getComponent("deep-path-for-modules:mod1").getName()).isEqualTo("Module 1"); + assertThat(getComponent("deep-path-for-modules:mod2").getName()).isEqualTo("Module 2"); + } } /** @@ -105,10 +118,14 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(getComponent("module-path-with-space").getName()).isEqualTo("Project with module path that contain spaces"); - // Verify that we have the modules - assertThat(getComponent("module-path-with-space:module1").getName()).isEqualTo("Module 1"); - - assertThat(getComponent("module-path-with-space:module2").getName()).isEqualTo("Module 2"); + if (noMoreModules()) { + assertThat(getComponent("module-path-with-space:my module 1/src").getName()).isEqualTo("my module 1/src"); + assertThat(getComponent("module-path-with-space:my module 2/src").getName()).isEqualTo("my module 2/src"); + } else { + // Verify that we have the modules + assertThat(getComponent("module-path-with-space:module1").getName()).isEqualTo("Module 1"); + assertThat(getComponent("module-path-with-space:module2").getName()).isEqualTo("Module 2"); + } } /** @@ -124,14 +141,19 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(rootProject.getName()).isEqualTo("Project with modules that overwrite properties"); assertThat(rootProject.getDescription()).isEqualTo("Description of root project"); - // Verify that we have the modules - Component module1 = getComponent("overwriting-parent-properties:module1-new-key"); - assertThat(module1.getName()).isEqualTo("Module 1"); - assertThat(module1.getDescription()).isEqualTo("Description of module 1"); - - Component module2 = getComponent("overwriting-parent-properties:module2-new-key"); - assertThat(module2.getName()).isEqualTo("Module 2"); - assertThat(module2.getDescription()).isEqualTo("Description of module 2"); + if (noMoreModules()) { + assertThat(getComponent("overwriting-parent-properties:module1/src1").getName()).isEqualTo("module1/src1"); + assertThat(getComponent("overwriting-parent-properties:module2/src2").getName()).isEqualTo("module2/src2"); + } else { + // Verify that we have the modules + Component module1 = getComponent("overwriting-parent-properties:module1-new-key"); + assertThat(module1.getName()).isEqualTo("Module 1"); + assertThat(module1.getDescription()).isEqualTo("Description of module 1"); + + Component module2 = getComponent("overwriting-parent-properties:module2-new-key"); + assertThat(module2.getName()).isEqualTo("Module 2"); + assertThat(module2.getDescription()).isEqualTo("Description of module 2"); + } } /** @@ -145,10 +167,18 @@ public class MultimoduleTest extends ScannerTestCase { assertThat(getComponent("using-config-file-prop").getName()).isEqualTo("Advanced use case - mostly used by the Ant task"); - // Verify that we have the modules - assertThat(getComponent("using-config-file-prop:module1").getName()).isEqualTo("Module 1"); + if (noMoreModules()) { + assertThat(getComponent("using-config-file-prop:module1/src").getName()).isEqualTo("module1/src"); + assertThat(getComponent("using-config-file-prop:module2/src").getName()).isEqualTo("module2/src"); + } else { + // Verify that we have the modules + assertThat(getComponent("using-config-file-prop:module1").getName()).isEqualTo("Module 1"); + assertThat(getComponent("using-config-file-prop:module2").getName()).isEqualTo("Module 2"); + } + } - assertThat(getComponent("using-config-file-prop:module2").getName()).isEqualTo("Module 2"); + private boolean noMoreModules() { + return orchestrator.getServer().version().isGreaterThanOrEquals(7, 6); } /** diff --git a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java index 6569b1e..fa147ac 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java @@ -25,7 +25,7 @@ import java.io.File; import java.io.IOException; import java.util.Map; import java.util.stream.Collectors; -import org.fest.assertions.Condition; +import org.assertj.core.api.Condition; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -33,7 +33,7 @@ import org.junit.rules.TemporaryFolder; import org.sonarqube.ws.WsMeasures.Measure; import static java.lang.Integer.parseInt; -import static org.fest.assertions.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; public class ScannerTest extends ScannerTestCase { @@ -194,7 +194,7 @@ public class ScannerTest extends ScannerTestCase { BuildResult executeBuild = orchestrator.executeBuildQuietly(build); assertThat(executeBuild.getStatus()).isNotEqualTo(0); String logs = executeBuild.getLogs(); - assertThat(logs).satisfies(new Condition("Contain error message about OOM") { + assertThat(logs).is(new Condition("Contain error message about OOM") { @Override public boolean matches(String value) { return value.contains("java.lang.OutOfMemoryError") diff --git a/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java index 682b4a1..6e90303 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java +++ b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java @@ -20,6 +20,7 @@ package com.sonarsource.scanner.it; import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.locator.MavenLocation; import org.junit.ClassRule; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -31,8 +32,8 @@ public class SonarScannerTestSuite { @ClassRule public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv() - .setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE") - .addPlugin("javascript") + .setSonarVersion(System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE[6.7]")) + .addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", "LATEST_RELEASE")) .build(); } -- 2.39.5