gnodet-bot commented on code in PR #29159:
URL: https://github.com/apache/camel/pull/29159#discussion_r4466523776
##########
dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/JBangRunnerTest.java:
##########
@@ -252,6 +252,24 @@ void
routesAreExpectedUnlessFilesCanBeAddedOrNoneAreWanted() {
assertThat(integration(main, empty).hasNoRoutes()).isFalse();
}
+ @Test
+ void aKameletYamlFileWithARouteTemplateIsNotTreatedAsEmpty() throws
Exception {
+ // CAMEL-26526: KameletRoutesBuilderLoader creates a route template,
not a route; hasNoRoutes() must not
+ // shut down when route templates are present (the kamelet file is
valid, it just has no instantiated routes)
+ DefaultCamelContext camelContext = new DefaultCamelContext();
+ camelContext.start();
+ RouteTemplateDefinition rtd = new RouteTemplateDefinition();
+ rtd.id("user-source");
+ camelContext.addRouteTemplateDefinitions(List.of(rtd));
+
+ KameletMain main = mock(KameletMain.class);
+ when(main.getCamelContext()).thenReturn(camelContext);
+
+ assertThat(integration(main, new
RunRequest()).hasNoRoutes()).isFalse();
+
+ camelContext.stop();
Review Comment:
💡 **Suggestion:** Wrap the assertion in a try-finally so
`camelContext.stop()` is called even if the assertion fails — prevents
lingering context in test failure scenarios.
```suggestion
assertThat(integration(main, new
RunRequest()).hasNoRoutes()).isFalse();
camelContext.stop();
```
--
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]