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 d5bc326b165d chore: update Citrus to 5.2.1 (#31059)
d5bc326b165d is described below

commit d5bc326b165d1530fdecd1511a277bf28423d127
Author: Christoph Deppisch <[email protected]>
AuthorDate: Sat Nov 28 08:56:15 2026 +0100

    chore: update Citrus to 5.2.1 (#31059)
    
    - Update Citrus dependency from 5.2.0 to 5.2.1
    - Remove --force workaround in TestInit (now handled upstream)
    - Add --clear option to test run docs
    - Update generated command metadata and test assertions
    - CitrusTestChecks: Citrus 5.2.1 test schema has configuration and a oneOf 
for http
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../jbang-commands/camel-jbang-test-init.adoc      |  1 +
 .../pages/jbang-commands/camel-jbang-test-run.adoc |  1 +
 .../jbang/core/commands/ai/CitrusTestChecks.java   | 14 +++++
 .../core/commands/ai/CitrusTestChecksTest.java     |  5 +-
 .../camel-jbang-plugin-commands-metadata.json      |  2 +-
 .../dsl/jbang/core/commands/test/TestInit.java     | 63 +---------------------
 .../jbang/core/commands/test/TestPluginTest.java   |  2 +-
 parent/pom.xml                                     |  2 +-
 8 files changed, 24 insertions(+), 66 deletions(-)

diff --git 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-init.adoc 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-init.adoc
index f9523e00eaec..d4c8beced1a6 100644
--- 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-init.adoc
+++ 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-init.adoc
@@ -22,6 +22,7 @@ camel test init [options]
 |===
 | Option | Description | Default | Type
 | `--directory` | Directory where the files will be created | . | String
+| `--force` | Overwrite existing files | false | boolean
 | `-h,--help` | Display this help and exit |  | boolean
 |===
 
diff --git 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-run.adoc 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-run.adoc
index 2b910da3a1a6..ad2222bf645e 100644
--- 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-run.adoc
+++ 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-run.adoc
@@ -21,6 +21,7 @@ camel test run [options]
 [cols="2,5,1,2",options="header"]
 |===
 | Option | Description | Default | Type
+| `--clear` | Remove the working directory before the test run | false | 
boolean
 | `--dep,--dependency` | Comma delimited list of additional Maven GAV 
dependencies that must be loaded to run the test. |  | List
 | `--engine` | Name of the test engine that is used to run tests. One of 
junit, junit-jupiter, junit4, testng, cucumber |  | String
 | `--includes` | Includes test name pattern. |  | List
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecks.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecks.java
index 5931f0938003..fb019f2d1d6e 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecks.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecks.java
@@ -619,6 +619,12 @@ public final class CitrusTestChecks {
             List<Error> all = List.copyOf(errors);
             errors.removeIf(e -> isComposition(e)
                     && all.stream().anyMatch(o -> 
location(o).startsWith(location(e) + "/")));
+            // a value of the wrong type fails the object and each branch of 
it (http: in a oneOf of sendRequest,
+            // receiveResponse... since Citrus 5.2.1): the type error of the 
object says it with all its keys
+            List<Error> types = List.copyOf(errors);
+            errors.removeIf(e -> "type".equals(e.getKeyword())
+                    && types.stream().anyMatch(o -> o != e && 
"type".equals(o.getKeyword())
+                            && location(o).equals(location(e)) && 
isBranchOf(e, o)));
             Map<String, List<Error>> unknown = new LinkedHashMap<>();
             for (Error e : errors) {
                 if ("additionalProperties".equals(e.getKeyword()) && 
e.getProperty() != null) {
@@ -1399,6 +1405,14 @@ public final class CitrusTestChecks {
         return "oneOf".equals(e.getKeyword()) || 
"anyOf".equals(e.getKeyword());
     }
 
+    /** Whether the schema of an error is in a branch of the schema of another 
error (both of the keyword type). */
+    private static boolean isBranchOf(Error branch, Error outer) {
+        String b = String.valueOf(branch.getSchemaLocation());
+        String o = String.valueOf(outer.getSchemaLocation());
+        String base = o.endsWith("/type") ? o.substring(0, o.length() - 
"/type".length()) : o;
+        return b.length() > o.length() && b.startsWith(base + "/");
+    }
+
     /** The instance location of an error as a pointer, "" for the root. */
     private static String location(Error e) {
         String at = e.getInstanceLocation() != null ? 
e.getInstanceLocation().toString() : "";
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecksTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecksTest.java
index f9f5184bc5b2..d69b375bc690 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecksTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CitrusTestChecksTest.java
@@ -691,7 +691,8 @@ class CitrusTestChecksTest {
                     from:
                       uri: timer:tick
                 """)).containsExactly("Line 1: array found, object expected: a 
Citrus test is a map with the keys"
-                                      + " actions, author, description, 
endpoints, finally, name, status, variables");
+                                      + " actions, author, configuration, 
description, endpoints, finally, name, status,"
+                                      + " variables");
         List<String> msgs = CitrusTestChecks.validate("""
                 name: t
                 status: final
@@ -703,7 +704,7 @@ class CitrusTestChecksTest {
         assertThat(msgs.get(0)).isEqualTo("Line 2: status: final is not one of 
DRAFT, READY_FOR_REVIEW, FINAL, DISABLED"
                                           + " (did you mean FINAL?)");
         assertThat(msgs.get(1)).isEqualTo("Line 3: steps is not a key of a 
Citrus test, which takes actions, author,"
-                                          + " description, endpoints, finally, 
name, status, variables");
+                                          + " configuration, description, 
endpoints, finally, name, status, variables");
     }
 
     @Test
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-test/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
 
b/dsl/camel-jbang/camel-jbang-plugin-test/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
index 800c026bed78..944490d42256 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-test/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-test/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
@@ -1,5 +1,5 @@
 {
   "commands": [
-    { "name": "test", "fullName": "test", "description": "Manage tests for 
Camel applications", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.test.TestCommand", "plugin": "test", 
"options": [ { "names": "-h,--help", "description": "Display this help and 
exit", "javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name": 
"agent", "fullName": "test agent", "description": "Manage Citrus agents", 
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.test.TestAgent", [...]
+    { "name": "test", "fullName": "test", "description": "Manage tests for 
Camel applications", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.test.TestCommand", "plugin": "test", 
"options": [ { "names": "-h,--help", "description": "Display this help and 
exit", "javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name": 
"agent", "fullName": "test agent", "description": "Manage Citrus agents", 
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.test.TestAgent", [...]
   ]
 }
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestInit.java
 
b/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestInit.java
index d5266a0e5cd1..3a6a5b1a407a 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestInit.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestInit.java
@@ -20,17 +20,12 @@ package org.apache.camel.dsl.jbang.core.commands.test;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
 import java.nio.file.Path;
 
 import org.aesh.command.CommandException;
 import org.aesh.command.CommandResult;
-import org.aesh.command.impl.internal.OptionType;
-import org.aesh.command.impl.internal.ProcessedCommand;
-import org.aesh.command.impl.internal.ProcessedOptionBuilder;
 import org.aesh.command.invocation.CommandInvocation;
 import org.apache.camel.catalog.VersionHelper;
-import org.apache.camel.dsl.jbang.core.common.CommandTree;
 import org.apache.camel.dsl.jbang.run.common.ExportHelper;
 import org.apache.camel.util.IOHelper;
 import org.citrusframework.CitrusSettings;
@@ -41,71 +36,17 @@ import org.citrusframework.jbang.cli.commands.Init;
 /**
  * Automatically uses test subfolder as a working directory for creating new 
tests. Automatically adds a
  * citrus-application.properties configuration if not present.
- *
- * The --force option is added programmatically in {@link 
#setProcessedCommand} because Citrus ships compile-time
- * generated aesh metadata ({@code Init_AeshMetadata}) that takes precedence 
over annotation scanning. That metadata
- * only knows about {@code Init}'s own fields, so a subclass {@code @Option} 
would be silently ignored.
  */
-public class TestInit extends Init implements CommandTree.ParsedCommandAware {
-
-    boolean force;
+public class TestInit extends Init {
 
     public TestInit(CitrusJBangMain citrus) {
         super(citrus);
     }
 
-    @Override
-    public void setProcessedCommand(ProcessedCommand<?, ?> processedCommand, 
CommandTree tree) {
-        try {
-            processedCommand.addOption(
-                    ProcessedOptionBuilder.builder()
-                            .name("force")
-                            .description("Overwrite a test that exists 
already")
-                            .hasValue(false)
-                            .type(Boolean.class)
-                            .optionType(OptionType.BOOLEAN)
-                            .fieldSetter((cmd, val) -> ((TestInit) cmd).force 
= val != null && (Boolean) val)
-                            .fieldGetter(cmd -> ((TestInit) cmd).force)
-                            .fieldResetter(cmd -> ((TestInit) cmd).force = 
false)
-                            .build());
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to add --force option to test 
init command", e);
-        }
-    }
-
     @Override
     public CommandResult execute(CommandInvocation invocation)
             throws CommandException, InterruptedException {
-        return TestPlugin.withClassLoader(inv -> {
-            try {
-                Path target = targetFile();
-                if (target != null && Files.exists(target) && !force) {
-                    printer().println("Error: Test already exists: %s (use 
--force to overwrite it)".formatted(target));
-                    return CommandResult.FAILURE;
-                }
-                return super.execute(inv);
-            } catch (RuntimeException e) {
-                printer().println(
-                        "Error: Failed to initialize test: %s 
%s".formatted(e.getClass().getName(), e.getMessage()));
-                return CommandResult.FAILURE;
-            }
-        }, invocation);
-    }
-
-    /**
-     * The file the Citrus init writes: the file argument in the target 
directory, or null when it is not known.
-     */
-    Path targetFile() {
-        try {
-            String file = TestPlugin.readField(Init.class, "file", this);
-            if (file == null) {
-                return null;
-            }
-            String directory = TestPlugin.readField(Init.class, "directory", 
this);
-            return Path.of(resolveTargetDirectory(directory)).resolve(file);
-        } catch (ReflectiveOperationException | RuntimeException e) {
-            return null;
-        }
+        return TestPlugin.withClassLoader(super::execute, invocation);
     }
 
     @Override
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 e2b04efd98c9..d9c8efbc6ea4 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
@@ -83,7 +83,7 @@ class TestPluginTest {
         camelJBangMain.execute("test", "init", "edited.citrus.it.yaml", 
"--directory", dir.toString());
 
         Assertions.assertEquals("name: my edited test\n", 
Files.readString(test));
-        Assertions.assertTrue(printer.getOutput().contains("Test already 
exists: " + test + " (use --force to overwrite it)"),
+        Assertions.assertTrue(printer.getOutput().contains("File already 
exists: " + test + " (use --force to overwrite)"),
                 printer.getOutput());
 
         camelJBangMain.execute("test", "init", "edited.citrus.it.yaml", 
"--directory", dir.toString(), "--force");
diff --git a/parent/pom.xml b/parent/pom.xml
index 22604278d169..da72864a7b10 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -121,7 +121,7 @@
         <clickhouse-client-version>0.11.0</clickhouse-client-version>
         <jta-api-1.2-version>1.2</jta-api-1.2-version>
         <chunk-templates-version>3.6.2</chunk-templates-version>
-        <citrus-version>5.2.0</citrus-version>
+        <citrus-version>5.2.1</citrus-version>
         <classgraph-version>4.8.199</classgraph-version>
         <cloudant-version>0.10.22</cloudant-version>
         
<com-ibm-mq-jakarta-client-version>10.0.1.0</com-ibm-mq-jakarta-client-version>

Reply via email to