qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r683955 - /incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
Date Fri, 08 Aug 2008 12:51:31 GMT
Author: ritchiem
Date: Fri Aug  8 05:51:31 2008
New Revision: 683955

URL: http://svn.apache.org/viewvc?rev=683955&view=rev
Log:
QPID-1226 : DupsOk test never creates the client so create one for the messages. Also improved
the testing to ensure we check for failure scenarions.

Modified:
    incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java

Modified: incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java?rev=683955&r1=683954&r2=683955&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
(original)
+++ incubator/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
Fri Aug  8 05:51:31 2008
@@ -52,6 +52,10 @@
         _queue = (Queue)  getInitialContext().lookup("queue");
 
 
+        //Declare the queue
+        Connection consumerConnection = getConnection();
+        consumerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE).createConsumer(_queue).close();
+
         //Create Producer put some messages on the queue
         Connection producerConnection = getConnection();
 
@@ -83,12 +87,14 @@
         //Create Client
         Connection clientConnection = getConnection();
 
-        clientConnection.start();
-
         final Session clientSession = clientConnection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
 
         MessageConsumer consumer = clientSession.createConsumer(_queue);
 
+        assertEquals("The queue should have msgs at start", MSG_COUNT, ((AMQSession) clientSession).getQueueDepth((AMQDestination)
_queue));
+
+        clientConnection.start();        
+
         consumer.setMessageListener(new MessageListener()
         {
             int _msgCount = 0;
@@ -146,11 +152,13 @@
             throw e;
         }
 
-
-        // wait for the ack to get back
-        Thread.sleep(1000);
+        //Close consumer to give broker time to process in bound Acks. As The main thread
will be released while
+        // before the dispatcher has sent the ack back to the broker.
+        consumer.close();
 
         assertEquals("The queue should have 0 msgs left", 0, ((AMQSession) clientSession).getQueueDepth((AMQDestination)
_queue));
+
+        clientConnection.close();
     }
 
 }



Mime
View raw message