From c9c9bb94e42523b29e8bd3cc7e07aee59fcb96d4 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Sat, 26 May 2012 07:45:56 +0000 Subject: QPID-3936: Java Performance Test Framework. Fix test highlighed by JDK1.7 build on Apache CI - test approach incompatible with the Junit lifecycle. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1342861 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/utils/ExecutorWithTimeLimitTest.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'qpid/java/perftests/src/test') diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java index 7a85de99ee..a201a7bacf 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java +++ b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java @@ -34,15 +34,25 @@ public class ExecutorWithTimeLimitTest extends TestCase private static final int TIMEOUT = 500; private static final Object RESULT = new Object(); - private ExecutorWithLimits _limiter = new ExecutorWithTimeLimit(System.currentTimeMillis(), TIMEOUT); + private ExecutorWithLimits _limiter; @SuppressWarnings("unchecked") private Callable _callback = mock(Callable.class); + @Override + protected void setUp() throws Exception + { + super.setUp(); + _limiter = new ExecutorWithTimeLimit(System.currentTimeMillis(), TIMEOUT); + } + @Override protected void tearDown() throws Exception { super.tearDown(); - _limiter.shutdown(); + if (_limiter != null) + { + _limiter.shutdown(); + } } public void testCallableCompletesNormally() throws Exception @@ -78,17 +88,20 @@ public class ExecutorWithTimeLimitTest extends TestCase public void testCallableNotRunDueToInsufficentTimeRemaining() throws Exception { long now = System.currentTimeMillis(); - _limiter = new ExecutorWithTimeLimit(now - 100, 100); - + ExecutorWithLimits shortTimeLimiter = new ExecutorWithTimeLimit(now - 100, 100); try { - _limiter.execute(_callback); + shortTimeLimiter.execute(_callback); fail("Exception not thrown"); } catch (CancellationException ca) { // PASS } + finally + { + shortTimeLimiter.shutdown(); + } verify(_callback, never()).call(); } -- cgit v1.2.1