diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-08-03 13:53:23 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-08-03 13:53:23 +0200 |
commit | d1537d139b0034ac151969f221c98b2e57701e95 (patch) | |
tree | 72a1f611edc6cb9b40f1d237edc9820ae11479e0 /src/test | |
parent | cc72c54ef3fd4b63751e65862fad250795accc04 (diff) | |
download | sonar-scanner-cli-d1537d139b0034ac151969f221c98b2e57701e95.tar.gz sonar-scanner-cli-d1537d139b0034ac151969f221c98b2e57701e95.zip |
SQSCANNER-26 Support SONARQUBE_SCANNER_PARAMS and sonar.scanner.skip
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/ConfTest.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java index 3450e88..506e01d 100644 --- a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java @@ -19,35 +19,40 @@ */ package org.sonarsource.scanner.cli; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; + import org.apache.commons.lang.SystemUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class ConfTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); + Map<String, String> env = new HashMap<>(); Properties args = new Properties(); Logs logs = new Logs(System.out, System.err); Cli cli = mock(Cli.class); - Conf conf = new Conf(cli, logs); + Conf conf = new Conf(cli, logs, env); @Before public void initConf() { + env.clear(); when(cli.properties()).thenReturn(args); } @@ -116,6 +121,17 @@ public class ConfTest { } @Test + public void shouldLoadEnvironmentProperties() throws IOException { + env.put("SONARQUBE_SCANNER_PARAMS", "{\"sonar.key1\" : \"v1\", \"sonar.key2\" : \"v2\"}"); + args.put("sonar.key2", "v3"); + + Properties props = conf.properties(); + + assertThat(props.getProperty("sonar.key1")).isEqualTo("v1"); + assertThat(props.getProperty("sonar.key2")).isEqualTo("v3"); + } + + @Test public void shouldSupportDeepModuleConfigurationInRoot() throws Exception { Path projectHome = Paths.get(getClass().getResource("ConfTest/shouldSupportDeepModuleConfigurationInRoot/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); |