activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [2/2] git commit: Add test case for session with local transactions.
Date Mon, 10 Feb 2014 18:26:00 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/1e7dc12c
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/1e7dc12c
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/1e7dc12c

Branch: refs/heads/trunk
Commit: 1e7dc12c3098061a421ba709b00aaf07d3e63b69
Parents: 519d8f7
Author: Timothy Bish <tabish121@gmai.com>
Authored: Mon Feb 10 12:20:44 2014 -0500
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Mon Feb 10 13:25:47 2014 -0500

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/1e7dc12c/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