Improving a test that failed due to what seemed a race

This commit is contained in:
Clebert Suconic 2015-03-16 19:17:52 -04:00
parent 519a47f023
commit 2f819a63e7
1 changed files with 7 additions and 2 deletions

View File

@ -625,8 +625,13 @@ public class QueueImplTest extends UnitTestCase
queue.resume(); queue.resume();
// Need to make sure the consumers will receive the messages before we do these assertions // Need to make sure the consumers will receive the messages before we do these assertions
long timeout = System.currentTimeMillis() + 1000; long timeout = System.currentTimeMillis() + 5000;
while (cons1.getReferences().size() != numMessages / 2 && cons2.getReferences().size() != numMessages / 2 && timeout > System.currentTimeMillis()) while (cons1.getReferences().size() != numMessages / 2 && timeout > System.currentTimeMillis())
{
Thread.sleep(1);
}
while (cons2.getReferences().size() != numMessages / 2 && timeout > System.currentTimeMillis())
{ {
Thread.sleep(1); Thread.sleep(1);
} }