diff options
Diffstat (limited to 'qpid/java/common/src/test/java/org/apache/qpid/transport')
-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 |