From da861bd6fd00bef0b96cc4be42c800099bcd3b4c Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Tue, 10 Dec 2024 11:47:32 -0500 Subject: [PATCH] ARTEMIS-5173 Using Wait.assertEquals --- .../artemis/tests/integration/routing/RedirectTest.java | 7 ++++--- .../activemq/artemis/tests/integration/server/LVQTest.java | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/RedirectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/RedirectTest.java index bb033bb72b..f35c58a9c2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/RedirectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/RedirectTest.java @@ -45,6 +45,7 @@ import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedT import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters; import org.apache.activemq.artemis.core.server.routing.KeyType; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; +import org.apache.activemq.artemis.tests.util.Wait; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @@ -394,9 +395,9 @@ public class RedirectTest extends RoutingTestBase { startServers(failedNode); - assertEquals(0, queueControl0.countMessages(), "Unexpected message count for node 0"); - assertEquals(1, queueControl1.countMessages(), "Unexpected message count for node 1"); - assertEquals(1, queueControl2.countMessages(), "Unexpected message count for node 2"); + Wait.assertEquals(0L, () -> queueControl0.countMessages(), 5000, 100); + Wait.assertEquals(1L, () -> queueControl1.countMessages(), 5000, 100); + Wait.assertEquals(1L, () -> queueControl2.countMessages(), 5000, 100); try (Connection connection = connectionFactory.createConnection()) { connection.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java index df32006152..27c3ac7a1f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java @@ -36,6 +36,7 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.api.core.management.SimpleManagement; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.MessageReference; @@ -170,6 +171,9 @@ public class LVQTest extends ActiveMQTestBase { producer.send(m2); producer.send(m3); producer.send(m4); + SimpleManagement simpleManagement = new SimpleManagement("tcp://localhost:61616", null, null); + Wait.assertEquals(2L, () -> simpleManagement.getMessageCountOnQueue(qName1.toString()), 5000, 100); + Wait.assertEquals(4L, () -> simpleManagement.getMessagesAddedOnQueue(qName1.toString()), 5000, 100); clientSession.start(); ClientMessage m = consumer.receive(1000); assertNotNull(m); @@ -179,6 +183,7 @@ public class LVQTest extends ActiveMQTestBase { assertNotNull(m); m.acknowledge(); assertEquals(m.getBodyBuffer().readString(), "m4"); + assertNull(consumer.receiveImmediate()); } @Test