This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new a07827b  Attempt to make this test more robust
a07827b is described below

commit a07827b32397b2172813b4f177e6b9165436fe0f
Author: Jonathan Gallimore <[email protected]>
AuthorDate: Thu Jul 9 15:01:09 2020 +0100

    Attempt to make this test more robust
---
 .../activemq/ProperConnectionShutdownTest.java     | 25 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ProperConnectionShutdownTest.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ProperConnectionShutdownTest.java
index b11c2c0..5429de6 100644
--- 
a/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ProperConnectionShutdownTest.java
+++ 
b/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ProperConnectionShutdownTest.java
@@ -83,6 +83,21 @@ public class ProperConnectionShutdownTest {
             Thread.sleep(1000);
         }
 
+        int retry = 0;
+        boolean threadsCompleted = false;
+        while (retry < 30) {
+
+            threadsCompleted = checkThreads(threadsBefore);
+            if (threadsCompleted) break;
+            retry++;
+
+            Thread.sleep(1000);
+        }
+
+        assertTrue(threadsCompleted);
+    }
+
+    private boolean checkThreads(Thread[] threadsBefore) {
         // ensure no connection are leaking
         final Thread[] threadsAfter = listThreads();
 
@@ -99,12 +114,12 @@ public class ProperConnectionShutdownTest {
             }
         }
 
-        final String debugMessage = Join.join(", ", threadsAfter);
-
-        assertEquals(debugMessage, 0, countAMQ);
+        if (countAMQ > 0) {
+            return false;
+        }
 
-        // geronimo libs spawn 2 threads we know: PoolIdleReleaseTimer and 
CurrentTime so we can get initial + 2 threads there
-        assertTrue(debugMessage, countOthers <= threadsBefore.length + 2);
+        // we expect PoolIdleReleaseTimer, CurrentTime and LogAsyncStream
+        return countOthers <= threadsBefore.length + 3;
     }
 
     private Thread[] listThreads() {

Reply via email to