[jboss-cvs] JBoss Messaging SVN: r2549 - trunk/tests/src/org/jboss/test/messaging/jms.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 15 18:34:09 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-03-15 18:34:09 -0400 (Thu, 15 Mar 2007)
New Revision: 2549

Modified:
   trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
Log:
Placing this loop back, as requested by Tim

Modified: trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2007-03-15 22:04:39 UTC (rev 2548)
+++ trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2007-03-15 22:34:09 UTC (rev 2549)
@@ -124,69 +124,75 @@
    // added for http://jira.jboss.org/jira/browse/JBMESSAGING-899
    public void testClosedConsumerAfterStart() throws Exception
    {
-      Queue queue = (Queue)ic.lookup("/queue/TestQueue");
+      Queue queue = (Queue) ic.lookup("/queue/TestQueue");
 
-      Connection conn1 = cf.createConnection();
+      // This loop is to increase chances of a failure.
+      for (int counter = 0; counter < 20; counter++)
+      {
+         log.info("Iteration = " + counter);
 
-      assertEquals(0, ((JBossConnection)conn1).getServerID());
+         Connection conn1 = cf.createConnection();
 
-      Connection conn2 = cf.createConnection();
+         assertEquals(0, ((JBossConnection) conn1).getServerID());
 
-      assertEquals(0, ((JBossConnection)conn2).getServerID());
+         Connection conn2 = cf.createConnection();
 
-      try
-      {
-         Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
+         assertEquals(0, ((JBossConnection) conn2).getServerID());
 
-         MessageProducer p = s.createProducer(queue);
-
-         for (int i = 0; i < 20; i++)
+         try
          {
-            p.send(s.createTextMessage("message " + i));
-         }
+            Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
 
-         s.commit();
+            MessageProducer p = s.createProducer(queue);
 
-         Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
+            for (int i = 0; i < 20; i++)
+            {
+               p.send(s.createTextMessage("message " + i));
+            }
 
-         // Create a consumer, start the session, close the consumer..
-         // This shouldn't cause any message to be lost
-         MessageConsumer c2 = s2.createConsumer(queue);
-         conn2.start();
-         c2.close();
+            s.commit();
 
-         c2 = s2.createConsumer(queue);
+            Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
 
-         //There is a possibility the messages arrive out of order if they hit the closed
-         //consumer and are cancelled back before delivery to the other consumer has finished.
-         //There is nothing much we can do about this
-         Set texts = new HashSet();
+            // Create a consumer, start the session, close the consumer..
+            // This shouldn't cause any message to be lost
+            MessageConsumer c2 = s2.createConsumer(queue);
+            conn2.start();
+            c2.close();
 
-         for (int i = 0; i < 20; i++)
-         {
-            TextMessage txt = (TextMessage)c2.receive(5000);
-            assertNotNull(txt);
-            texts.add(txt.getText());
-         }
+            c2 = s2.createConsumer(queue);
 
-         for (int i = 0; i < 20; i++)
-         {
-            assertTrue(texts.contains("message " + i));
-         }
+            //There is a possibility the messages arrive out of order if they hit the closed
+            //consumer and are cancelled back before delivery to the other consumer has finished.
+            //There is nothing much we can do about this
+            Set texts = new HashSet();
 
-         s2.commit();
+            for (int i = 0; i < 20; i++)
+            {
+               TextMessage txt = (TextMessage) c2.receive(5000);
+               assertNotNull(txt);
+               texts.add(txt.getText());
+            }
 
-         assertNull(c2.receive(1000));
-      }
-      finally
-      {
-         if (conn1 != null)
-         {
-            conn1.close();
+            for (int i = 0; i < 20; i++)
+            {
+               assertTrue(texts.contains("message " + i));
+            }
+
+            s2.commit();
+
+            assertNull(c2.receive(1000));
          }
-         if (conn2 != null)
+         finally
          {
-            conn2.close();
+            if (conn1 != null)
+            {
+               conn1.close();
+            }
+            if (conn2 != null)
+            {
+               conn2.close();
+            }
          }
       }
    }




More information about the jboss-cvs-commits mailing list