From: Simon Brandhof Date: Sun, 7 Apr 2013 12:45:26 +0000 (+0200) Subject: Add test X-Git-Tag: 2.5-rc1~161 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3258f16877c32accda2a1a7aec1a2114068b3bab;p=sonar-scanner-cli.git Add test --- diff --git a/sonar-runner-batch/src/main/java/org/sonar/runner/batch/IsolatedLauncher.java b/sonar-runner-batch/src/main/java/org/sonar/runner/batch/IsolatedLauncher.java index c541b1e..eee9da7 100644 --- a/sonar-runner-batch/src/main/java/org/sonar/runner/batch/IsolatedLauncher.java +++ b/sonar-runner-batch/src/main/java/org/sonar/runner/batch/IsolatedLauncher.java @@ -41,6 +41,10 @@ import java.util.Properties; public class IsolatedLauncher { public void execute(Properties properties, List extensions) { + createBatch(properties, extensions).execute(); + } + + Batch createBatch(Properties properties, List extensions) { ProjectReactor projectReactor = null; String task = properties.getProperty("sonar.task", "scan"); if ("scan".equals(task)) { @@ -57,7 +61,7 @@ public class IsolatedLauncher { if (projectReactor != null) { builder.setProjectReactor(projectReactor); } - builder.build().execute(); + return builder.build(); } private void initLogging(Properties props) { diff --git a/sonar-runner-batch/src/test/java/org/sonar/runner/batch/IsolatedLauncherTest.java b/sonar-runner-batch/src/test/java/org/sonar/runner/batch/IsolatedLauncherTest.java index 31c6174..44a2e2d 100644 --- a/sonar-runner-batch/src/test/java/org/sonar/runner/batch/IsolatedLauncherTest.java +++ b/sonar-runner-batch/src/test/java/org/sonar/runner/batch/IsolatedLauncherTest.java @@ -20,7 +20,9 @@ package org.sonar.runner.batch; import org.junit.Test; +import org.sonar.batch.bootstrapper.Batch; +import java.util.Collections; import java.util.Properties; import static org.fest.assertions.Assertions.assertThat; @@ -30,6 +32,18 @@ public class IsolatedLauncherTest { Properties props = new Properties(); IsolatedLauncher launcher = new IsolatedLauncher(); + @Test + public void should_create_batch() { + props.setProperty("sonar.projectBaseDir", "src/test/java_sample"); + props.setProperty("sonar.projectKey", "sample"); + props.setProperty("sonar.projectName", "Sample"); + props.setProperty("sonar.projectVersion", "1.0"); + props.setProperty("sonar.sources", "src"); + Batch batch = launcher.createBatch(props, Collections.emptyList()); + + assertThat(batch).isNotNull(); + } + @Test public void testGetSqlLevel() throws Exception { assertThat(IsolatedLauncher.getSqlLevel(props)).isEqualTo("WARN"); diff --git a/sonar-runner-batch/src/test/java_sample/sonar-project.properties b/sonar-runner-batch/src/test/java_sample/sonar-project.properties new file mode 100644 index 0000000..0c35484 --- /dev/null +++ b/sonar-runner-batch/src/test/java_sample/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=sample +sonar.projectName=Sample +sonar.projectVersion=1.0-SNAPSHOT +sonar.projectDescription=Sample description +sonar.sources=src diff --git a/sonar-runner-batch/src/test/java_sample/src/Sample.java b/sonar-runner-batch/src/test/java_sample/src/Sample.java new file mode 100644 index 0000000..e69de29