[Jboss-cvs] JBoss Messaging SVN: r1316 - 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
Tue Sep 19 00:08:24 EDT 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-09-19 00:08:23 -0400 (Tue, 19 Sep 2006)
New Revision: 1316
Modified:
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
Log:
added extra tests 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-19 04:07:09 UTC (rev 1315)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java 2006-09-19 04:08:23 UTC (rev 1316)
@@ -91,7 +91,7 @@
ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
conn = cf.createConnection();
- s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
TextMessage rm = (TextMessage)s.createConsumer(queue).receive(500);
@@ -139,12 +139,14 @@
ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
conn = cf.createConnection();
- s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
TextMessage rm = (TextMessage)s.createConsumer(queue).receive(500);
assertEquals("one", rm.getText());
+
+ conn.close();
}
finally
{
@@ -178,6 +180,7 @@
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);
@@ -185,6 +188,8 @@
p.send(m);
+ log.debug("message sent");
+
conn.close();
// receive the message
@@ -210,7 +215,87 @@
}
}
+ /**
+ * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-410. Use a cached connection that
+ * was initally enroled in a global transaction.
+ */
+ public void testSendNoGlobalTransaction2() 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.AUTO_ACKNOWLEDGE);
+ conn.start();
+
+ TextMessage rm = (TextMessage)s.createConsumer(queue).receive(500);
+
+ assertEquals("one", rm.getText());
+
+ conn.close();
+
+ // make sure there's no active JTA transaction
+
+ assertNull(TransactionManagerLocator.getInstance().locate().getTransaction());
+
+ // send a message to the queue, using a JCA wrapper
+
+ mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
+
+ conn = mcf.createConnection();
+
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ p = s.createProducer(queue);
+ p.setDeliveryMode(DeliveryMode.PERSISTENT);
+ m = s.createTextMessage("one");
+
+ p.send(m);
+
+ conn.close();
+
+ // receive the message
+ cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ conn = cf.createConnection();
+ conn.start();
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer c = s.createConsumer(queue);
+ rm = (TextMessage)c.receive(1000);
+
+ assertEquals("one", rm.getText());
+
+ conn.close();
+ }
+ finally
+ {
+ if (suspended != null)
+ {
+ TransactionManagerLocator.getInstance().locate().resume(suspended);
+ }
+ }
+ }
+
/**
* Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-520.
*/
@@ -218,12 +303,12 @@
{
try
{
- ServerManagement.deployQueue("MyQueue");
+ ServerManagement.deployQueue("MyQueue2");
// send a message to the queue
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("queue/MyQueue");
+ Queue queue = (Queue)ic.lookup("queue/MyQueue2");
Connection conn = cf.createConnection();
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer p = s.createProducer(queue);
@@ -257,7 +342,7 @@
conn.close();
// now the queue should be empty
- ObjectName on = new ObjectName("jboss.messaging.destination:service=Queue,name=MyQueue");
+ ObjectName on = new ObjectName("jboss.messaging.destination:service=Queue,name=MyQueue2");
Integer count = (Integer)ServerManagement.getAttribute(on, "MessageCount");
assertEquals(0, count.intValue());
}
@@ -272,7 +357,7 @@
}
finally
{
- ServerManagement.undeployQueue("MyQueue");
+ ServerManagement.undeployQueue("MyQueue2");
}
}
More information about the jboss-cvs-commits
mailing list