gnodet opened a new pull request, #31156: URL: https://github.com/apache/camel/pull/31156
## Summary Two bugs in `camel-test-citrus` are fixed: 1. **`log` and `reportGroup` component options had no effect** — `CitrusComponent.createEndpoint()` was not propagating these options to the `CitrusEndpoint`, unlike the parent `MockComponent` which does both. 2. **A missing Citrus validation module was silently ignored** — `CitrusValidationProcessor.performCitrusValidation()` called the 2-argument `MessageValidatorRegistry.findMessageValidators()` overload, which falls back to `DefaultTextEqualsMessageValidator` (plain-text comparison) when no type-specific validator is registered. This meant that an absent module (e.g. `citrus-validation-json`) was never reported; the validation appeared to pass while actually comparing bytes as text. ## Root Cause ### Bug 1 — log / reportGroup not propagated `MockComponent.createEndpoint()` explicitly sets `endpoint.setLog(log)`, extracts `reportGroup` from URI parameters, and wires up a `ThroughputLogger` reporter. `CitrusComponent.createEndpoint()` overrides that method but was doing neither, so both options were always at their default values. ### Bug 2 — missing validator silently ignored `MessageValidatorRegistry.findMessageValidators(String, Message)` (2-arg) is a convenience wrapper that calls `findMessageValidators(String, Message, false)` — `mustFindValidator=false`. When no registered validator claims the message type, Citrus silently falls back to `DefaultTextEqualsMessageValidator`. The old manual `validators.isEmpty()` guard was therefore dead code: the list was never empty because the fallback validator was always added. ## Fix - **`CitrusComponent`**: after setting `operation` and `name`, propagate `isLog()` to the endpoint and extract `reportGroup` from the parameters, mirroring `MockComponent.createEndpoint()` exactly. - **`CitrusValidationProcessor`**: switch to `findMessageValidators(resolvedType, receivedMessage, true)` (`mustFindValidator=true`). Citrus itself throws `CitrusRuntimeException` when only the default fallback validator would be used, surfacing missing modules with a clear diagnostic message. The now-redundant `validators.isEmpty()` manual check is removed. ## Tests `CitrusComponentOptionsTest` (new): - `logOptionPropagatesToEndpoint` — asserts `citrus.isLog()` is `true` after `?log=true` - `logOptionDefaultIsFalse` — asserts default is `false` - `reportGroupOptionPropagatesToEndpoint` — asserts `getReportGroup() == 10` and `getReporter() != null` after `?reportGroup=10` - `reportGroupDefaultIsNull` — asserts `getReporter()` is `null` with no option set - `unknownMessageTypeShouldBeReported` — sends a byte-array body with `messageType=BINARY` (no BINARY validator module on the classpath); asserts `assertIsSatisfied()` throws `AssertionError` caused by `CitrusRuntimeException` All 54 tests in the module pass locally. Fixes https://issues.apache.org/jira/browse/CAMEL-27869 --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
