gnodet-bot commented on code in PR #28147:
URL: https://github.com/apache/camel/pull/28147#discussion_r4336920579


##########
core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultSupervisingRouteControllerMulticastSplitTest.java:
##########
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.engine;
+
+import java.time.Duration;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.SupervisingRouteController;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.support.DefaultConsumer;
+import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.support.DefaultProducer;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests that Split and Multicast EIPs do not start child producers during 
doInit(), which would bypass the
+ * SupervisingRouteController retry logic and fail the entire context when a 
producer cannot connect yet.
+ * <p>
+ * CAMEL-25823: Split and Multicast start their child producers before 
CamelContext starts, so with the supervising
+ * route controller a producer that cannot start yet fails the whole context.
+ */
+class DefaultSupervisingRouteControllerMulticastSplitTest extends 
ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        SupervisingRouteController src = 
context.getRouteController().supervising();
+        src.setBackOffDelay(25);
+        src.setBackOffMaxAttempts(10);
+        src.setInitialDelay(10);
+        src.setThreadPoolSize(2);
+        return context;
+    }
+
+    @Test
+    void testSplitWithFlakyProducer() throws Exception {
+        FlakyComponent component = new FlakyComponent(2);
+        context.addComponent("flaky", component);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:split")
+                        .routeId("split-route")
+                        .split(body())
+                        .to("flaky:target");
+            }
+        });
+
+        // Must not throw - supervising route controller should retry
+        context.start();
+
+        // Route should eventually reach Started state after retries
+        await().atMost(Duration.ofSeconds(5))
+                .untilAsserted(() -> assertEquals(ServiceStatus.Started,
+                        
context.getRouteController().getRouteStatus("split-route")));
+
+        // Verify the producer was retried (failCount=2 means 3 start attempts 
total)
+        FlakyEndpoint endpoint = (FlakyEndpoint) 
context.getEndpoint("flaky:target");
+        assertEquals(3, endpoint.startAttempts.get(), "Expected 3 start 
attempts (2 failures + 1 success)");
+
+        // Verify that a message can actually be processed once the route is 
started
+        template.sendBody("direct:split", "a b c");

Review Comment:
   ⚠️ **Test bug: wrong delimiter — `processCount` assertion will fail**
   
   `split(body())` uses comma (`,`) as the default delimiter 
(`ObjectHelper.DEFAULT_DELIMITER = ","`). The body `"a b c"` contains no 
commas, so `ObjectHelper.createIterable()` returns a **singleton** — the entire 
string is treated as one token. `processCount` will be `1`, not `3`, and the 
`assertEquals` will fail even with the fix applied.
   
   ```suggestion
           template.sendBody("direct:split", "a,b,c");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to