[jboss-cvs] JBoss Messaging SVN: r3900 - branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 20 18:40:21 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-03-20 18:40:21 -0400 (Thu, 20 Mar 2008)
New Revision: 3900
Modified:
branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-1253 - Adding testcase
Modified: branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java 2008-03-20 17:03:19 UTC (rev 3899)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java 2008-03-20 22:40:21 UTC (rev 3900)
@@ -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