gnodet-bot commented on code in PR #28001:
URL: https://github.com/apache/camel/pull/28001#discussion_r4302213987
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/IntegrationLauncherTest.java:
##########
@@ -101,6 +101,50 @@ void failureOutputKeepsTheCauseNotTheFrames(@TempDir Path
dir) throws Exception
assertThat(text.indexOf("is
starting")).isLessThan(text.indexOf("Failed to create route"));
}
+ @Test
+ void failureCauseIsTheErrorCamelRunPrintsAsItExits(@TempDir Path dir)
throws Exception {
+ // the console of camel run with a copy of the route in beans.yaml,
next to the route file
+ String duplicate = "Failed to create route because: Duplicate route
ids detected: order-generator. Please correct"
+ + " ids to be unique among all your routes.";
+ StringBuilder out = new StringBuilder();
+ out.append("Running integration with the following configuration:\n
--kamelets-version=4.22.1\n");
+ out.append("2026-10-17 11:03:43.201 INFO 81710 --- [ main]
org.apache.camel.main.MainSupport :"
+ + " Apache Camel (JBang) 4.24.0-SNAPSHOT is starting\n");
+ out.append("2026-10-17 11:03:43.640 WARN 81710 --- [ main]
sl.yaml.common.YamlDeserializerBase :"
+ + " YAML DSL compact notation detected in:
file:./beans.yaml\n");
+ out.append("2026-10-17 11:03:43.652 ERROR 81710 --- [ main]
org.apache.camel.main.MainSupport :"
+ + " Error starting Camel:
org.apache.camel.FailedToCreateRouteException: " + duplicate + "\n");
+ out.append("org.apache.camel.FailedToCreateRouteException:
").append(duplicate).append('\n');
+ out.append("\tat
org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes(RoutesConfigurer.java:385)\n");
+ out.append("\tat main.CamelJBang.main(CamelJBang.java:38)\n");
+ out.append("ERROR: ").append(duplicate).append('\n');
+ out.append("org.apache.camel.FailedToCreateRouteException:
").append(duplicate).append('\n');
+ out.append("\tat
org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes(RoutesConfigurer.java:385)\n");
+ Path output = dir.resolve("camel-launch.log");
+ Files.writeString(output, out.toString());
+
+
assertThat(IntegrationLauncher.failureCause(output)).isEqualTo(duplicate);
+ }
+
+ @Test
+ void failureCauseWithoutTheErrorLineIsTheFirstLoggedException(@TempDir
Path dir) throws Exception {
+ Path output = dir.resolve("camel-launch.log");
+ Files.writeString(output, "2026-10-06 01:12:03.101 INFO 81990 --- [
main] o.a.c.main.MainSupport :"
+ + " Apache Camel (JBang) 4.24.0-SNAPSHOT is
starting\n"
+ + "2026-10-06 01:12:04.552 ERROR 81990 --- [
main] o.a.c.main.MainSupport :"
+ + " Failed to create route:
order-generator\n"
+ +
"org.apache.camel.FailedToCreateRouteException: Failed to create route:
order-generator"
+ + " because of No bean could be found in the
registry for: orderNumber\n"
+ + "\tat
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:1)\n");
+ assertThat(IntegrationLauncher.failureCause(output))
+ .isEqualTo("Failed to create route: order-generator because of
No bean could be found in the registry for:"
+ + " orderNumber");
+
+ // nothing that names an error: no cause, the output says what it says
+ Files.writeString(output, "Downloading dependency
org.example:missing:1.0\n");
+ assertThat(IntegrationLauncher.failureCause(output)).isNull();
+ }
Review Comment:
🧪 **Missing test: `failureCause` fallback path (ERROR line without a
following exception)**
The `failureCauseWithoutTheErrorLineIsTheFirstLoggedException` test only
covers the case where an `EXCEPTION_LINE` (e.g.
`org.apache.camel.FailedToCreateRouteException: …`) immediately follows the
ERROR log line. But `IntegrationLauncher.failureCause` has a second path: if no
exception line is found within the next 5 lines, it falls back to extracting
the message from the ERROR line itself via `" : "` split.
That fallback is never exercised. Consider adding a case such as:
```java
// ERROR line with no following exception within 5 lines — fallback to " : "
split
Files.writeString(output,
"2026-10-06 01:12:04.552 ERROR 81990 --- [main] o.a.c.main.MainSupport :
Route start failed due to missing bean\n"
+ " at some.Frame(Frame.java:1)\n");
assertThat(IntegrationLauncher.failureCause(output))
.isEqualTo("Route start failed due to missing bean");
```
Low severity — the production logic is correct, just the test doesn't verify
this branch.
--
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]