This is an automated email from the ASF dual-hosted git repository. christophd pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8fdb6c60b1ca0a8e216d6f8b7f6ee61aeaf5b0a8 Author: Christoph Deppisch <[email protected]> AuthorDate: Sun Nov 15 09:09:39 2026 +0100 CAMEL-26918: Address third review round - Fix camel-test-infra version in Exporter.buildDependencyList: use request.camelVersion instead of null for artifacts not in the BOM - Add ExporterTest for buildDependencyList version handling - Add LOG.debug to outer catch block in detectDependenciesFromTestSources - Drop shouldDetectCitrusHttpFromHttpAction (citrus-http is a default) - Move ANALYZER_SUPPORTED_EXTENSIONS constant next to NAME_SEPARATOR_PATTERN Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../core/commands/test/TestPluginExporter.java | 6 +-- .../jbang/core/commands/test/TestPluginTest.java | 27 ------------ .../camel/dsl/jbang/run/export/Exporter.java | 9 +++- .../camel/dsl/jbang/run/export/ExporterTest.java | 49 ++++++++++++++++++++++ 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java b/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java index 24a00f42827f..101399265b0c 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java +++ b/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java @@ -60,6 +60,8 @@ public class TestPluginExporter implements PluginExporter { public static final Pattern NAME_SEPARATOR_PATTERN = Pattern.compile("[-._]([a-z])"); + private static final List<String> ANALYZER_SUPPORTED_EXTENSIONS = List.of("yaml", "yml", "xml", "groovy"); + @Override public boolean isEnabled() { // assume tests are located in a subdirectory, only perform when this directory is present @@ -221,7 +223,7 @@ public class TestPluginExporter implements PluginExporter { } }); } catch (IOException e) { - // ignore if test directory cannot be listed + LOG.debug("Failed to list test directory {}: {}", testDir, e.getMessage()); } return deps; @@ -287,8 +289,6 @@ public class TestPluginExporter implements PluginExporter { return javaClassName; } - private static final List<String> ANALYZER_SUPPORTED_EXTENSIONS = List.of("yaml", "yml", "xml", "groovy"); - private boolean isTestSource(Path path) { String fileName = path.getFileName().toString(); if (fileName.startsWith(".")) { diff --git a/dsl/camel-jbang/camel-jbang-plugin-test/src/test/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginTest.java b/dsl/camel-jbang/camel-jbang-plugin-test/src/test/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginTest.java index d21564a8e335..7321e17e17be 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-test/src/test/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginTest.java +++ b/dsl/camel-jbang/camel-jbang-plugin-test/src/test/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginTest.java @@ -345,33 +345,6 @@ class TestPluginTest { } } - @Test - public void shouldDetectCitrusHttpFromHttpAction() throws IOException { - Path testDir = Path.of(".").resolve("test"); - Files.createDirectories(testDir); - Path yamlFile = testDir.resolve("http-test.citrus.it.yaml"); - try { - Files.writeString(yamlFile, """ - name: http-test - actions: - - http: - client: "http://localhost:8080" - sendRequest: - POST: - path: "/orders" - """); - - TestPluginExporter exporter = new TestPluginExporter(); - Set<String> deps = exporter.getDependencies(RuntimeType.quarkus); - - Assertions.assertTrue(deps.contains("mvn@test:org.citrusframework:citrus-http:${citrus.version}"), - "Should include citrus-http when http action is used"); - } finally { - Files.deleteIfExists(yamlFile); - Files.deleteIfExists(testDir); - } - } - @Test public void shouldKeepVersionForCamelTestInfraArtifacts() throws IOException { Path testDir = Path.of(".").resolve("test"); diff --git a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java index 75139fcb4bad..0e1788050e2b 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java +++ b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java @@ -207,8 +207,13 @@ abstract class Exporter { MavenGav gav = parseMavenGav(dep); String gid = gav.getGroupId(); if ("org.apache.camel".equals(gid)) { - // uses BOM so version should not be included - gav.setVersion(null); + if (gav.getArtifactId() != null && gav.getArtifactId().startsWith("camel-test-infra-")) { + // camel-test-infra-* is not managed by the BOM, use Camel version + gav.setVersion(request.camelVersion); + } else { + // uses BOM so version should not be included + gav.setVersion(null); + } } gavs.add(gav); } diff --git a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ExporterTest.java b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ExporterTest.java index 03c613f04ce2..e3485670c3db 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ExporterTest.java +++ b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ExporterTest.java @@ -16,6 +16,10 @@ */ package org.apache.camel.dsl.jbang.run.export; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -46,4 +50,49 @@ class ExporterTest { assertThat(Exporter.getScheme("c:/certs/keystore.jks")).isNull(); assertThat(Exporter.getScheme("route.camel.yaml")).isNull(); } + + @Test + public void shouldKeepVersionForCamelTestInfraInBuildDependencyList() { + ExportRequest request = new ExportRequest(); + request.camelVersion = "4.24.0"; + + TestableExporter exporter = new TestableExporter(request); + List<Map<String, Object>> deps = exporter.buildDependencyList( + Set.of("mvn@test:org.apache.camel:camel-test-infra-kafka:4.23.0")); + + assertThat(deps).hasSize(1); + Map<String, Object> dep = deps.get(0); + assertThat(dep) + .containsEntry("groupId", "org.apache.camel") + .containsEntry("artifactId", "camel-test-infra-kafka") + .containsEntry("version", "4.24.0"); + } + + @Test + public void shouldStripVersionForRegularCamelDependencies() { + ExportRequest request = new ExportRequest(); + request.camelVersion = "4.24.0"; + + TestableExporter exporter = new TestableExporter(request); + List<Map<String, Object>> deps = exporter.buildDependencyList( + Set.of("mvn@test:org.apache.camel:camel-kafka")); + + assertThat(deps).hasSize(1); + Map<String, Object> dep = deps.get(0); + assertThat(dep) + .containsEntry("groupId", "org.apache.camel") + .containsEntry("artifactId", "camel-kafka") + .containsEntry("version", null); + } + + private static class TestableExporter extends Exporter { + TestableExporter(ExportRequest request) { + super(request, new ExportContext()); + } + + @Override + public Integer export() { + return 0; + } + } }
