qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/3] qpid-jms git commit: Test some TX offline behavior
Date Mon, 16 Feb 2015 23:27:04 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 1ba99d539 -> 289c9ab3d


Test some TX offline behavior 

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/fa99c6f8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/fa99c6f8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/fa99c6f8

Branch: refs/heads/master
Commit: fa99c6f80e36cea98d2e02b752640850cd953e08
Parents: 1ba99d5
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Feb 16 15:50:04 2015 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Feb 16 15:50:04 2015 -0500

----------------------------------------------------------------------
 .../FailoverProviderOfflineBehaviorTest.java    | 48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/fa99c6f8/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java
index f60a9ba..1124014 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.qpid.jms.provider.failover;
 
+import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.net.URI;
 import java.util.concurrent.CountDownLatch;
@@ -25,6 +27,7 @@ import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
+import javax.jms.TransactionRolledBackException;
 
 import org.apache.qpid.jms.JmsConnection;
 import org.apache.qpid.jms.JmsConnectionFactory;
@@ -186,6 +189,51 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup
         connection.close();
     }
 
+    @Test(timeout=10000)
+    public void testTransactionCommitFails() throws Exception {
+        connection = (JmsConnection) factory.createConnection();
+        connection.addConnectionListener(new ConnectionInterruptionListener());
+        connection.start();
+
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Queue queue = session.createQueue(_testName.getMethodName());
+        MessageProducer producer = session.createProducer(queue);
+        producer.send(session.createMessage());
+
+        mockPeer.shutdown();
+        connectionInterrupted.await(9, TimeUnit.SECONDS);
+
+        try {
+            session.commit();
+            fail("Should not allow a commit while offline.");
+        } catch (TransactionRolledBackException ex) {}
+
+        connection.close();
+    }
+
+    @Test(timeout=10000)
+    public void testTransactionRollbackSucceeds() throws Exception {
+        connection = (JmsConnection) factory.createConnection();
+        connection.addConnectionListener(new ConnectionInterruptionListener());
+        connection.start();
+
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Queue queue = session.createQueue(_testName.getMethodName());
+        MessageProducer producer = session.createProducer(queue);
+        producer.send(session.createMessage());
+
+        mockPeer.shutdown();
+        connectionInterrupted.await(9, TimeUnit.SECONDS);
+
+        try {
+            session.rollback();
+        } catch (TransactionRolledBackException ex) {
+            fail("Should allow a rollback while offline.");
+        }
+
+        connection.close();
+    }
+
     private class ConnectionInterruptionListener implements JmsConnectionListener {
         @Override
         public void onConnectionInterrupted(URI remoteURI) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message