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

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


The following commit(s) were added to refs/heads/main by this push:
     new 72a2aa1199f1 CAMEL-24035: Fix flaky camel-core tests with timed mock 
assertions
72a2aa1199f1 is described below

commit 72a2aa1199f1309c2ac8a09268acd353cb20693b
Author: Omar Atie <[email protected]>
AuthorDate: Wed Aug 5 02:16:23 2026 -0700

    CAMEL-24035: Fix flaky camel-core tests with timed mock assertions
    
    Extract TIMEOUT_SECONDS constants and drop unnecessary public modifiers
    in DistributedTimeoutTest and 
ThrottlingExceptionRoutePolicyOpenViaConfigTest.
    Completes remaining polish after core fixes merged in CAMEL-24037 and 
CAMEL-24042.
    
    Closes #25332
    
    Co-authored-by: Cursor Agent <[email protected]>
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../camel/processor/aggregator/DistributedTimeoutTest.java   | 12 +++++++-----
 .../ThrottlingExceptionRoutePolicyOpenViaConfigTest.java     | 12 +++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/DistributedTimeoutTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/DistributedTimeoutTest.java
index c1c9597029c7..869fa25ce270 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/DistributedTimeoutTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/DistributedTimeoutTest.java
@@ -30,7 +30,9 @@ import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-public class DistributedTimeoutTest extends AbstractDistributedTest {
+class DistributedTimeoutTest extends AbstractDistributedTest {
+
+    private static final long TIMEOUT_SECONDS = 30;
 
     private final MemoryAggregationRepository sharedAggregationRepository = 
new MemoryAggregationRepository(true);
 
@@ -41,7 +43,7 @@ public class DistributedTimeoutTest extends 
AbstractDistributedTest {
     private volatile long receivedTimeout;
 
     @Test
-    public void testAggregateTimeout() throws Exception {
+    void testAggregateTimeout() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:aggregated");
         MockEndpoint mock2 = getMockEndpoint2("mock:aggregated");
         mock.expectedMessageCount(0);
@@ -50,7 +52,7 @@ public class DistributedTimeoutTest extends 
AbstractDistributedTest {
         template.sendBodyAndHeader("direct:start", "A", "id", 123);
         template2.sendBodyAndHeader("direct:start", "B", "id", 123);
 
-        // wait a bit until the timeout was triggered
+        // wait until the timeout was triggered
         await().atMost(10, TimeUnit.SECONDS).until(() -> invoked.get() == 1);
 
         mock.assertIsSatisfied();
@@ -72,8 +74,8 @@ public class DistributedTimeoutTest extends 
AbstractDistributedTest {
         template2.sendBodyAndHeader("direct:start", "B", "id", 123);
         template2.sendBodyAndHeader("direct:start", "C", "id", 123);
 
-        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
-        MockEndpoint.assertIsSatisfied(context2, 30, TimeUnit.SECONDS);
+        MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
+        MockEndpoint.assertIsSatisfied(context2, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
 
         // should have not invoked the timeout method anymore
         assertEquals(1, invoked.get());
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/throttle/ThrottlingExceptionRoutePolicyOpenViaConfigTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/processor/throttle/ThrottlingExceptionRoutePolicyOpenViaConfigTest.java
index 3b3c50507dcd..75d7b7b81abc 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/processor/throttle/ThrottlingExceptionRoutePolicyOpenViaConfigTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/processor/throttle/ThrottlingExceptionRoutePolicyOpenViaConfigTest.java
@@ -28,7 +28,9 @@ import org.junit.jupiter.api.Test;
 
 import static org.awaitility.Awaitility.await;
 
-public class ThrottlingExceptionRoutePolicyOpenViaConfigTest extends 
ContextTestSupport {
+class ThrottlingExceptionRoutePolicyOpenViaConfigTest extends 
ContextTestSupport {
+
+    private static final long TIMEOUT_SECONDS = 30;
 
     private final String url = "seda:foo?concurrentConsumers=20";
     private MockEndpoint result;
@@ -55,7 +57,7 @@ public class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTest
     }
 
     @Test
-    public void testThrottlingRoutePolicyStartWithAlwaysOpenOffThenToggle() 
throws Exception {
+    void testThrottlingRoutePolicyStartWithAlwaysOpenOffThenToggle() throws 
Exception {
         final ServiceSupport consumer = (ServiceSupport) 
context.getRoute("foo").getConsumer();
 
         // send first set of messages
@@ -65,7 +67,7 @@ public class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTest
             template.sendBody(url, "MessageRound1 " + i);
         }
         result.expectedMessageCount(size);
-        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
+        MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
 
         // set keepOpen to true
         policy.setKeepOpen(true);
@@ -85,7 +87,7 @@ public class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTest
 
         // should not close b/c keepOpen is true
         result.expectedMessageCount(size + 1);
-        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
+        MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
 
         // set keepOpen to false
         policy.setKeepOpen(false);
@@ -95,7 +97,7 @@ public class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTest
 
         // it should close b/c keepOpen is false — queued messages should now 
arrive
         result.expectedMessageCount(size * 2 + 1);
-        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
+        MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
     }
 
     @Override

Reply via email to