From e857c1b9538f91b435ad180be974887e87569b5e Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 15 Apr 2020 14:34:25 -0400 Subject: [PATCH] NO-JIRA Fixing test race on Wait (ProducerAutoCreateQueue) --- .../amq/ProducerAutoCreateQueueTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerAutoCreateQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerAutoCreateQueueTest.java index e67fd65739..5697ce5b7d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerAutoCreateQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerAutoCreateQueueTest.java @@ -20,6 +20,7 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.artemis.tests.util.Wait; import org.junit.Assert; import org.junit.Test; @@ -72,8 +73,8 @@ public class ProducerAutoCreateQueueTest extends BasicOpenWireTest { } } - assertNotNull(server.getAddressInfo(new SimpleString("trash"))); - assertEquals(0, server.getTotalMessageCount()); + Wait.assertTrue(() -> server.getAddressInfo(new SimpleString("trash")) != null); + Wait.assertEquals(0, server::getTotalMessageCount); } @Test @@ -91,9 +92,9 @@ public class ProducerAutoCreateQueueTest extends BasicOpenWireTest { } } - assertNotNull(server.getAddressInfo(new SimpleString("trash"))); - assertNotNull(server.locateQueue(new SimpleString("trash"))); - assertEquals(1, server.getTotalMessageCount()); + Wait.assertTrue(() -> server.getAddressInfo(new SimpleString("trash")) != null); + Wait.assertTrue(() -> server.locateQueue(new SimpleString("trash")) != null); + Wait.assertEquals(1, server::getTotalMessageCount); } @Test @@ -115,7 +116,8 @@ public class ProducerAutoCreateQueueTest extends BasicOpenWireTest { } } - assertNull(server.locateQueue(new SimpleString("trash"))); + SimpleString queueName = SimpleString.toSimpleString("trash"); + Wait.assertTrue(() -> server.locateQueue(queueName) == null); } @Test @@ -138,7 +140,7 @@ public class ProducerAutoCreateQueueTest extends BasicOpenWireTest { } } - assertNotNull(server.locateQueue(new SimpleString("trash"))); - assertNotNull(server.getAddressInfo(new SimpleString("trash"))); + Wait.assertTrue(() -> server.locateQueue(new SimpleString("trash")) != null); + Wait.assertTrue(() -> server.getAddressInfo(new SimpleString("trash")) != null); } }