diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java index 09282e747e3f8..bcf23f29c42a0 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java +++ b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java @@ -71,6 +71,7 @@ private void checkOneDependencyAddedForArangoDb(RuntimeType rt) throws Exception DependencyUpdate command = new DependencyUpdate(new CamelJBangMain().withPrinter(secondUpdateCommandPrinter)); CommandLine.populateCommand(command, "--dir=" + workingDir, + "--camel-version=4.13.0", CamelCommandBaseTestSupport.quarkusExtRegistry(), new File(workingDir, "pom.xml").getAbsolutePath()); int exit = command.doCall(); @@ -146,6 +147,7 @@ void shouldScanRoutesAddDependency(RuntimeType rt) throws Exception { DependencyUpdate command = new DependencyUpdate(new CamelJBangMain().withPrinter(updatePrinter)); CommandLine.populateCommand(command, "--scan-routes", + "--camel-version=4.13.0", "--dir=" + workingDir, new File(workingDir, "pom.xml").getAbsolutePath()); int exit = command.doCall(); 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 0edbb342b0685..ca623d5cdbab3 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 @@ -21,6 +21,7 @@ import java.io.FileReader; import java.io.IOException; import java.nio.file.Files; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -53,6 +54,12 @@ class ExportTest { private static final Logger LOG = LoggerFactory.getLogger(ExportTest.class); + // Use a released Camel version for Spring Boot tests because the Spring Boot catalog provider + // (camel-catalog-provider-springboot) comes from the separate camel-spring-boot project. + // Its SNAPSHOT may not be deployed to Apache Snapshots, causing flaky CI failures. + // Released versions are always available on Maven Central. + private static final String RELEASED_CAMEL_VERSION = "4.13.0"; + private File workingDir; @BeforeEach @@ -139,8 +146,14 @@ public void shouldExportDifferentVersion(RuntimeType rt) throws Exception { public void shouldGenerateProjectWithBuildProperties(RuntimeType rt) throws Exception { LOG.info("shouldGenerateProjectWithBuildProperties {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "--build-property=foo=bar", "target/test-classes/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()), "--build-property=foo=bar")); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("target/test-classes/route.yaml"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -157,11 +170,17 @@ public void shouldGenerateProjectWithBuildProperties(RuntimeType rt) throws Exce public void testShouldGenerateProjectMultivalue(RuntimeType rt) throws Exception { LOG.info("testShouldGenerateProjectMultivalue {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "--dep=foo:bar:1.0,jupiter:rocks:2.0", - // it's important for the --build-property to be the last parameter to test a previous - // export error when this property had arity=* - "--build-property=foo=bar", "--build-property=camel=rocks", "target/test-classes/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()), "--dep=foo:bar:1.0,jupiter:rocks:2.0")); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + // it's important for the --build-property to be the last parameter to test a previous + // export error when this property had arity=* + cmdArgs.addAll(List.of("--build-property=foo=bar", "--build-property=camel=rocks", + "target/test-classes/route.yaml")); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -183,6 +202,10 @@ private Export createCommand(RuntimeType rt, String[] files, String... args) { CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, "--quiet", "--runtime=%s".formatted(rt.runtime()), CamelCommandBaseTestSupport.quarkusExtRegistry()); + // Pin Spring Boot tests to a released version to avoid SNAPSHOT download failures + if (rt == RuntimeType.springBoot && !containsCamelVersion(args)) { + CommandLine.populateCommand(command, "--camel-version=" + RELEASED_CAMEL_VERSION); + } if (args != null) { CommandLine.populateCommand(command, args); } @@ -190,13 +213,31 @@ private Export createCommand(RuntimeType rt, String[] files, String... args) { return command; } + private static boolean containsCamelVersion(String... args) { + if (args == null) { + return false; + } + for (String arg : args) { + if (arg != null && arg.startsWith("--camel-version=")) { + return true; + } + } + return false; + } + @ParameterizedTest @MethodSource("runtimeProvider") public void shouldExportWithJpaAndHibernate(RuntimeType rt) throws Exception { LOG.info("shouldExportWithJpaAndHibernate {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "--dep=camel:jpa", "target/test-classes/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()), "--dep=camel:jpa")); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("target/test-classes/route.yaml"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -739,8 +780,14 @@ public void shouldExportGroovy(RuntimeType rt) throws Exception { public void shouldExportObserve(RuntimeType rt) throws Exception { LOG.info("shouldExportObserve {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "--observe=true", "target/test-classes/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()), "--observe=true")); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("target/test-classes/route.yaml"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -768,8 +815,14 @@ public void shouldExportObserve(RuntimeType rt) throws Exception { public void shouldExportFromDir(RuntimeType rt) throws Exception { LOG.info("shouldExportFromDir {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "src/test/resources/myapp"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()))); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("src/test/resources/myapp"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -886,8 +939,14 @@ public void shouldOverrideQuarkusVersionFromSystemProperty() throws Exception { public void shouldExportHawtio(RuntimeType rt) throws Exception { LOG.info("shouldExportHawtio {}", rt); Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "--hawtio=true", "target/test-classes/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()), "--hawtio=true")); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("target/test-classes/route.yaml"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit); @@ -932,8 +991,14 @@ public void shouldExportHawtio(RuntimeType rt) throws Exception { @MethodSource("runtimeProvider") public void shouldContainJibProfile(RuntimeType rt) throws Exception { Export command = new Export(new CamelJBangMain()); - CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, - "--runtime=%s".formatted(rt.runtime()), "src/test/resources/route.yaml"); + List cmdArgs = new ArrayList<>( + List.of("--gav=examples:route:1.0.0", "--dir=" + workingDir, + "--runtime=%s".formatted(rt.runtime()))); + if (rt == RuntimeType.springBoot) { + cmdArgs.add("--camel-version=" + RELEASED_CAMEL_VERSION); + } + cmdArgs.add("src/test/resources/route.yaml"); + CommandLine.populateCommand(command, cmdArgs.toArray(String[]::new)); int exit = command.doCall(); Assertions.assertEquals(0, exit);