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/15 08:58:15 UTC

[camel] branch main updated (f7f6fb0c38f -> ec619feb60a)

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

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from f7f6fb0c38f CAMEL-19607: camel-core - Fix error handler redeliveryPolicyRef
     new 159d3d6106a Revert "(chores) camel-core: RecipientListWithSimpleExpressionTest test fixes and cleanups"
     new ec619feb60a (chores) camel-core: RecipientListWithSimpleExpressionTest cleanups

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../RecipientListWithSimpleExpressionTest.java     | 65 +++++++++-------------
 1 file changed, 25 insertions(+), 40 deletions(-)


[camel] 01/02: Revert "(chores) camel-core: RecipientListWithSimpleExpressionTest test fixes and cleanups"

Posted by or...@apache.org.
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

commit 159d3d6106a2dca565806ca252f8b7e4822860d5
Author: Otavio R. Piske <an...@gmail.com>
AuthorDate: Sat Jul 15 09:34:24 2023 +0200

    Revert "(chores) camel-core: RecipientListWithSimpleExpressionTest test fixes and cleanups"
    
    This reverts commit cce62c2ce9977eeeb95305dd1611e07a566b0624.
---
 .../RecipientListWithSimpleExpressionTest.java     | 110 ++++++++++++++-------
 1 file changed, 74 insertions(+), 36 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
index 4761b06f928..fbda46e7a9a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
@@ -16,70 +16,108 @@
  */
 package org.apache.camel.processor;
 
-import java.time.Duration;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Phaser;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Header;
 import org.apache.camel.builder.RouteBuilder;
-import org.awaitility.Awaitility;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.Isolated;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-@Isolated("This test creates a larger thread pool, which may be too much on slower hosts")
 public class RecipientListWithSimpleExpressionTest extends ContextTestSupport {
-    private static final Logger LOG = LoggerFactory.getLogger(RecipientListWithSimpleExpressionTest.class);
-    private final ScheduledExecutorService executors = Executors.newScheduledThreadPool(10);
-    private final Phaser phaser = new Phaser(50);
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testRecipientList() throws Exception {
+        context.addRoutes(new RouteBuilder() {
             @Override
-            public void configure() {
+            public void configure() throws Exception {
                 from("direct:start").recipientList(simple("mock:${in.header.queue}"));
             }
-        };
-    }
+        });
+        context.start();
+        template.start();
 
-    @BeforeEach
-    void sendMessages() {
-        // it may take a little while for the context to start on slower hosts
-        Awaitility.await().atMost(Duration.ofSeconds(2)).until(() -> context.getUptimeMillis() > 1000);
+        for (int i = 0; i < 10; i++) {
+            getMockEndpoint("mock:" + i).expectedMessageCount(50);
+        }
 
         // use concurrent producers to send a lot of messages
+        ExecutorService executors = Executors.newFixedThreadPool(10);
         for (int i = 0; i < 50; i++) {
-            final Runnable runOverRunnable = new Runnable() {
-                int i;
-
-                @Override
+            executors.execute(new Runnable() {
                 public void run() {
-                    template.sendBodyAndHeader("direct:start", "Hello " + i, "queue", i);
-                    i++;
-                    if (i == 10) {
-                        i = 0;
+                    for (int i = 0; i < 10; i++) {
+                        try {
+                            template.sendBodyAndHeader("direct:start", "Hello " + i, "queue", i);
+                            Thread.sleep(5);
+                        } catch (Exception e) {
+                            // ignore
+                        }
                     }
                 }
-            };
-            executors.scheduleAtFixedRate(runOverRunnable, 0, 50, TimeUnit.MILLISECONDS);
-            phaser.arrive();
+            });
+        }
+
+        assertMockEndpointsSatisfied();
+        executors.shutdownNow();
+    }
+
+    public static class MyBeanRouter {
+
+        @org.apache.camel.RecipientList
+        public String route(@Header("queue") String queue) {
+            return "mock:" + queue;
         }
     }
 
     @Test
-    public void testRecipientList() throws InterruptedException, TimeoutException {
+    public void testStatic() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:0").to("mock:0");
+                from("direct:1").to("mock:1");
+                from("direct:2").to("mock:2");
+                from("direct:3").to("mock:3");
+                from("direct:4").to("mock:4");
+                from("direct:5").to("mock:5");
+                from("direct:6").to("mock:6");
+                from("direct:7").to("mock:7");
+                from("direct:8").to("mock:8");
+                from("direct:9").to("mock:9");
+            }
+        });
+        context.start();
+        template.start();
+
         for (int i = 0; i < 10; i++) {
             getMockEndpoint("mock:" + i).expectedMessageCount(50);
         }
 
-        phaser.awaitAdvanceInterruptibly(0, 5000, TimeUnit.SECONDS);
+        // use concurrent producers to send a lot of messages
+        ExecutorService executors = Executors.newFixedThreadPool(10);
+        for (int i = 0; i < 50; i++) {
+            executors.execute(new Runnable() {
+                public void run() {
+                    for (int i = 0; i < 10; i++) {
+                        try {
+                            template.sendBodyAndHeader("direct:" + i, "Hello " + i, "queue", i);
+                            Thread.sleep(5);
+                        } catch (Exception e) {
+                            // ignore
+                        }
+                    }
+                }
+            });
+        }
+
         assertMockEndpointsSatisfied();
         executors.shutdownNow();
     }
+
 }


[camel] 02/02: (chores) camel-core: RecipientListWithSimpleExpressionTest cleanups

Posted by or...@apache.org.
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

commit ec619feb60a99f5d89321cf221ff0e3e7b9dad20
Author: Otavio R. Piske <an...@gmail.com>
AuthorDate: Sat Jul 15 09:35:59 2023 +0200

    (chores) camel-core: RecipientListWithSimpleExpressionTest cleanups
    
    - removed unrelated test case
    - isolate the test, as it requires more resources than the rest of the tests
    
    Signed-off-by: Otavio R. Piske <an...@gmail.com>
---
 .../RecipientListWithSimpleExpressionTest.java     | 57 +---------------------
 1 file changed, 2 insertions(+), 55 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
index fbda46e7a9a..0ecd39bde13 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java
@@ -20,10 +20,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Header;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
 
+@Isolated("This test creates a larger thread pool, which may be too much on slower hosts")
 public class RecipientListWithSimpleExpressionTest extends ContextTestSupport {
 
     @Override
@@ -66,58 +67,4 @@ public class RecipientListWithSimpleExpressionTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
         executors.shutdownNow();
     }
-
-    public static class MyBeanRouter {
-
-        @org.apache.camel.RecipientList
-        public String route(@Header("queue") String queue) {
-            return "mock:" + queue;
-        }
-    }
-
-    @Test
-    public void testStatic() throws Exception {
-        context.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("direct:0").to("mock:0");
-                from("direct:1").to("mock:1");
-                from("direct:2").to("mock:2");
-                from("direct:3").to("mock:3");
-                from("direct:4").to("mock:4");
-                from("direct:5").to("mock:5");
-                from("direct:6").to("mock:6");
-                from("direct:7").to("mock:7");
-                from("direct:8").to("mock:8");
-                from("direct:9").to("mock:9");
-            }
-        });
-        context.start();
-        template.start();
-
-        for (int i = 0; i < 10; i++) {
-            getMockEndpoint("mock:" + i).expectedMessageCount(50);
-        }
-
-        // use concurrent producers to send a lot of messages
-        ExecutorService executors = Executors.newFixedThreadPool(10);
-        for (int i = 0; i < 50; i++) {
-            executors.execute(new Runnable() {
-                public void run() {
-                    for (int i = 0; i < 10; i++) {
-                        try {
-                            template.sendBodyAndHeader("direct:" + i, "Hello " + i, "queue", i);
-                            Thread.sleep(5);
-                        } catch (Exception e) {
-                            // ignore
-                        }
-                    }
-                }
-            });
-        }
-
-        assertMockEndpointsSatisfied();
-        executors.shutdownNow();
-    }
-
 }