This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 cd6ea67a3bef CAMEL-27767: camel-jbang spring-boot export - use
camel-test-spring-junit5 for camel-spring-boot-bom < 4.19.0 (#31127)
cd6ea67a3bef is described below
commit cd6ea67a3bef0c8250ceca13b5e188fa10e8a241
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Dec 1 21:18:21 2026 +0100
CAMEL-27767: camel-jbang spring-boot export - use camel-test-spring-junit5
for camel-spring-boot-bom < 4.19.0 (#31127)
AI-assisted by Hermès on behalf of gnodet.
Co-authored-by: Hermès on behalf of gnodet
---
.../camel/dsl/jbang/core/commands/ExportTest.java | 51 ++++++++++++++++++++++
.../dsl/jbang/core/common/TemplateHelperTest.java | 2 +
.../expected/maven-spring-boot-sanitizer.maven.txt | 2 +-
.../golden/expected/maven-spring-boot.maven.txt | 2 +-
.../dsl/jbang/run/export/SpringBootExporter.java | 13 +++++-
.../templates/spring-boot-kubernetes-pom.ftl | 2 +-
.../main/resources/templates/spring-boot-pom.ftl | 2 +-
7 files changed, 68 insertions(+), 6 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index d269fb39865a..76af5ce2cbcb 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -404,6 +404,57 @@ class ExportTest extends ExportBaseTestSupport {
Assertions.assertTrue(new File(workingDir, "AGENTS.md").exists(),
"Missing AGENTS.md");
}
+ @Test
+ void shouldExportSpringBootOlderVersionUsesJUnit5Artifact() throws
Exception {
+ // CAMEL-27767: with --camel-spring-boot-version < 4.19.0, the
generated pom must use
+ // camel-test-spring-junit5 (managed by the BOM) instead of
camel-test-spring-junit6.
+ Export command = createCommand(RuntimeType.springBoot,
+ new String[] { "classpath:route.yaml" },
+ "--gav=examples:route:1.0.0",
+ "--camel-version=" + RELEASED_CAMEL_VERSION,
+ "--spring-boot-version=3.5.0",
+ "--camel-spring-boot-version=4.18.1",
+ "--dir=" + workingDir, "--quiet");
+ int exit = command.doCall();
+
+ Assertions.assertEquals(0, exit);
+ Model model = readMavenModel();
+ assertThat(model.getDependencies())
+ .as("camel-test-spring-junit5 must be used for
camel-spring-boot-bom < 4.19.0")
+ .anySatisfy(dep -> {
+ assertThat(dep.getGroupId()).isEqualTo("org.apache.camel");
+
assertThat(dep.getArtifactId()).isEqualTo("camel-test-spring-junit5");
+ assertThat(dep.getVersion())
+ .as("version must be managed by BOM (no explicit
version)")
+ .isNull();
+ });
+ }
+
+ @Test
+ void shouldExportSpringBootNewerVersionUsesJUnit6Artifact() throws
Exception {
+ // CAMEL-27767: with --camel-spring-boot-version >= 4.19.0, the
generated pom must use
+ // camel-test-spring-junit6 (managed by the BOM).
+ Export command = createCommand(RuntimeType.springBoot,
+ new String[] { "classpath:route.yaml" },
+ "--gav=examples:route:1.0.0",
+ "--camel-version=" + RELEASED_CAMEL_VERSION,
+ "--camel-spring-boot-version=4.19.0",
+ "--dir=" + workingDir, "--quiet");
+ int exit = command.doCall();
+
+ Assertions.assertEquals(0, exit);
+ Model model = readMavenModel();
+ assertThat(model.getDependencies())
+ .as("camel-test-spring-junit6 must be used for
camel-spring-boot-bom >= 4.19.0")
+ .anySatisfy(dep -> {
+ assertThat(dep.getGroupId()).isEqualTo("org.apache.camel");
+
assertThat(dep.getArtifactId()).isEqualTo("camel-test-spring-junit6");
+ assertThat(dep.getVersion())
+ .as("version must be managed by BOM (no explicit
version)")
+ .isNull();
+ });
+ }
+
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldExportFromDir(RuntimeType rt) throws Exception {
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/common/TemplateHelperTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/common/TemplateHelperTest.java
index d8cf27f53fcd..d09b2d850ede 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/common/TemplateHelperTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/common/TemplateHelperTest.java
@@ -334,6 +334,7 @@ class TemplateHelperTest {
model.put("SpringBootVersion", "3.4.0");
model.put("JavaVersion", "21");
model.put("CamelSpringBootVersion", "4.10.0");
+ model.put("CamelTestSpringArtifactId", "camel-test-spring-junit6");
model.put("ProjectBuildOutputTimestamp", "2024-01-01T00:00:00Z");
model.put("BuildProperties", "");
model.put("Repositories", List.of());
@@ -577,6 +578,7 @@ class TemplateHelperTest {
model.put("SpringBootVersion", "3.5.0");
model.put("SpringBootWebStarter", "spring-boot-starter-web");
model.put("CamelSpringBootVersion", "4.18.1");
+ model.put("CamelTestSpringArtifactId", "camel-test-spring-junit5");
model.put("JavaVersion", "21");
model.put("ProjectBuildOutputTimestamp", "2024-01-01T00:00:00Z");
model.put("BuildProperties", "");
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot-sanitizer.maven.txt
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot-sanitizer.maven.txt
index 5ee3627afa8d..e84510f104d5 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot-sanitizer.maven.txt
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot-sanitizer.maven.txt
@@ -35,7 +35,7 @@ dependency org.apache.camel.springboot:camel-timer-starter
dependency org.apache.camel.springboot:camel-yaml-dsl-starter
dependency org.apache.camel:camel-sanitizer
dependency org.springframework.boot:spring-boot-starter-test (test)
-dependency org.apache.camel:camel-test-spring-junit6 (test)
+dependency org.apache.camel:camel-test-spring-junit5 (test)
plugin org.springframework.boot:spring-boot-maven-plugin
# application.properties
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot.maven.txt
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot.maven.txt
index eeedf3e9dbad..c6385eb11979 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot.maven.txt
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-spring-boot.maven.txt
@@ -33,7 +33,7 @@ dependency org.apache.camel.springboot:camel-log-starter
dependency org.apache.camel.springboot:camel-timer-starter
dependency org.apache.camel.springboot:camel-yaml-dsl-starter
dependency org.springframework.boot:spring-boot-starter-test (test)
-dependency org.apache.camel:camel-test-spring-junit6 (test)
+dependency org.apache.camel:camel-test-spring-junit5 (test)
plugin org.springframework.boot:spring-boot-maven-plugin
# application.properties
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
index a9515c23abd5..37152a3001f2 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
@@ -331,8 +331,17 @@ class SpringBootExporter extends Exporter {
: "spring-boot-starter-web");
model.put("SpringBootVersion", request.springBootVersion);
model.put("JavaVersion", request.javaVersion);
- model.put("CamelSpringBootVersion",
- Objects.requireNonNullElseGet(request.camelSpringBootVersion,
() -> request.camelVersion));
+ // CamelVersion is not referenced by the built-in spring-boot-*.ftl
templates (which pin
+ // the version via CamelSpringBootVersion on the BOM import), but is
exposed here for
+ // custom pomTemplateName templates that may need it.
+ model.put("CamelVersion", request.camelVersion);
+ String csbVersion
+ =
Objects.requireNonNullElseGet(request.camelSpringBootVersion, () ->
request.camelVersion);
+ model.put("CamelSpringBootVersion", csbVersion);
+ // camel-test-spring-junit6 was not managed by camel-spring-boot-bom
before 4.19.0;
+ // use camel-test-spring-junit5 for older versions so the BOM can
manage the version.
+ model.put("CamelTestSpringArtifactId",
+ VersionHelper.isGE(csbVersion, "4.19.0") ?
"camel-test-spring-junit6" : "camel-test-spring-junit5");
model.put("ProjectBuildOutputTimestamp",
this.getBuildMavenProjectDate());
model.put("BuildProperties", formatBuildProperties());
model.put("Repositories", buildRepositoryList(repos));
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-kubernetes-pom.ftl
b/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-kubernetes-pom.ftl
index 56750286c2e0..68f5d871a345 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-kubernetes-pom.ftl
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-kubernetes-pom.ftl
@@ -157,7 +157,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring-junit6</artifactId>
+ <artifactId>[=CamelTestSpringArtifactId]</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-pom.ftl
b/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-pom.ftl
index 095a9bd12c1b..4111cb696aef 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-pom.ftl
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/resources/templates/spring-boot-pom.ftl
@@ -158,7 +158,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring-junit6</artifactId>
+ <artifactId>[=CamelTestSpringArtifactId]</artifactId>
<scope>test</scope>
</dependency>
</dependencies>