You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2009/09/18 14:55:10 UTC

svn commit: r816613 - /qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java

Author: aidan
Date: Fri Sep 18 12:55:10 2009
New Revision: 816613

URL: http://svn.apache.org/viewvc?rev=816613&view=rev
Log:
MINANetworkDriverTest: Make sure we sleep for at least the alloted time.

Modified:
    qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java

Modified: qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java?rev=816613&r1=816612&r2=816613&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java (original)
+++ qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java Fri Sep 18 12:55:10 2009
@@ -186,14 +186,7 @@
         _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null);
         assertFalse("Reader should not have been idle", _countingEngine.getReaderHasBeenIdle());
         _client.setMaxReadIdle(1);
-        try
-        {
-            Thread.sleep(1000);
-        }
-        catch (InterruptedException e)
-        {
-            // Eat it
-        }
+        sleepForAtLeast(1500);
         assertTrue("Reader should have been idle", _countingEngine.getReaderHasBeenIdle());
     } 
     
@@ -211,14 +204,7 @@
         _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null);
         assertFalse("Reader should not have been idle", _countingEngine.getWriterHasBeenIdle());
         _client.setMaxWriteIdle(1);
-        try
-        {
-            Thread.sleep(1000);
-        }
-        catch (InterruptedException e)
-        {
-            // Eat it
-        }
+        sleepForAtLeast(1500);
         assertTrue("Reader should have been idle", _countingEngine.getWriterHasBeenIdle());
     } 
     
@@ -484,4 +470,22 @@
             _driver.send(msg);
         }
     }
+    
+    public static void sleepForAtLeast(long period)
+    {
+        long start = System.currentTimeMillis();
+        long timeLeft = period;
+        while (timeLeft > 0)
+        {
+            try
+            {
+                Thread.sleep(timeLeft);
+            }
+            catch (InterruptedException e)
+            {
+                // Ignore it
+            }
+            timeLeft = period - (System.currentTimeMillis() - start);
+        }
+    }
 }
\ No newline at end of file



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org