From 38188cdf2e6a1a04c6b900ec6bbc6bd49a406b4b Mon Sep 17 00:00:00 2001 From: jbertram Date: Mon, 10 Aug 2015 16:19:01 -0500 Subject: [PATCH] ARTEMIS-179 fix BindingsClusterTest --- .../jms/cluster/BindingsClusterTest.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java index 29c0edc7fa..674c9f15d7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java @@ -402,28 +402,32 @@ public class BindingsClusterTest extends JMSClusteredTestBase { } private void crash() throws Exception { + /* + * Rather than just calling stop() on the server here we want to simulate an actual node crash or bridge failure + * so the bridge's failure listener needs to get something other than a DISCONNECTED message. In this case we + * simulate a NOT_CONNECTED exception. + */ + final CountDownLatch latch = new CountDownLatch(1); + ClusterConnectionImpl next = (ClusterConnectionImpl) server1.getClusterManager().getClusterConnections().iterator().next(); + BridgeImpl bridge = (BridgeImpl) next.getRecords().values().iterator().next().getBridge(); + RemotingConnection forwardingConnection = getForwardingConnection(bridge); + forwardingConnection.addFailureListener(new FailureListener() { + @Override + public void connectionFailed(ActiveMQException exception, boolean failedOver) { + latch.countDown(); + } + + @Override + public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) { + connectionFailed(me, failedOver); + } + }); + forwardingConnection.fail(new ActiveMQNotConnectedException()); + assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); + if (crash) { jmsServer2.stop(); } - else { - final CountDownLatch latch = new CountDownLatch(1); - ClusterConnectionImpl next = (ClusterConnectionImpl) server1.getClusterManager().getClusterConnections().iterator().next(); - BridgeImpl bridge = (BridgeImpl) next.getRecords().values().iterator().next().getBridge(); - RemotingConnection forwardingConnection = getForwardingConnection(bridge); - forwardingConnection.addFailureListener(new FailureListener() { - @Override - public void connectionFailed(ActiveMQException exception, boolean failedOver) { - latch.countDown(); - } - - @Override - public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) { - connectionFailed(me, failedOver); - } - }); - forwardingConnection.fail(new ActiveMQNotConnectedException()); - assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); - } } private void restart() throws Exception {