activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [08/18] git commit: Add test case for session with local transactions.
Date Thu, 20 Mar 2014 18:44:04 GMT
Add test case for session with local transactions.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/315f3d4d
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/315f3d4d
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/315f3d4d

Branch: refs/heads/activemq-5.9
Commit: 315f3d4db81dc6df5154c3bd41ed00463899e32c
Parents: a25812d
Author: Timothy Bish <tabish121@gmai.com>
Authored: Mon Feb 10 12:20:44 2014 -0500
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Thu Mar 20 13:53:57 2014 -0400

----------------------------------------------------------------------
 .../activemq/transport/amqp/JMSClientTest.java  | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/315f3d4d/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
index af4f6f8..20d1f22 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
@@ -694,6 +694,40 @@ public class JMSClientTest extends AmqpTestSupport {
         assertTrue("No exception listener event fired.", called.await(15, TimeUnit.SECONDS));
     }
 
+    @Test
+    public void testSessionTransactedCommit() throws JMSException, InterruptedException {
+
+        Connection connection = createConnection();
+        Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+        Queue queue = session.createQueue(name.toString());
+
+        connection.start();
+
+        // transacted producer
+        MessageProducer pr = session.createProducer(queue);
+        for (int i = 0; i < 10; i++) {
+            Message m = session.createTextMessage("TestMessage" + i);
+            pr.send(m);
+        }
+
+        // No commit in place, so no message should be dispatched.
+        MessageConsumer consumer = session.createConsumer(queue);
+        TextMessage m = (TextMessage) consumer.receive(5000);
+
+        assertNull(m);
+
+        session.commit();
+
+        // Messages should be available now.
+        for (int i = 0; i < 10; i++) {
+            Message msg = consumer.receive(5000);
+            assertNotNull(msg);
+        }
+
+        session.close();
+        connection.close();
+    }
+
     private Connection createConnection() throws JMSException {
         return createConnection(name.toString(), false);
     }


Mime
View raw message