[Jboss-cvs] JBoss Messaging SVN: r1311 - branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 18 19:59:33 EDT 2006


Author: ovidiu.feodorov at jboss.com
Date: 2006-09-18 19:59:31 -0400 (Mon, 18 Sep 2006)
New Revision: 1311

Modified:
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
Log:
added extra test cases for http://jira.jboss.org/jira/browse/JBMESSAGING-410

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java	2006-09-18 23:57:51 UTC (rev 1310)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java	2006-09-18 23:59:31 UTC (rev 1311)
@@ -109,6 +109,109 @@
    }
 
    /**
+    * The difference from the previous test is that we're creating the session using
+    * conn.createSession(false, ...);
+    */
+   public void testSimpleTransactedSend2() throws Exception
+   {
+      Transaction suspended = TransactionManagerLocator.getInstance().locate().suspend();
+
+      try
+      {
+
+         ConnectionFactory mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
+         Connection conn = mcf.createConnection();
+         conn.start();
+
+         UserTransaction ut = ServerManagement.getUserTransaction();
+
+         ut.begin();
+
+         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer p = s.createProducer(queue);
+         Message m = s.createTextMessage("one");
+
+         p.send(m);
+
+         ut.commit();
+
+         conn.close();
+
+         ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+         conn = cf.createConnection();
+         s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+         conn.start();
+
+         TextMessage rm = (TextMessage)s.createConsumer(queue).receive(500);
+
+         assertEquals("one", rm.getText());
+      }
+      finally
+      {
+
+         if (suspended != null)
+         {
+            TransactionManagerLocator.getInstance().locate().resume(suspended);
+         }
+      }
+   }
+
+   /**
+    * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-410.
+    */
+   public void testSendNoGlobalTransaction() throws Exception
+   {
+      Transaction suspended = null;
+
+      try
+      {
+         ServerManagement.deployQueue("MyQueue");
+
+         // make sure there's no active JTA transaction
+
+         suspended = TransactionManagerLocator.getInstance().locate().suspend();
+
+         // send a message to the queue, using a JCA wrapper
+
+         Queue queue = (Queue)ic.lookup("queue/MyQueue");
+
+         ConnectionFactory mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
+
+         Connection conn = mcf.createConnection();
+         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer p = s.createProducer(queue);
+         p.setDeliveryMode(DeliveryMode.PERSISTENT);
+         Message m = s.createTextMessage("one");
+
+         p.send(m);
+
+         conn.close();
+
+         // receive the message
+         ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+         conn = cf.createConnection();
+         conn.start();
+         s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageConsumer c = s.createConsumer(queue);
+         TextMessage rm = (TextMessage)c.receive(1000);
+
+         assertEquals("one", rm.getText());
+
+         conn.close();
+      }
+      finally
+      {
+         ServerManagement.undeployQueue("MyQueue");
+
+         if (suspended != null)
+         {
+            TransactionManagerLocator.getInstance().locate().resume(suspended);
+         }
+      }
+   }
+
+
+   /**
     * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-520.
     */
    public void testReceiveNoGlobalTransaction() throws Exception




More information about the jboss-cvs-commits mailing list