aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-05-27 14:01:42 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-05-27 14:02:06 +0200
commita5f662a00b63be2d8802295a50116868a3170a45 (patch)
treedbb7f721a80c133ca4d8b25a13e03d6bb366eb79 /sonar-plugin-api/src/test
parentbfb11703b6d598687621f3f88bedf2997f30678d (diff)
downloadsonarqube-a5f662a00b63be2d8802295a50116868a3170a45.tar.gz
sonarqube-a5f662a00b63be2d8802295a50116868a3170a45.zip
Add test for CommandExecutor timeout with new shell
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java18
1 files changed, 14 insertions, 4 deletions
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);