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 13:56:41 UTC

[camel] branch main updated: CAMEL-19541-1: replaced cycles with Thread.sleep() with throttling execution method in camel-quartz

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 a6d72b16880 CAMEL-19541-1: replaced cycles with Thread.sleep() with throttling execution method in camel-quartz
a6d72b16880 is described below

commit a6d72b16880f36ae99e0c60b88815c239e2bb879
Author: Nikita Konovalov <nk...@redhat.com>
AuthorDate: Thu Oct 26 14:31:39 2023 +0200

    CAMEL-19541-1: replaced cycles with Thread.sleep() with throttling execution method in camel-quartz
---
 .../camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java    | 8 ++++----
 .../routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java    | 9 +++++----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java b/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
index 2911a0e8b9b..d83d3c36deb 100644
--- a/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
+++ b/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.routepolicy.quartz;
 
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
@@ -28,6 +29,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.camel.throttling.ThrottlingInflightRoutePolicy;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.test.junit5.TestSupport.executeSlowly;
 import static org.junit.jupiter.api.Assertions.assertSame;
 
 public class MultiplePoliciesOnRouteTest extends CamelTestSupport {
@@ -80,10 +82,8 @@ public class MultiplePoliciesOnRouteTest extends CamelTestSupport {
         context.start();
 
         assertSame(ServiceStatus.Started, context.getRouteController().getRouteStatus("test"));
-        for (int i = 0; i < size; i++) {
-            template.sendBody(url, "Message " + i);
-            Thread.sleep(3);
-        }
+
+        executeSlowly(size, 3, TimeUnit.MILLISECONDS, (i) -> template.sendBody(url, "Message " + i));
 
         context.getComponent("quartz", QuartzComponent.class).stop();
         success.assertIsSatisfied();
diff --git a/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java b/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
index 485c65be03a..03a7f19f84d 100644
--- a/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
+++ b/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
@@ -16,12 +16,16 @@
  */
 package org.apache.camel.routepolicy.quartz;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
+import static org.apache.camel.test.junit5.TestSupport.executeSlowly;
+
 public class SpringMultiplePoliciesOnRouteTest extends CamelSpringTestSupport {
     private String url = "seda:foo?concurrentConsumers=20";
     private int size = 100;
@@ -32,10 +36,7 @@ public class SpringMultiplePoliciesOnRouteTest extends CamelSpringTestSupport {
         // when we get graceful shutdown support we can prevent this
         getMockEndpoint("mock:success").expectedMinimumMessageCount(size - 10);
 
-        for (int i = 0; i < size; i++) {
-            template.sendBody(url, "Message " + i);
-            Thread.sleep(3);
-        }
+        executeSlowly(size, 3, TimeUnit.MILLISECONDS, (i) -> template.sendBody(url, "Message " + i));
 
         MockEndpoint.assertIsSatisfied(context);
     }