]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Add test
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 7 Apr 2013 12:45:26 +0000 (14:45 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 7 Apr 2013 12:45:26 +0000 (14:45 +0200)
sonar-runner-batch/src/main/java/org/sonar/runner/batch/IsolatedLauncher.java
sonar-runner-batch/src/test/java/org/sonar/runner/batch/IsolatedLauncherTest.java
sonar-runner-batch/src/test/java_sample/sonar-project.properties [new file with mode: 0644]
sonar-runner-batch/src/test/java_sample/src/Sample.java [new file with mode: 0644]

index c541b1ec55796afa16edfa5b95829453c3be0428..eee9da7673c55dac435bf587365564920b0f5d20 100644 (file)
@@ -41,6 +41,10 @@ import java.util.Properties;
 public class IsolatedLauncher {
 
   public void execute(Properties properties, List<Object> extensions) {
+    createBatch(properties, extensions).execute();
+  }
+
+  Batch createBatch(Properties properties, List<Object> 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) {
index 31c61745de3697cd4967d72861ac225b54309c3d..44a2e2dc1cb01894f5f469b56526940ad347fb74 100644 (file)
@@ -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 (file)
index 0000000..0c35484
--- /dev/null
@@ -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 (file)
index 0000000..e69de29