From 92114fc688d69d283ca955b7de8f6265af0b7c2b Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Tue, 23 Oct 2007 16:47:22 +0000 Subject: cahnged for setting the consumer before the producer git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@587552 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/unit/client/connection/ConnectionStartTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'java/client/src') diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java index e115821755..e2d3832cc9 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java @@ -60,14 +60,15 @@ public class ConnectionStartTest extends QpidTestCase MessageProducer pub = pubSess.createProducer(queue); - pub.send(pubSess.createTextMessage("Initial Message")); - _connection = (AMQConnection) getConnection("guest", "guest"); _consumerSess = _connection.createSession(false, AMQSession.AUTO_ACKNOWLEDGE); _consumer = _consumerSess.createConsumer(queue); + //publish after queue is created to ensure it can be routed as expected + pub.send(pubSess.createTextMessage("Initial Message")); + pubCon.close(); } @@ -82,7 +83,7 @@ public class ConnectionStartTest extends QpidTestCase { _connection.close(); } - + public void testSimpleReceiveConnection() { try @@ -90,9 +91,9 @@ public class ConnectionStartTest extends QpidTestCase assertTrue("Connection should not be started", !_connection.started()); //Note that this next line will start the dispatcher in the session // should really not be called before _connection start - assertTrue("There should not be messages waiting for the consumer", _consumer.receiveNoWait() == null); + //assertTrue("There should not be messages waiting for the consumer", _consumer.receiveNoWait() == null); _connection.start(); - assertTrue("There should be messages waiting for the consumer", _consumer.receive(10*1000) == null); + assertTrue("There should be messages waiting for the consumer", _consumer.receive(10*1000) != null); assertTrue("Connection should be started", _connection.started()); } @@ -110,7 +111,7 @@ public class ConnectionStartTest extends QpidTestCase try { assertTrue("Connection should not be started", !_connection.started()); - _consumerSess.setMessageListener(new MessageListener() + _consumer.setMessageListener(new MessageListener() { public void onMessage(Message message) { @@ -133,7 +134,7 @@ public class ConnectionStartTest extends QpidTestCase try { - _gotMessage.await(1000, TimeUnit.MILLISECONDS); + assertTrue("Listener was never called", _gotMessage.await(10 * 1000, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { -- cgit v1.2.1