From bc49ddf6f68e7b80dabad80c77e9db4bcb548f83 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 3 Aug 2016 15:25:02 +0200 Subject: Improve tests --- it/src/test/java/com/sonar/runner/it/JavaTest.java | 4 +--- src/test/java/org/sonarsource/scanner/cli/ConfTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 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 c93e3cc..c9d3210 100644 --- a/it/src/test/java/com/sonar/runner/it/JavaTest.java +++ b/it/src/test/java/com/sonar/runner/it/JavaTest.java @@ -220,9 +220,7 @@ public class JavaTest extends ScannerTestCase { "\"sonar.projectDescription\" : \"This is a Java sample\"," + "\"sonar.projectVersion\" : \"1.2.3\"," + "\"sonar.sources\" : \"src\" }"); - String logs = orchestrator.executeBuild(build).getLogs(); - System.out.println(logs); - + orchestrator.executeBuild(build); } @Test diff --git a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java index 506e01d..66e61e8 100644 --- a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java @@ -37,6 +37,7 @@ import org.apache.commons.lang.SystemUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; public class ConfTest { @@ -44,6 +45,9 @@ public class ConfTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); + @Rule + public ExpectedException exception = ExpectedException.none(); + Map env = new HashMap<>(); Properties args = new Properties(); Logs logs = new Logs(System.out, System.err); @@ -131,6 +135,14 @@ public class ConfTest { assertThat(props.getProperty("sonar.key2")).isEqualTo("v3"); } + @Test + public void shouldFailWithInvalidEnvironmentProperties() throws IOException { + env.put("SONARQUBE_SCANNER_PARAMS", "{sonar.key1: \"v1\", \"sonar.key2\" : \"v2\"}"); + exception.expect(IllegalStateException.class); + exception.expectMessage("JSON"); + conf.properties(); + } + @Test public void shouldSupportDeepModuleConfigurationInRoot() throws Exception { Path projectHome = Paths.get(getClass().getResource("ConfTest/shouldSupportDeepModuleConfigurationInRoot/project").toURI()); -- cgit v1.2.3