Author: kwall
Date: Sat May 26 07:45:56 2012
New Revision: 1342861

URL: http://svn.apache.org/viewvc?rev=1342861&view=rev
Log:
QPID-3936: Java Performance Test Framework.

Fix test highlighed by JDK1.7 build on Apache CI - test approach incompatible 
with the Junit lifecycle.

Modified:
    
qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java

Modified: 
qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java?rev=1342861&r1=1342860&r2=1342861&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
 Sat May 26 07:45:56 2012
@@ -34,15 +34,25 @@ public class ExecutorWithTimeLimitTest e
     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<Object> _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 e
     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();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to