This is an automated email from the ASF dual-hosted git repository.
Croway 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 7ec7f2a79a00 CAMEL-27237: camel-jbang - export to camel-main adds
camel-health when it turns on the health check
7ec7f2a79a00 is described below
commit 7ec7f2a79a0042bdfe001d78499632d19c9bb49d
Author: croway <[email protected]>
AuthorDate: Thu Nov 19 11:45:26 2026 +0100
CAMEL-27237: camel-jbang - export to camel-main adds camel-health when it
turns on the health check
The export of a platform-http or rest route to camel-main turns on the
embedded HTTP server and its health check in the exported
application.properties, but the dependencies were resolved before, from
the application.properties given to the export, so the exported
application failed at startup without camel-health.
---
.../jbang/core/commands/ExportDependencyTest.java | 29 ++++++++++++++++++++++
.../resources/golden/expected/openapi.export.txt | 1 +
.../dsl/jbang/run/export/CamelMainExporter.java | 5 ++++
3 files changed, 35 insertions(+)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportDependencyTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportDependencyTest.java
index bfba59056baa..3bea3d948a85 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportDependencyTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportDependencyTest.java
@@ -31,6 +31,7 @@ import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -580,4 +581,32 @@ class ExportDependencyTest extends ExportBaseTestSupport {
.doesNotContain("camel-platform-http",
"camel-platform-http-vertx");
assertEachArtifactOnce(model);
}
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ "camel.main.name=platform-http-demo\n",
+
"camel.main.name=platform-http-demo\ncamel.management.health-check-enabled=true\n"
})
+ void shouldAddCamelHealthWhenTheHealthCheckIsOn(String
applicationProperties) throws Exception {
+ LOG.info("shouldAddCamelHealthWhenTheHealthCheckIsOn");
+ // platform-http turns on the embedded HTTP server and its health
check in the exported application.properties,
+ // and the management server does not start without camel-health,
whether the export or the
+ // application.properties turned the health check on
+ Path baseDir = baseDirWithApplicationProperties(applicationProperties);
+
+ Export command = new Export(new CamelJBangMain());
+ command.exportBaseDir = baseDir;
+ CommandLineTestHelper.parse(command,
+ "--gav=examples:route:1.0.0", "--dir=" + workingDir, "--quiet",
+ "--runtime=camel-main",
+ "--dep=camel-platform-http",
+ "src/test/resources/route.yaml");
+ int exit = command.doCall();
+
+ assertThat(exit).isEqualTo(0);
+ Properties props = loadExportedProperties("application.properties");
+ assertThat(exportedProperty(props,
"camel.management.health-check-enabled")).isEqualTo("true");
+ Model model = readMavenModel();
+
assertThat(model.getDependencies()).extracting(Dependency::getArtifactId).contains("camel-health");
+ assertEachArtifactOnce(model);
+ }
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/openapi.export.txt
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/openapi.export.txt
index d7e1d134838f..15e290e0e03b 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/openapi.export.txt
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/openapi.export.txt
@@ -49,6 +49,7 @@ org.example.golden:openapi:1.0.0
properties: [java.version, project.build.outputTimestamp]
dependency org.apache.camel:camel-main
dependency org.apache.camel:camel-direct
+dependency org.apache.camel:camel-health
dependency org.apache.camel:camel-http
dependency org.apache.camel:camel-jackson3
dependency org.apache.camel:camel-openapi-java
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
index 5cd8151e755e..9f3f1680ca56 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
@@ -157,6 +157,11 @@ class CamelMainExporter extends Exporter {
// old option name for Camel 4.13 and older
prop.put("camel.server.health-check-enabled",
"true");
}
+ // the health check does not start without
camel-health, and the dependencies were
+ // resolved from the application.properties before
this added it
+ if (!hasCamelArtifact(deps, "camel-health")) {
+ deps.add("camel:health");
+ }
}
}
port = ExportHelper.httpManagementPort(settings);