From 4d16c0721a9df58908f0daa7d27735c60d8bee77 Mon Sep 17 00:00:00 2001 From: Erich Duda Date: Fri, 15 Jul 2016 12:44:09 +0200 Subject: [PATCH] ARTEMIS-634 JMSQueueControlUsingJMSTest fails We have to wait some time until Artemis delivers all messages. --- .../server/management/JMSQueueControlTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java index 6acd9ae35d..90aa8f98a9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java @@ -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 {