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/07/14 10:57:59 UTC

[camel] branch main updated: (chores) camel-core: DelayerWhileShutdownTest fixes and cleanups

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 60bfe112ad8 (chores) camel-core: DelayerWhileShutdownTest fixes and cleanups
60bfe112ad8 is described below

commit 60bfe112ad8d67d1f0219dd19b862deec8818ff0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Jul 14 11:24:42 2023 +0200

    (chores) camel-core: DelayerWhileShutdownTest fixes and cleanups
    
    - send test kick-off messages earlier
    - increase timeouts
    - improve test execution coordination
---
 .../camel/processor/DelayerWhileShutdownTest.java     | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
index 2202740cfe7..2c52c83febf 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/DelayerWhileShutdownTest.java
@@ -16,9 +16,13 @@
  */
 package org.apache.camel.processor;
 
+import java.util.concurrent.Phaser;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -26,13 +30,20 @@ import org.junit.jupiter.api.Test;
  */
 public class DelayerWhileShutdownTest extends ContextTestSupport {
 
+    private final Phaser phaser = new Phaser(2);
+
+    @BeforeEach
+    void sendEarly() {
+        template.sendBody("seda:a", "Long delay");
+        template.sendBody("seda:b", "Short delay");
+    }
+
     @Test
     public void testSendingMessageGetsDelayed() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Short delay");
 
-        template.sendBody("seda:a", "Long delay");
-        template.sendBody("seda:b", "Short delay");
+        phaser.awaitAdvanceInterruptibly(0, 5000, TimeUnit.SECONDS);
 
         assertMockEndpointsSatisfied();
     }
@@ -41,8 +52,8 @@ public class DelayerWhileShutdownTest extends ContextTestSupport {
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("seda:a").delay(500).to("mock:result");
-                from("seda:b").delay(1).to("mock:result");
+                from("seda:a").process(e -> phaser.arriveAndAwaitAdvance()).delay(1000).to("mock:result");
+                from("seda:b").process(e -> phaser.arriveAndAwaitAdvance()).delay(1).to("mock:result");
             }
         };
     }