From 6f3c99991dbbace5b2a350478929256e51881d9c Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Wed, 29 Jul 2009 10:26:19 +0000 Subject: [PATCH] resolve https://issues.apache.org/activemq/browse/AMQ-2075 - async dispatch of brokerInfo could end up getting dispatched after messages git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@798842 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/broker/BrokerTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTest.java index 918961c798..8edd7d347c 100755 --- a/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTest.java @@ -1127,15 +1127,16 @@ public class BrokerTest extends BrokerTestSupport { } // give the async ack a chance to perculate and validate all are currently consumed - assertNull(connection1.getDispatchQueue().poll(MAX_NULL_WAIT, TimeUnit.MILLISECONDS)); - + Message msg = receiveMessage(connection1, MAX_NULL_WAIT); + assertNull("all messages were received " + msg, msg); + // Close the connection, this should in turn close the consumer. connection1.request(closeConnectionInfo(connectionInfo1)); // Send another message, connection1 should not get the message. connection2.request(createMessage(producerInfo2, destination, deliveryMode)); - assertNull(connection1.getDispatchQueue().poll(MAX_NULL_WAIT, TimeUnit.MILLISECONDS)); + assertNull("no message received", receiveMessage(connection1, MAX_NULL_WAIT)); } public void initCombosForTestSessionCloseCascades() { @@ -1187,7 +1188,7 @@ public class BrokerTest extends BrokerTestSupport { // Send another message, connection1 should not get the message. connection2.request(createMessage(producerInfo2, destination, deliveryMode)); - Object msg = connection1.getDispatchQueue().poll(MAX_NULL_WAIT, TimeUnit.MILLISECONDS); + Message msg = receiveMessage(connection1,MAX_NULL_WAIT); assertNull("no message received from connection1 after session close", msg); } @@ -1235,7 +1236,8 @@ public class BrokerTest extends BrokerTestSupport { } // give the async ack a chance to perculate and validate all are currently consumed - Object result = connection1.getDispatchQueue().poll(MAX_NULL_WAIT, TimeUnit.MILLISECONDS); + // use receive rather than poll as broker info is sent async and may still need to be dequeued + Message result = receiveMessage(connection1, MAX_NULL_WAIT); assertNull("no more messages " + result, result); // Close the consumer. @@ -1244,7 +1246,8 @@ public class BrokerTest extends BrokerTestSupport { // Send another message, connection1 should not get the message. connection2.request(createMessage(producerInfo2, destination, deliveryMode)); - assertNull(connection1.getDispatchQueue().poll(MAX_NULL_WAIT, TimeUnit.MILLISECONDS)); + result = receiveMessage(connection1, MAX_NULL_WAIT); + assertNull("no message received after close " + result, result); } public void initCombosForTestTopicNoLocal() {