You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/02/13 16:12:15 UTC
svn commit: r744141 -
/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
Author: ritchiem
Date: Fri Feb 13 15:12:14 2009
New Revision: 744141
URL: http://svn.apache.org/viewvc?rev=744141&view=rev
Log:
QPID-1662 : Converted Thread.sleep in to an awaitNanos()
Modified:
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java?rev=744141&r1=744140&r2=744141&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java Fri Feb 13 15:12:14 2009
@@ -36,6 +36,8 @@
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.test.utils.QpidTestCase;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Condition;
public class TimeToLiveTest extends QpidTestCase
{
@@ -88,13 +90,29 @@
producer.send(nextMessage(String.valueOf(msg), false, producerSession, producer));
consumer = clientSession.createConsumer(queue);
- try
- {
- // Sleep to ensure TTL reached
- Thread.sleep(TIME_TO_LIVE);
- }
- catch (InterruptedException e)
+
+ // Ensure we sleep the required amount of time.
+ ReentrantLock waitLock = new ReentrantLock();
+ Condition wait = waitLock.newCondition();
+ final long MILLIS = 1000000L;
+ long waitTime = TIME_TO_LIVE * MILLIS;
+ while (waitTime > 0)
{
+ try
+ {
+ waitLock.lock();
+
+ waitTime = wait.awaitNanos(waitTime);
+ }
+ catch (InterruptedException e)
+ {
+ //Stop if we are interrupted
+ fail(e.getMessage());
+ }
+ finally
+ {
+ waitLock.unlock();
+ }
}
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org