From 3f3fed4a92ea7ef8f26819b6f48f8c7ede9f6833 Mon Sep 17 00:00:00 2001 From: Nikita Konovalov Date: Wed, 25 Oct 2023 17:03:58 +0200 Subject: [PATCH] CAMEL-19986: created throttling executor in camel-test --- .../java/org/apache/camel/test/junit5/TestSupport.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java index 01be80cdbfc62..4a0e90f318204 100644 --- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java +++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java @@ -23,6 +23,8 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.concurrent.TimeUnit; +import java.util.function.IntConsumer; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; @@ -581,4 +583,11 @@ public static String fileUri(Path testDirectory) { public static String fileUri(Path testDirectory, String query) { return "file:" + testDirectory + (query.startsWith("?") ? "" : "/") + query; } + + public static void executeSlowly(int count, long interval, TimeUnit timeUnit, IntConsumer task) throws Exception { + for (int i = 0; i < count; i++) { + task.accept(i); + Thread.sleep(timeUnit.toMillis(interval)); + } + } }