Repository: activemq
Updated Branches:
  refs/heads/master 272fb2b97 -> de5d0d943


https://issues.apache.org/jira/browse/AMQ-5854

Fix intermittent test failure caused by the test reconnecting before
the failure assertion had a chance to assert the expected failure


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

Branch: refs/heads/master
Commit: de5d0d9430838948196f573c5278c75fbee9f25e
Parents: 272fb2b
Author: Christopher L. Shannon (cshannon) <christopher.l.shan...@gmail.com>
Authored: Sun Nov 22 18:34:34 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shan...@gmail.com>
Committed: Sun Nov 22 18:36:38 2015 +0000

----------------------------------------------------------------------
 .../activemq/transport/failover/FailoverTxSlowAckTest.java  | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/de5d0d94/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTxSlowAckTest.java
----------------------------------------------------------------------
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTxSlowAckTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTxSlowAckTest.java
index 427e2ba..6e42090 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTxSlowAckTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTxSlowAckTest.java
@@ -106,6 +106,7 @@ public class FailoverTxSlowAckTest {
                         if (sendCount > 1) {
                             // need new thread b/c we have the service write 
lock
                             executorService.execute(new Runnable() {
+                                @Override
                                 public void run() {
                                     LOG.info("Stopping broker before 
commit...");
                                     try {
@@ -138,6 +139,7 @@ public class FailoverTxSlowAckTest {
 
         final CountDownLatch commitDoneLatch = new CountDownLatch(1);
         final CountDownLatch messagesReceived = new CountDownLatch(1);
+        final CountDownLatch brokerDisconnectedLatch = new CountDownLatch(1);
         final AtomicInteger receivedCount = new AtomicInteger();
 
         final AtomicBoolean gotDisconnect = new AtomicBoolean();
@@ -146,6 +148,7 @@ public class FailoverTxSlowAckTest {
         final MessageConsumer testConsumer = 
consumerSession.createConsumer(in);
         testConsumer.setMessageListener(new MessageListener() {
 
+            @Override
             public void onMessage(Message message) {
                 LOG.info("consume one and commit");
 
@@ -178,6 +181,9 @@ public class FailoverTxSlowAckTest {
                                 }
                             }));
 
+                            //connect down to trigger reconnect
+                            brokerDisconnectedLatch.countDown();
+
                             LOG.info("got disconnect");
                             gotReconnected.set(Wait.waitFor(new 
Wait.Condition() {
                                 @Override
@@ -204,6 +210,7 @@ public class FailoverTxSlowAckTest {
         });
 
         executorService.execute(new Runnable() {
+            @Override
             public void run() {
                 LOG.info("producer started");
                 try {
@@ -219,6 +226,8 @@ public class FailoverTxSlowAckTest {
 
         // will be stopped by the plugin on TX ack
         broker.waitUntilStopped();
+        //await for listener to detect disconnect
+        brokerDisconnectedLatch.await();
         broker = createBroker(false, url);
         broker.start();
 

Reply via email to