diff options
-rw-r--r-- | it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java | 19 | ||||
-rw-r--r-- | pom.xml | 4 |
2 files changed, 19 insertions, 4 deletions
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 f748d21..d444a98 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java @@ -20,6 +20,7 @@ package com.sonarsource.scanner.it; import com.sonar.orchestrator.build.BuildResult; +import com.sonar.orchestrator.build.BuildRunner; import com.sonar.orchestrator.build.SonarScanner; import java.io.File; import java.io.IOException; @@ -140,7 +141,7 @@ public class ScannerTest extends ScannerTestCase { } @Test - public void should_use_environment_props() { + public void should_use_json_environment_props() { SonarScanner build = newScanner(new File("projects/simple-sample-no-properties")) .setEnvironmentVariable("SONARQUBE_SCANNER_PARAMS", "{" + "\"sonar.projectKey\" : \"sample\"," + @@ -152,6 +153,18 @@ public class ScannerTest extends ScannerTestCase { } @Test + public void should_use_environment_prop() { + SonarScanner build = newScanner(new File("projects/simple-sample")) + .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org"); + + BuildRunner runner = new BuildRunner(orchestrator.getConfiguration()); + BuildResult buildResult = runner.runQuietly(null, build); + + assertThat(buildResult.isSuccess()).isFalse(); + assertThat(buildResult.getLogs()).contains("SonarQube server [http://from-env.org] can not be reached"); + } + + @Test public void should_skip_analysis() { SonarScanner build = newScanner(new File("projects/simple-sample")) .setProperty("sonar.host.url", "http://foo") @@ -164,11 +177,13 @@ public class ScannerTest extends ScannerTestCase { @Test public void should_fail_if_unable_to_connect() { SonarScanner build = newScanner(new File("projects/simple-sample")) + //env property should be overridden + .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org") .setProperty("sonar.host.url", "http://foo"); BuildResult result = orchestrator.executeBuildQuietly(build); // expect build failure - assertThat(result.getStatus()).isNotEqualTo(0); + assertThat(result.isSuccess()).isFalse(); // with the following message assertThat(result.getLogs()).contains("SonarQube server [http://foo] can not be reached"); } @@ -60,7 +60,7 @@ <dependency> <groupId>org.sonarsource.scanner.api</groupId> <artifactId>sonar-scanner-api</artifactId> - <version>2.13.0.1871</version> + <version>2.14.0.2002</version> </dependency> <dependency> <groupId>com.google.code.findbugs</groupId> @@ -189,7 +189,7 @@ <configuration> <source>8</source> </configuration> - </plugin> + </plugin> </plugins> </build> |