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 0fb46c3dafad358a5addc771903bb767d63cf026
Author: Christoph Deppisch <[email protected]>
AuthorDate: Sat Nov 14 14:44:53 2026 +0100

    CAMEL-26918: Address review feedback
    
    - Keep version for camel-test-infra-* artifacts (not managed by BOM)
    - Restore citrus-http as default (Java tests cannot be scanned)
    - Filter to analyzer-supported extensions (yaml/yml/xml/groovy)
    - Extract isTestSource() helper to share filter logic
    - Add tests for Camel infra service and endpoint dependency detection
    - Add test verifying camel-test-infra version is preserved
    - Fix backslash check scope in shouldProduceValidMavenPropertyReferences
    - Update camel-jbang-test.adoc to document auto-detection
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../modules/ROOT/pages/camel-jbang-test.adoc       |   7 +-
 .../core/commands/test/TestPluginExporter.java     |  48 +++++----
 .../jbang/core/commands/test/TestPluginTest.java   | 120 ++++++++++++++++++++-
 3 files changed, 153 insertions(+), 22 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-test.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang-test.adoc
index 4aaa144b52dd..aea9281cb34f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-test.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-test.adoc
@@ -54,7 +54,10 @@ TIP: The export creates a JUnit Jupiter test class in 
`src/test/java` that you c
 
 == Dependency management
 
-Basic Citrus dependencies are included out of the box. For additional modules 
(Kafka, Testcontainers, etc.), add them in a `jbang.properties` file next to 
the test source:
+Basic Citrus dependencies are included out of the box.
+Additional Citrus modules (e.g. `citrus-sql`, `citrus-kafka`) and Camel test 
infrastructure dependencies (e.g. `camel-test-infra-kafka`) are auto-detected 
from YAML, XML and Groovy test sources during project export.
+
+For Java test sources or dependencies that cannot be auto-detected, add them 
in a `jbang.properties` file next to the test source:
 
 .jbang.properties
 [source,properties]
@@ -68,7 +71,7 @@ org.apache.camel:camel-aws2-s3:4.13.0
 run.D=citrus.camel.jbang.dump.integration.output=true
 ----
 
-TIP: These dependencies are automatically added as test-scoped dependencies 
during project export.
+TIP: Dependencies from `jbang.properties` and auto-detected dependencies are 
both added as test-scoped dependencies during project export.
 
 == Writing tests with Citrus
 
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 609b9cef63ae..3f6280b69b87 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
@@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Locale;
 import java.util.Properties;
 import java.util.Set;
@@ -83,6 +84,7 @@ public class TestPluginExporter implements PluginExporter {
         // add default Citrus dependencies as defined in Citrus JBang
         deps.add(asCitrusDependency("citrus-base"));
         deps.add(asCitrusDependency("citrus-junit-jupiter"));
+        deps.add(asCitrusDependency("citrus-http"));
         deps.add(asCitrusDependency("citrus-yaml"));
         deps.add(asCitrusDependency("citrus-xml"));
         deps.add(asCitrusDependency("citrus-groovy"));
@@ -146,14 +148,8 @@ public class TestPluginExporter implements PluginExporter {
         try (Stream<Path> paths = Files.list(testDir)) {
             // Add all supported test sources
             Set<Path> testSources = paths
-                    .filter(path -> 
!path.getFileName().toString().startsWith("."))
-                    .filter(path -> {
-                        String ext = 
FileUtils.getFileExtension(path.getFileName().toString());
-                        return CitrusSettings.getTestFileNamePattern(ext)
-                                .stream()
-                                .map(Pattern::compile)
-                                .anyMatch(pattern -> 
pattern.matcher(path.getFileName().toString()).matches());
-                    }).collect(Collectors.toSet());
+                    .filter(this::isTestSource)
+                    .collect(Collectors.toSet());
 
             for (Path testSource : testSources) {
                 String ext = 
FileUtils.getFileExtension(testSource.getFileName().toString());
@@ -205,14 +201,8 @@ public class TestPluginExporter implements PluginExporter {
         Set<String> deps = new HashSet<>();
         DelegatingCodeAnalyzer analyzer = new DelegatingCodeAnalyzer();
         try (Stream<Path> paths = Files.list(testDir)) {
-            paths.filter(p -> !p.getFileName().toString().startsWith("."))
-                    .filter(p -> {
-                        String ext = 
FileUtils.getFileExtension(p.getFileName().toString());
-                        return CitrusSettings.getTestFileNamePattern(ext)
-                                .stream()
-                                .map(Pattern::compile)
-                                .anyMatch(pattern -> 
pattern.matcher(p.getFileName().toString()).matches());
-                    })
+            paths.filter(this::isTestSource)
+                    .filter(this::isAnalyzerSupported)
                     .forEach(path -> {
                         try {
                             CodeAnalyzer.ScanResult result = 
analyzer.scan(path);
@@ -222,8 +212,8 @@ public class TestPluginExporter implements PluginExporter {
                             for (String dependency : result.dependencies()) {
                                 deps.add(asScannedDependency(dependency));
                             }
-                        } catch (Exception e) {
-                            // ignore scan errors for unsupported file types 
or missing catalog
+                        } catch (IOException e) {
+                            // ignore scan errors for missing catalog
                         }
                     });
         } catch (IOException e) {
@@ -238,6 +228,9 @@ public class TestPluginExporter implements PluginExporter {
         if (parts[0].equals("org.citrusframework")) {
             return asCitrusDependency(parts[1]);
         } else if (parts[0].startsWith("org.apache.camel")) {
+            if (parts.length > 2 && parts[1].startsWith("camel-test-infra-")) {
+                return asDependency(parts[0], parts[1], parts[2]);
+            }
             return asDependency(parts[0], parts[1]);
         } else {
             return asDependency(dependency);
@@ -287,6 +280,25 @@ 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(".")) {
+            return false;
+        }
+        String ext = FileUtils.getFileExtension(fileName);
+        return CitrusSettings.getTestFileNamePattern(ext)
+                .stream()
+                .map(Pattern::compile)
+                .anyMatch(pattern -> pattern.matcher(fileName).matches());
+    }
+
+    private boolean isAnalyzerSupported(Path path) {
+        String ext = FileUtils.getFileExtension(path.getFileName().toString());
+        return ANALYZER_SUPPORTED_EXTENSIONS.contains(ext);
+    }
+
     private String extractArtifactId(String dependency) {
         return dependency.split(":")[1];
     }
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 c248f1d0b1d0..d21564a8e335 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
@@ -143,6 +143,8 @@ class TestPluginTest {
                     "Should always include citrus-base as default dependency");
             
Assertions.assertTrue(deps.contains("mvn@test:org.citrusframework:citrus-junit-jupiter:${citrus.version}"),
                     "Should always include citrus-junit-jupiter as default 
dependency");
+            
Assertions.assertTrue(deps.contains("mvn@test:org.citrusframework:citrus-http:${citrus.version}"),
+                    "Should always include citrus-http as default dependency");
             
Assertions.assertTrue(deps.contains("mvn@test:org.citrusframework:citrus-yaml:${citrus.version}"),
                     "Should always include citrus-yaml as default dependency");
             
Assertions.assertTrue(deps.contains("mvn@test:org.citrusframework:citrus-xml:${citrus.version}"),
@@ -175,9 +177,9 @@ class TestPluginTest {
             
Assertions.assertFalse(deps.contains("mvn@test:org.citrusframework:citrus-junit5:${citrus.version}"),
                     "Should not include legacy citrus-junit5 dependency");
             for (String dep : deps) {
+                Assertions.assertFalse(dep.contains("\\"),
+                        "Dependency should not contain backslash escapes: " + 
dep);
                 if (dep.contains("org.citrusframework")) {
-                    Assertions.assertFalse(dep.contains("\\"),
-                            "Dependency should not contain backslash escapes: 
" + dep);
                     Assertions.assertTrue(dep.contains("${citrus.version}"),
                             "Dependency should contain valid Maven property 
reference: " + dep);
                 }
@@ -289,6 +291,120 @@ class TestPluginTest {
         }
     }
 
+    @Test
+    public void shouldDetectCamelInfraServiceDependencies() throws IOException 
{
+        Path testDir = Path.of(".").resolve("test");
+        Files.createDirectories(testDir);
+        Path yamlFile = testDir.resolve("infra-test.citrus.it.yaml");
+        try {
+            Files.writeString(yamlFile, """
+                    name: infra-test
+                    actions:
+                      - camel:
+                          infra:
+                            run:
+                              service: kafka
+                      - echo:
+                          message: "Hello"
+                    """);
+
+            TestPluginExporter exporter = new TestPluginExporter();
+            Set<String> deps = exporter.getDependencies(RuntimeType.quarkus);
+
+            Assertions.assertTrue(
+                    deps.stream().anyMatch(d -> 
d.startsWith("mvn@test:org.apache.camel:camel-test-infra-kafka:")),
+                    "Should auto-detect camel-test-infra-kafka from camel 
infra service action");
+        } finally {
+            Files.deleteIfExists(yamlFile);
+            Files.deleteIfExists(testDir);
+        }
+    }
+
+    @Test
+    public void shouldDetectCamelEndpointDependencies() throws IOException {
+        Path testDir = Path.of(".").resolve("test");
+        Files.createDirectories(testDir);
+        Path yamlFile = testDir.resolve("camel-endpoint-test.citrus.it.yaml");
+        try {
+            Files.writeString(yamlFile, """
+                    name: camel-endpoint-test
+                    actions:
+                      - send:
+                          endpoint: "camel:kafka:myTopic"
+                    """);
+
+            TestPluginExporter exporter = new TestPluginExporter();
+            Set<String> deps = exporter.getDependencies(RuntimeType.quarkus);
+
+            Assertions.assertTrue(
+                    deps.stream().anyMatch(d -> 
d.startsWith("mvn@test:org.apache.camel:camel-kafka")),
+                    "Should auto-detect camel-kafka from camel endpoint URI");
+        } finally {
+            Files.deleteIfExists(yamlFile);
+            Files.deleteIfExists(testDir);
+        }
+    }
+
+    @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");
+        Files.createDirectories(testDir);
+        Path yamlFile = testDir.resolve("infra-version-test.citrus.it.yaml");
+        try {
+            Files.writeString(yamlFile, """
+                    name: infra-version-test
+                    actions:
+                      - camel:
+                          infra:
+                            run:
+                              service: kafka
+                    """);
+
+            TestPluginExporter exporter = new TestPluginExporter();
+            Set<String> deps = exporter.getDependencies(RuntimeType.quarkus);
+
+            String infraDep = deps.stream()
+                    .filter(d -> d.contains("camel-test-infra-kafka"))
+                    .findFirst()
+                    .orElse(null);
+            Assertions.assertNotNull(infraDep, "Should contain 
camel-test-infra-kafka dependency");
+
+            String[] parts = infraDep.split(":");
+            Assertions.assertEquals(4, parts.length,
+                    "camel-test-infra dependency should include version (4 
colon-separated parts): " + infraDep);
+        } finally {
+            Files.deleteIfExists(yamlFile);
+            Files.deleteIfExists(testDir);
+        }
+    }
+
     /**
      * Creates CamelJBangMain instance ready for unit testing. Automatically 
adds test plugin commands. Automatically
      * sets the out printer.

Reply via email to