From b1cf5c385c916946ea044f0325b74b3907c262ed Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Wed, 25 Apr 2018 05:36:37 +0200 Subject: [Releng] Provide AbstractOMTest.await(CountDownLatch) helper --- .../org/eclipse/net4j/util/tests/AbstractOMTest.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'plugins/org.eclipse.net4j.tests/src/org') diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java index aea3b9e3e1..52c7d0e029 100644 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java @@ -13,7 +13,9 @@ package org.eclipse.net4j.util.tests; import org.eclipse.net4j.internal.util.test.TestExecuter; import org.eclipse.net4j.tests.bundle.OM; import org.eclipse.net4j.util.ReflectUtil; +import org.eclipse.net4j.util.WrappedException; import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; +import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException; import org.eclipse.net4j.util.concurrent.TrackableTimerTask; import org.eclipse.net4j.util.event.EventUtil; import org.eclipse.net4j.util.event.IEvent; @@ -857,11 +859,23 @@ public abstract class AbstractOMTest extends TestCase }); } - public static final void await(CountDownLatch latch) throws InterruptedException, TimeoutException + public static void await(CountDownLatch latch) throws TimeoutRuntimeException { - if (!latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)) + await(latch, DEFAULT_TIMEOUT); + } + + public static void await(CountDownLatch latch, long millis) throws TimeoutRuntimeException + { + try + { + if (!latch.await(millis, TimeUnit.MILLISECONDS)) + { + throw new TimeoutRuntimeException("Latch timed out: " + latch); + } + } + catch (InterruptedException ex) { - throw new TimeoutException("Latch timed out: " + latch); + throw WrappedException.wrap(ex); } } -- cgit v1.2.3