ARTEMIS-634 JMSQueueControlUsingJMSTest fails

We have to wait some time until Artemis delivers all messages.
This commit is contained in:
Erich Duda 2016-07-15 12:44:09 +02:00 committed by jbertram
parent baee468de2
commit 4d16c0721a
1 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
import org.apache.activemq.artemis.api.jms.management.DestinationControl;
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
import org.apache.activemq.artemis.core.config.Configuration;
@ -1451,6 +1452,8 @@ public class JMSQueueControlTest extends ManagementTestBase {
JMSQueueControl control = createManagementControl(pagedQueue);
Assert.assertTrue(waitForMessages(control, 100, 5000));
assertEquals(100, control.removeMessages(" "));
session.start();
@ -1667,6 +1670,18 @@ public class JMSQueueControlTest extends ManagementTestBase {
return ManagementControlHelper.createJMSQueueControl(queueParameter, mbeanServer);
}
protected boolean waitForMessages(DestinationControl control, int count, long timeout) throws Exception {
long timeToWait = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < timeToWait) {
if (control.getMessageCount() == count) {
return true;
}
Thread.sleep(100);
}
return false;
}
// Private -------------------------------------------------------
private Connection createConnection() throws JMSException {