You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/01/03 05:50:41 UTC

[camel] 02/07: CAMEL-14340: Improve tests

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

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

commit a293dd5602aa93b63474f4d35955a2b6d260de8d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 2 19:40:59 2020 +0100

    CAMEL-14340: Improve tests
---
 .../apache/camel/impl/DefaultConsumerCacheTest.java    | 10 +++++-----
 .../apache/camel/impl/DefaultProducerCacheTest.java    | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerCacheTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerCacheTest.java
index 92f9fda..de6d2be 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerCacheTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerCacheTest.java
@@ -42,11 +42,11 @@ public class DefaultConsumerCacheTest extends ContextTestSupport {
             assertNotNull("the polling consumer should not be null", p);
         }
 
-        // the eviction is async so force cleanup
-        cache.cleanUp();
-
-        await().atMost(3, TimeUnit.SECONDS).until(() -> cache.size() == 1000);
-        assertEquals("Size should be 1000", 1000, cache.size());
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // the eviction is async so force cleanup
+            cache.cleanUp();
+            assertEquals("Size should be 1000", 1000, cache.size());
+        });
 
         cache.stop();
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerCacheTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerCacheTest.java
index f93542f..c473110 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerCacheTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerCacheTest.java
@@ -66,10 +66,11 @@ public class DefaultProducerCacheTest extends ContextTestSupport {
             cache.releaseProducer(e, p);
         }
 
-        // the eviction is async so force cleanup
-        cache.cleanUp();
-
-        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> assertEquals("Size should be 1000", 1000, cache.size()));
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // the eviction is async so force cleanup
+            cache.cleanUp();
+            assertEquals("Size should be 1000", 1000, cache.size());
+        });
 
         cache.stop();
 
@@ -90,10 +91,12 @@ public class DefaultProducerCacheTest extends ContextTestSupport {
             cache.releaseProducer(e, p);
         }
 
-        // the eviction is async so force cleanup
-        cache.cleanUp();
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // the eviction is async so force cleanup
+            cache.cleanUp();
+            assertEquals("Size should be 5", 5, cache.size());
+        });
 
-        await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> assertEquals("Size should be 5", 5, cache.size()));
         await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> assertEquals(3, stopCounter.get()));
 
         cache.stop();
@@ -248,6 +251,7 @@ public class DefaultProducerCacheTest extends ContextTestSupport {
     }
 
     private final class MyComponent extends DefaultComponent {
+
         public MyComponent(CamelContext context) {
             super(context);
         }