From: Julien HENRY Date: Wed, 27 May 2015 12:01:42 +0000 (+0200) Subject: Add test for CommandExecutor timeout with new shell X-Git-Tag: 5.2-RC1~1818 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a5f662a00b63be2d8802295a50116868a3170a45;p=sonarqube.git Add test for CommandExecutor timeout with new shell --- diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java index f9b071cc929..04e2f78be98 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.api.utils.command; +import java.io.File; +import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.SystemUtils; import org.junit.Before; @@ -29,9 +31,6 @@ import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; import org.sonar.api.utils.System2; -import java.io.File; -import java.io.IOException; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; @@ -126,7 +125,7 @@ public class CommandExecutorTest { assertThat(log).contains("Environment variable: 2"); } - @Test + @Test(timeout = 3000L) public void should_stop_after_timeout() throws IOException { try { String executable = getScript("forever"); @@ -137,6 +136,17 @@ public class CommandExecutorTest { } } + @Test(timeout = 3000L) + public void should_stop_after_timeout_and_new_shell() throws IOException { + try { + String executable = getScript("forever"); + CommandExecutor.create().execute(Command.create(executable).setNewShell(true).setDirectory(workDir), 300L); + fail(); + } catch (TimeoutException e) { + // ok + } + } + @Test public void should_fail_if_script_not_found() { thrown.expect(CommandException.class);