qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r816613 - /qpid/branches/java-network-refactor/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java
Date Fri, 18 Sep 2009 12:55:10 GMT
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


Mime
View raw message