Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<String> 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);
Expand All @@ -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<String> 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);
Expand All @@ -183,20 +202,42 @@ 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);
}
command.files = Arrays.asList(files);
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<String> 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);
Expand Down Expand Up @@ -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<String> 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);
Expand Down Expand Up @@ -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<String> 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);
Expand Down Expand Up @@ -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<String> 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);
Expand Down Expand Up @@ -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<String> 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);
Expand Down