From d3ea5c4f9fbdbd69819a9a3977a844ea09b386f9 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Tue, 10 May 2016 11:41:30 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-5621 Fixing LinkStealingTest by adding a wait because removeConnection may not have been called yet when checking if the removeException exists the first time --- .../apache/activemq/broker/LinkStealingTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/activemq-broker/src/test/java/org/apache/activemq/broker/LinkStealingTest.java b/activemq-broker/src/test/java/org/apache/activemq/broker/LinkStealingTest.java index 2a2fb90c50..1e53f60460 100644 --- a/activemq-broker/src/test/java/org/apache/activemq/broker/LinkStealingTest.java +++ b/activemq-broker/src/test/java/org/apache/activemq/broker/LinkStealingTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.broker; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.concurrent.atomic.AtomicReference; @@ -26,6 +26,8 @@ import javax.jms.InvalidClientIDException; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.command.ConnectionInfo; +import org.apache.activemq.util.Wait; +import org.apache.activemq.util.Wait.Condition; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -110,7 +112,14 @@ public class LinkStealingTest { fail("Unexcpected exception causes test failure"); } - assertNotNull(removeException.get()); + //Need to wait because removeConnection might not be called yet + assertTrue(Wait.waitFor(new Condition() { + @Override + public boolean isSatisified() throws Exception { + return removeException.get() != null; + } + }, 5000, 100)); + LOG.info("removeException: {}", removeException.get().getMessage()); } }