diff options
author | Aidan Skinner <aidan@apache.org> | 2009-09-18 12:55:10 +0000 |
---|---|---|
committer | Aidan Skinner <aidan@apache.org> | 2009-09-18 12:55:10 +0000 |
commit | 555d38fcb330e544a01a2c0a2d9e0d94d4560b2d (patch) | |
tree | e1e6f3ad7ea904365be85fb6b1172ca364db27d7 /qpid | |
parent | 2296769193754d1bc09e1dc3b998709a5808ecbb (diff) | |
download | qpid-python-555d38fcb330e544a01a2c0a2d9e0d94d4560b2d.tar.gz |
MINANetworkDriverTest: Make sure we sleep for at least the alloted time.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-network-refactor@816613 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r-- | qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java index 5500ff9d4b..5af07d9735 100644 --- a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java +++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java @@ -186,14 +186,7 @@ public class MINANetworkDriverTest extends TestCase _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 @@ public class MINANetworkDriverTest extends TestCase _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 @@ public class MINANetworkDriverTest extends TestCase _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 |