use of org.sonar.application.process.ProcessMonitor in project sonarqube by SonarSource.
the class JavaProcessLauncherImplTest method launch_forks_a_new_process.
@Test
public void launch_forks_a_new_process() throws Exception {
File tempDir = temp.newFolder();
TestProcessBuilder processBuilder = new TestProcessBuilder();
JavaProcessLauncher underTest = new JavaProcessLauncherImpl(tempDir, commands, () -> processBuilder);
JavaCommand command = new JavaCommand(ProcessId.ELASTICSEARCH);
command.addClasspath("lib/*.class");
command.addClasspath("lib/*.jar");
command.setArgument("foo", "bar");
command.setClassName("org.sonarqube.Main");
command.setEnvVariable("VAR1", "valueOfVar1");
command.setWorkDir(temp.newFolder());
ProcessMonitor monitor = underTest.launch(command);
assertThat(monitor).isNotNull();
assertThat(processBuilder.started).isTrue();
assertThat(processBuilder.commands.get(0)).endsWith("java");
assertThat(processBuilder.commands).containsSequence("-Djava.io.tmpdir=" + tempDir.getAbsolutePath(), "-cp", "lib/*.class" + System.getProperty("path.separator") + "lib/*.jar", "org.sonarqube.Main");
assertThat(processBuilder.dir).isEqualTo(command.getWorkDir());
assertThat(processBuilder.redirectErrorStream).isTrue();
assertThat(processBuilder.environment).contains(entry("VAR1", "valueOfVar1")).containsAllEntriesOf(command.getEnvVariables());
}
Aggregations