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)) {
if (projectReactor != null) {
builder.setProjectReactor(projectReactor);
}
- builder.build().execute();
+ return builder.build();
}
private void initLogging(Properties props) {
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;
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");