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 1aaf34d9ebbc CAMEL-27007: camel-core - shorter test time, round 2 
(#30214)
1aaf34d9ebbc is described below

commit 1aaf34d9ebbcc97a3dd189c83bd4210435078c99
Author: Adriano Machado <[email protected]>
AuthorDate: Mon Nov 16 16:55:47 2026 -0500

    CAMEL-27007: camel-core - shorter test time, round 2 (#30214)
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 .../component/dataset/DataSetConsumerTest.java     | 13 ++++--
 .../timer/TimerFirstFireAfterRouteRestartTest.java |  9 ++--
 .../processor/MulticastParallelStreamingTest.java  |  6 ++-
 ...tlingExceptionRoutePolicyOpenViaConfigTest.java | 15 ++++--
 .../task/task/BackgroundIterationTimeTaskTest.java | 31 ++++++++-----
 .../support/task/task/ForegroundTaskTest.java      | 23 ++++++----
 .../support/task/task/ForegroundTimeTaskTest.java  | 53 ++++++++++++----------
 .../camel/support/task/task/TaskTestSupport.java   | 10 +++-
 8 files changed, 104 insertions(+), 56 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
index 1d5c238980d5..9f6bf4f81b7c 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
@@ -36,6 +36,13 @@ public class DataSetConsumerTest extends ContextTestSupport {
     final String dataSetUriWithDataSetIndexSetToStrict = dataSetUri + 
"&dataSetIndex=strict";
     final String resultUri = "mock://result";
 
+    // the tests add a route, set the expectations and then start the context; 
a context that is already started
+    // starts the dataset consumer at once, and its messages race with the 
expectations
+    @Override
+    public boolean isUseAdviceWith() {
+        return true;
+    }
+
     @Override
     protected Registry createCamelRegistry() throws Exception {
         Registry answer = super.createCamelRegistry();
@@ -80,15 +87,15 @@ public class DataSetConsumerTest extends ContextTestSupport 
{
             }
         });
 
-        assertEquals(dataSet.getSize(), 
getMockEndpoint(dataSetUri).getExpectedCount(),
-                "expectedMessageCount should be the same as the DataSet size 
for a consumer-producer endpoint");
-
         MockEndpoint result = getMockEndpoint(resultUri);
         result.expectedMessageCount((int) dataSet.getSize());
         
result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
 
         context.start();
 
+        assertEquals(dataSet.getSize(), 
getMockEndpoint(dataSetUri).getExpectedCount(),
+                "expectedMessageCount should be the same as the DataSet size 
for a consumer-producer endpoint");
+
         assertMockEndpointsSatisfied();
     }
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerFirstFireAfterRouteRestartTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerFirstFireAfterRouteRestartTest.java
index af448c0db5fc..d7ab65df2227 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerFirstFireAfterRouteRestartTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerFirstFireAfterRouteRestartTest.java
@@ -26,6 +26,8 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spi.Registry;
 import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 /**
  * The first fire of a timer with {@code delay=0} must not be dropped when its 
route is (re)started at runtime on an
  * already started CamelContext.
@@ -40,9 +42,10 @@ public class TimerFirstFireAfterRouteRestartTest extends 
ContextTestSupport {
     public void testFirstFireNotDroppedOnRouteRestart() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
 
-        // the timer fires once when the route is started with the CamelContext
-        mock.expectedMessageCount(1);
-        MockEndpoint.assertIsSatisfied(context, 10, TimeUnit.SECONDS);
+        // the timer fires once when the route is started with the 
CamelContext, and the custom timer runs the
+        // task synchronously, so it has fired before the test starts; an 
expectation set now would leave a latch
+        // that nothing counts down, and the reset below would wait for it
+        assertEquals(1, mock.getReceivedCounter());
 
         mock.reset();
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelStreamingTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelStreamingTest.java
index b5b9d2ba211a..4b1afb536ba4 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelStreamingTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelStreamingTest.java
@@ -44,7 +44,7 @@ public class MulticastParallelStreamingTest extends 
ContextTestSupport {
     @Test
     public void testMulticastParallel() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(10);
+        mock.expectedMessageCount(5);
         mock.whenAnyExchangeReceived(new Processor() {
             public void process(Exchange exchange) {
                 // they should all be BA as B is faster than A
@@ -52,7 +52,9 @@ public class MulticastParallelStreamingTest extends 
ContextTestSupport {
             }
         });
 
-        for (int i = 0; i < 10; i++) {
+        // route a delays each message 2 seconds, and they are sent one after 
the other so that the threads of the
+        // multicast are free for the b branch
+        for (int i = 0; i < 5; i++) {
             template.sendBody("direct:start", "Hello");
         }
 
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 46ea90090390..a66683da14e5 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
@@ -60,19 +60,23 @@ class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTestSupport
     void testThrottlingRoutePolicyStartWithAlwaysOpenOffThenToggle() throws 
Exception {
         final ServiceSupport consumer = (ServiceSupport) 
context.getRoute("foo").getConsumer();
 
+        // each phase resets the mock and sets its expectation BEFORE the 
messages are sent: a latch created
+        // after some messages were already consumed never reaches zero, and 
the assertion waits the full timeout
+
         // send first set of messages
         // should go through b/c circuit is closed
         int size = 5;
+        result.expectedMessageCount(size);
         for (int i = 0; i < size; i++) {
             template.sendBody(url, "MessageRound1 " + i);
         }
-        result.expectedMessageCount(size);
         MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
 
         // send the trigger message while the circuit is still closed so it is
         // guaranteed to be consumed before we open the circuit
+        result.reset();
+        result.expectedMessageCount(1);
         template.sendBody(url, "MessageTrigger");
-        result.expectedMessageCount(size + 1);
         MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
 
         // toggle keepOpen to true: setKeepOpen() immediately suspends the
@@ -85,24 +89,25 @@ class ThrottlingExceptionRoutePolicyOpenViaConfigTest 
extends ContextTestSupport
 
         // send next set of messages
         // should NOT go through b/c circuit is open
+        result.reset();
+        result.expectedMessageCount(0);
         for (int i = 0; i < size; i++) {
             template.sendBody(url, "MessageRound2 " + i);
         }
 
         // should not close b/c keepOpen is true; use assertPeriod to verify 
no extra messages arrive
         result.setAssertPeriod(500);
-        result.expectedMessageCount(size + 1);
         MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
-        result.setAssertPeriod(0);
 
         // set keepOpen to false
+        result.reset();
+        result.expectedMessageCount(size);
         policy.setKeepOpen(false);
 
         // wait for the consumer to resume since keepOpen is now false
         await().atMost(10, TimeUnit.SECONDS).until(consumer::isStarted);
 
         // it should close b/c keepOpen is false — queued messages should now 
arrive
-        result.expectedMessageCount(size * 2 + 1);
         MockEndpoint.assertIsSatisfied(context, TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
     }
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/BackgroundIterationTimeTaskTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/BackgroundIterationTimeTaskTest.java
index 9c3c5cab064b..5d9b68e701f8 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/BackgroundIterationTimeTaskTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/BackgroundIterationTimeTaskTest.java
@@ -32,6 +32,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class BackgroundIterationTimeTaskTest extends TaskTestSupport {
 
+    // these tests count the iterations of a task and do not measure the 
elapsed time, so the budgets of one second are
+    // shortened to a fifth of it (and the slow predicate with them) and the 
test is five times faster
+    @Override
+    protected long slowPredicateMillis() {
+        return 400;
+    }
+
     @DisplayName("Test that the task does not run for more than the max 
iterations when using a supplier")
     @Test
     @Timeout(10)
@@ -41,7 +48,7 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
                         .withMaxIterations(3)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .withInitialDelay(Duration.ZERO)
                         // use unlimited duration so we're sure that the task 
is really canceled after maxIterations
                         .withUnlimitedDuration()
@@ -60,9 +67,9 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
         BackgroundTask task = Tasks.backgroundTask()
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withInterval(Duration.ofSeconds(1))
-                        .withInitialDelay(Duration.ofSeconds(1))
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withInterval(Duration.ofMillis(200))
+                        .withInitialDelay(Duration.ofMillis(200))
+                        .withMaxDuration(Duration.ofMillis(1000))
                         .withMaxIterations(5)
                         .build())
                 .build();
@@ -79,7 +86,7 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
         BackgroundTask task = Tasks.backgroundTask()
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .withInitialDelay(Duration.ZERO)
                         .withMaxIterations(3)
                         .build())
@@ -98,9 +105,9 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
         BackgroundTask task = Tasks.backgroundTask()
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .withInitialDelay(Duration.ZERO)
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(5_000))
                         .withMaxIterations(4)
                         .build())
                 .build();
@@ -119,7 +126,8 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
                         .withMaxIterations(4)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withMaxDuration(Duration.ofMillis(1000))
+                        .withInterval(Duration.ofMillis(200))
                         .withInitialDelay(Duration.ZERO)
                         .build())
                 .build();
@@ -137,9 +145,10 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
         BackgroundTask task = Tasks.backgroundTask()
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withInterval(Duration.ofSeconds(1))
-                        .withInitialDelay(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
+                        .withInitialDelay(Duration.ofMillis(200))
                         .withMaxIterations(4)
+                        .withMaxDuration(Duration.ofMillis(1000))
                         .build())
                 .build();
 
@@ -156,7 +165,7 @@ public class BackgroundIterationTimeTaskTest extends 
TaskTestSupport {
                 
.withScheduledExecutor(Executors.newSingleThreadScheduledExecutor())
                 .withBudget(Budgets.iterationTimeBudget()
                         .withMaxIterations(Integer.MAX_VALUE)
-                        .withInitialDelay(Duration.ofSeconds(1))
+                        .withInitialDelay(Duration.ofMillis(200))
                         .withUnlimitedDuration()
                         .build())
                 .build();
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTaskTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTaskTest.java
index 6a587d02ff07..1394c58d4c37 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTaskTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTaskTest.java
@@ -32,6 +32,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ForegroundTaskTest extends TaskTestSupport {
 
+    // these tests count the iterations of a task and do not measure the 
elapsed time, so the budgets of one second are
+    // shortened to a fifth of it (and the slow predicate with them) and the 
test is five times faster
+    @Override
+    protected long slowPredicateMillis() {
+        return 400;
+    }
+
     @DisplayName("Test that the task does not run for more than the max 
iterations when using a supplier")
     @Test
     @Timeout(20)
@@ -41,7 +48,7 @@ public class ForegroundTaskTest extends TaskTestSupport {
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -62,8 +69,8 @@ public class ForegroundTaskTest extends TaskTestSupport {
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
-                        .withInitialDelay(Duration.ofSeconds(1))
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInitialDelay(Duration.ofMillis(200))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -80,7 +87,7 @@ public class ForegroundTaskTest extends TaskTestSupport {
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -97,7 +104,7 @@ public class ForegroundTaskTest extends TaskTestSupport {
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -114,7 +121,7 @@ public class ForegroundTaskTest extends TaskTestSupport {
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -130,8 +137,8 @@ public class ForegroundTaskTest extends TaskTestSupport {
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationBudget()
                         .withMaxIterations(5)
-                        .withInitialDelay(Duration.ofSeconds(1))
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInitialDelay(Duration.ofMillis(200))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTimeTaskTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTimeTaskTest.java
index 2d9bfa3e0aea..cb704729e9cb 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTimeTaskTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/ForegroundTimeTaskTest.java
@@ -32,17 +32,24 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class ForegroundTimeTaskTest extends TaskTestSupport {
 
+    // these tests count the iterations of a task and do not measure the 
elapsed time, so the budgets of one second are
+    // shortened to a fifth of it (and the slow predicate with them) and the 
test is five times faster
+    @Override
+    protected long slowPredicateMillis() {
+        return 400;
+    }
+
     @DisplayName("Test that the task does not run for more than the max 
iterations when using a supplier")
     @Test
     @Timeout(20)
     void testRunNoMoreSupplier() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(5_000))
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -60,13 +67,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMoreSupplierWithDelay() {
-        // this should run 5 times in a total duration of 6 seconds (5s 
executing + 1s delay)
+        // this should run 5 times in a total duration of 1.2 seconds (1s 
executing + 200ms delay)
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofMillis(10_000))
+                        .withMaxDuration(Duration.ofMillis(5_000))
                         .withMaxIterations(5)
-                        .withInitialDelay(Duration.ofSeconds(1))
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInitialDelay(Duration.ofMillis(200))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -78,13 +85,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMorePredicate() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(5_000))
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -96,13 +103,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMorePredicateMaxDuration() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(1000))
                         .withMaxIterations(50)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -114,13 +121,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMorePredicateDeterministic() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(5_000))
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -132,13 +139,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMorePredicateDeterministicSlow() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(1000))
                         .withMaxIterations(5)
                         .withInitialDelay(Duration.ZERO)
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
@@ -150,13 +157,13 @@ class ForegroundTimeTaskTest extends TaskTestSupport {
     @Test
     @Timeout(20)
     void testRunNoMorePredicateDeterministicSlowWithDelay() {
-        // It should run 5 times in 4 seconds because there is no delay
+        // It should run 5 times in 800 milliseconds because there is no 
initial delay
         ForegroundTask task = Tasks.foregroundTask()
                 .withBudget(Budgets.iterationTimeBudget()
-                        .withMaxDuration(Duration.ofSeconds(5))
+                        .withMaxDuration(Duration.ofMillis(1000))
                         .withMaxIterations(5)
-                        .withInitialDelay(Duration.ofSeconds(1))
-                        .withInterval(Duration.ofSeconds(1))
+                        .withInitialDelay(Duration.ofMillis(200))
+                        .withInterval(Duration.ofMillis(200))
                         .build())
                 .build();
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/TaskTestSupport.java
 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/TaskTestSupport.java
index 4f53bbeccd71..2632314f7b71 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/support/task/task/TaskTestSupport.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/support/task/task/TaskTestSupport.java
@@ -57,7 +57,7 @@ public class TaskTestSupport {
         assertNotNull(stopAtValue);
 
         try {
-            Thread.sleep(2000);
+            Thread.sleep(slowPredicateMillis());
         } catch (InterruptedException e) {
             return false;
         }
@@ -70,6 +70,14 @@ public class TaskTestSupport {
         return false;
     }
 
+    /**
+     * How long the slow predicate takes. A test class that runs its task on a 
shorter interval than a second shortens
+     * it in the same proportion.
+     */
+    protected long slowPredicateMillis() {
+        return 2000;
+    }
+
     @BeforeEach
     void setUp() {
         taskCount.reset();

Reply via email to