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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 12 14:29:42 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-03-12 14:29:42 -0400 (Mon, 12 Mar 2007)
New Revision: 2543

Modified:
   trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-899 - This test doesn't need this loop... The loop was here to increase chances of failing the test as the test was failing 1 in 6. The test still the same though.

Modified: trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2007-03-09 03:13:14 UTC (rev 2542)
+++ trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2007-03-12 18:29:42 UTC (rev 2543)
@@ -126,84 +126,66 @@
    {
       Queue queue = (Queue)ic.lookup("/queue/TestQueue");
 
-      // Maybe we could remove this counter after we are sure this test is fixed!
-      // I had to use a counter because this can work in some iterations.
-      for (int counter = 0; counter < 20; counter++)
-      {
-         log.info("Iteration = " + counter);
+      Connection conn1 = cf.createConnection();
 
-         Connection conn1 = cf.createConnection();
+      assertEquals(0, ((JBossConnection)conn1).getServerID());
 
-         assertEquals(0, ((JBossConnection)conn1).getServerID());
+      Connection conn2 = cf.createConnection();
 
-         Connection conn2 = cf.createConnection();
+      assertEquals(0, ((JBossConnection)conn2).getServerID());
 
-         assertEquals(0, ((JBossConnection)conn2).getServerID());
+      try
+      {
+         Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
 
-         try
+         MessageProducer p = s.createProducer(queue);
+
+         for (int i = 0; i < 20; i++)
          {
-            Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
+            p.send(s.createTextMessage("message " + i));
+         }
 
-            MessageProducer p = s.createProducer(queue);
+         s.commit();
 
-            for (int i = 0; i < 20; i++)
-            {
-               p.send(s.createTextMessage("message " + i));
-            }
+         Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
 
-            s.commit();
+         // these next three lines are an anti-pattern but they shouldn't loose any messages
+         MessageConsumer c2 = s2.createConsumer(queue);
+         conn2.start();
+         c2.close();
 
-            Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
+         c2 = s2.createConsumer(queue);
 
-            // these next three lines are an anti-pattern but they shouldn't loose any messages
-            MessageConsumer c2 = s2.createConsumer(queue);
-            conn2.start();
-            c2.close();
+         //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();
 
-            c2 = s2.createConsumer(queue);
+         for (int i = 0; i < 20; i++)
+         {
+            TextMessage txt = (TextMessage)c2.receive(5000);
+            assertNotNull(txt);
+            texts.add(txt.getText());
+         }
 
-            //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();
-            
-            for (int i = 0; i < 20; i++)
-            {
-               TextMessage txt = (TextMessage)c2.receive(5000);
-               assertNotNull(txt);
-               texts.add(txt.getText());               
-            }
-            
-            for (int i = 0; i < 20; i++)
-            {
-               assertTrue(texts.contains("message " + i));            
-            }
-            
-            // Ovidiu: the test was originally invalid, a locally transacted session that is closed 
-            //         rolls back its transaction. I added s2.commit() to correct the test.
-            // JMS 1.1 Specifications, Section 4.3.5:
-            // "Closing a connection must roll back the transactions in progress on its
-            // transacted sessions*.
-            // *) The term 'transacted session' refers to the case where a session's commit and
-            // rollback methods are used to demarcate a transaction local to the session. In the
-            // case where a session's work is coordinated by an external transaction manager, a
-            // session's commit and rollback methods are not used and the result of a closed
-            // session's work is determined later by the transaction manager.
+         for (int i = 0; i < 20; i++)
+         {
+            assertTrue(texts.contains("message " + i));
+         }
 
-            s2.commit();
+         s2.commit();
 
-            assertNull(c2.receive(1000));
+         assertNull(c2.receive(1000));
+      }
+      finally
+      {
+         if (conn1 != null)
+         {
+            conn1.close();
          }
-         finally
+         if (conn2 != null)
          {
-            if (conn1 != null)
-            {
-               conn1.close();
-            }
-            if (conn2 != null)
-            {
-               conn2.close();
-            }
+            conn2.close();
          }
       }
    }




More information about the jboss-cvs-commits mailing list