Improving test.

There's a race here that only happens on Virtual Machines (VMWare.. etc)
This commit is contained in:
Clebert Suconic 2015-09-10 17:50:07 -04:00
parent d3ea9aca50
commit d5a01287a5
1 changed files with 6 additions and 1 deletions

View File

@ -131,6 +131,7 @@ public class ProtonTest extends ActiveMQTestBase {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
try { try {
Thread.sleep(250);
if (connection != null) { if (connection != null) {
connection.close(); connection.close();
} }
@ -257,6 +258,10 @@ public class ProtonTest extends ActiveMQTestBase {
cons.close(); cons.close();
for (int i = 0; i < 100 && serverQueue.getConsumerCount() != 0; i++) {
Thread.sleep(500);
}
assertEquals(0, serverQueue.getConsumerCount()); assertEquals(0, serverQueue.getConsumerCount());
session.close(); session.close();
@ -330,7 +335,7 @@ public class ProtonTest extends ActiveMQTestBase {
connection = createConnection(); connection = createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue); MessageConsumer consumer = session.createConsumer(queue);
Thread.sleep(1000); Thread.sleep(100);
consumer.close(); consumer.close();
connection.close(); connection.close();
Assert.assertEquals(numMessages, getMessageCount(q)); Assert.assertEquals(numMessages, getMessageCount(q));