qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject qpid-jms git commit: QPIDJMS-265: add test verifying the client attempts reconnection when receiving remote closure with connection-forced error
Date Wed, 15 Feb 2017 12:33:27 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master e034731fc -> e343dd054


QPIDJMS-265: add test verifying the client attempts reconnection when receiving remote closure
with connection-forced error


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

Branch: refs/heads/master
Commit: e343dd05482e784ceec573c47fe4d4b30e5c2f9a
Parents: e034731
Author: Robert Gemmell <robbie@apache.org>
Authored: Wed Feb 15 12:23:34 2017 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Wed Feb 15 12:23:34 2017 +0000

----------------------------------------------------------------------
 .../failover/FailoverIntegrationTest.java       | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e343dd05/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
index 008670c..8174eea 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
@@ -57,6 +57,7 @@ import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
 import org.apache.qpid.jms.test.testpeer.basictypes.AmqpError;
+import org.apache.qpid.jms.test.testpeer.basictypes.ConnectionError;
 import org.apache.qpid.jms.test.testpeer.basictypes.TerminusDurability;
 import org.apache.qpid.jms.test.testpeer.describedtypes.Accepted;
 import org.apache.qpid.jms.test.testpeer.describedtypes.Rejected;
@@ -221,6 +222,58 @@ public class FailoverIntegrationTest extends QpidJmsTestCase {
     }
 
     @Test(timeout = 20000)
+    public void testFailoverHandlesRemotelyEndConnectionForced() throws Exception {
+        try (TestAmqpPeer forcingPeer = new TestAmqpPeer();
+             TestAmqpPeer backupPeer = new TestAmqpPeer();) {
+
+            final String forcingPeerURI = createPeerURI(forcingPeer);
+            final String backupPeerURI = createPeerURI(backupPeer);
+            LOG.info("Primary is at {}: Backup peer is at: {}", forcingPeerURI, backupPeerURI);
+
+            final CountDownLatch connectedToPrimary = new CountDownLatch(1);
+            final CountDownLatch connectedToBackup = new CountDownLatch(1);
+
+            forcingPeer.expectSaslAnonymous();
+            forcingPeer.expectOpen();
+            forcingPeer.expectBegin();
+            forcingPeer.remotelyCloseConnection(true, ConnectionError.CONNECTION_FORCED,
"Server is going away", 10);
+
+            backupPeer.expectSaslAnonymous();
+            backupPeer.expectOpen();
+            backupPeer.expectBegin();
+
+            final JmsConnection connection = establishAnonymousConnecton(forcingPeer, backupPeer);
+            connection.addConnectionListener(new JmsDefaultConnectionListener() {
+                @Override
+                public void onConnectionEstablished(URI remoteURI) {
+                    LOG.info("Connection Established: {}", remoteURI);
+                    if (remoteURI.toString().equals(forcingPeerURI)) {
+                        connectedToPrimary.countDown();
+                    }
+                }
+
+                @Override
+                public void onConnectionRestored(URI remoteURI) {
+                    LOG.info("Connection Reestablished: {}", remoteURI);
+                    if (remoteURI.toString().equals(backupPeerURI)) {
+                        connectedToBackup.countDown();
+                    }
+                }
+            });
+            connection.start();
+
+            forcingPeer.waitForAllHandlersToComplete(3000);
+
+            assertTrue("Should connect to primary peer", connectedToPrimary.await(5, TimeUnit.SECONDS));
+            assertTrue("Should connect to backup peer", connectedToBackup.await(5, TimeUnit.SECONDS));
+
+            backupPeer.expectClose();
+            connection.close();
+            backupPeer.waitForAllHandlersToComplete(1000);
+        }
+    }
+
+    @Test(timeout = 20000)
     public void testFailoverHandlesTransportDropBeforeDispositionRecieived() throws Exception
{
         try (TestAmqpPeer originalPeer = new TestAmqpPeer();
              TestAmqpPeer finalPeer = new TestAmqpPeer();) {


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


Mime
View raw message