From fcdefb9e0944be78742d18fd3e02a81f882db864 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 11 Nov 2016 12:22:53 +0100 Subject: [PATCH] Improve stability of ProcessUtilsTest on slow box --- .../test/java/org/sonar/process/ProcessUtilsTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java index 01fb917d80c..1db07dd3213 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java @@ -19,7 +19,9 @@ */ package org.sonar.process; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.Timeout; import org.sonar.test.TestUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -27,6 +29,9 @@ import static org.sonar.process.ProcessUtils.awaitTermination; public class ProcessUtilsTest { + @Rule + public Timeout timeout= Timeout.seconds(5); + @Test public void private_constructor() { assertThat(TestUtils.hasOnlyPrivateConstructors(ProcessUtils.class)).isTrue(); @@ -37,12 +42,12 @@ public class ProcessUtilsTest { awaitTermination((Thread) null); } - @Test(timeout = 250L) + @Test public void awaitTermination_does_not_wait_on_currentThread() { awaitTermination(Thread.currentThread()); } - @Test(timeout = 3_000L) + @Test public void awaitTermination_ignores_interrupted_exception_of_current_thread() throws InterruptedException { final EverRunningThread runningThread = new EverRunningThread(); final Thread safeJoiner = new Thread() { @@ -89,7 +94,7 @@ public class ProcessUtilsTest { safeJoiner.join(); } - @Test(timeout = 1_000L) + @Test public void awaitTermination_of_vararg_does_not_fail_when_there_is_a_null_or_current_thread() { awaitTermination(null, Thread.currentThread(), null); } -- 2.39.5