You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/10/26 12:24:16 UTC

[camel] branch main updated: CAMEL-19986: created throttling executor in camel-test

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

orpiske 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 592f3db2317 CAMEL-19986: created throttling executor in camel-test
592f3db2317 is described below

commit 592f3db2317e7f4daa09fc8eb5b3b00d8d352dc8
Author: Nikita Konovalov <nk...@redhat.com>
AuthorDate: Wed Oct 25 17:03:58 2023 +0200

    CAMEL-19986: created throttling executor in camel-test
---
 .../src/main/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 01be80cdbfc..4a0e90f3182 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.nio.file.Path;
 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 final class TestSupport {
     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));
+        }
+    }
 }