[jboss-cvs] JBoss Messaging SVN: r3950 - branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 26 13:43:08 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-03-26 13:43:08 -0400 (Wed, 26 Mar 2008)
New Revision: 3950

Modified:
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
Log:
JBMESSAGING-1253 Adding testcase on CP branch (from Branch_Stable)

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	2008-03-26 17:33:18 UTC (rev 3949)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	2008-03-26 17:43:08 UTC (rev 3950)
@@ -22,6 +22,8 @@
 package org.jboss.test.messaging.jms;
 
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
@@ -31,6 +33,7 @@
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
@@ -584,7 +587,62 @@
       	}
       }
    }
+   
+   public void testSameTransaction() throws Exception
+   {
+      Connection conn = null;
+      
+      try
+      {        
+         conn = cf.createConnection();
+         conn.setClientID(".testSameTransaction");
+         conn.start();
+         
+         
+         // Several Iterations as it can pass eventually
+         for (int i=0; i<50; i++)
+         {
+            log.info("*************************************************************");
+            log.info("Iteration " + i);
+            log.info("*************************************************************");
 
+            Session s = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+            
+            MessageProducer prod = s.createProducer(topic1);
+
+            final CountDownLatch latchReceive = new CountDownLatch(1);
+            TopicSubscriber subscriber = s.createDurableSubscriber(topic1, "topic" + i);
+            subscriber.setMessageListener(new MessageListener(){
+               public void onMessage(Message arg0)
+               {
+                  latchReceive.countDown();
+               }
+            });
+            
+            prod.send(s.createTextMessage("msg1"));
+            s.commit(); // to the message send
+            
+            latchReceive.await(10, TimeUnit.SECONDS);
+            assertEquals(0, latchReceive.getCount());
+            
+            s.commit(); // to the message receive
+            
+            prod.close();
+            
+            subscriber.close();
+            
+            s.unsubscribe("topic" + i);
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------




More information about the jboss-cvs-commits mailing list