From b968c0c9b2147b629523aab685e1bda17558427b Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Tue, 11 Sep 2012 09:13:00 +0000 Subject: [PATCH] Fixing test on CI servers. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1383304 13f79535-47bb-0310-9956-ffa450edef68 --- ...lientAndBrokerDoesNotLeaveThreadsRunningTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java index 38f5e11a43..164d6a82fa 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java @@ -78,16 +78,16 @@ public class StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest extends T } public void runTest(Task task) throws Exception { - int numThreads = Thread.currentThread().getThreadGroup().activeCount(); -// Thread.currentThread().getThreadGroup().list(); + int before = Thread.currentThread().getThreadGroup().activeCount(); task.execute(); Thread.yield(); - Thread.sleep(2000); // Wait for the threads to exit on their own + // need to wait for slow servers + Thread.sleep(5000); -// Thread.currentThread().getThreadGroup().list(); - int activeCount = Thread.currentThread().getThreadGroup().activeCount(); - assertTrue("Should be at most one more thread but was: " + activeCount, numThreads + 1 <= activeCount); + int after = Thread.currentThread().getThreadGroup().activeCount(); + int diff = Math.abs(before - after); + assertTrue("Should be at most one more thread. Diff = " + diff, diff + 1 <= after); } }