ARTEMIS-5173 Using Wait.assertEquals

This commit is contained in:
Clebert Suconic 2024-12-10 11:47:32 -05:00 committed by clebertsuconic
parent 393167fff5
commit da861bd6fd
2 changed files with 9 additions and 3 deletions

View File

@ -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();

View File

@ -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