[ 
https://issues.apache.org/jira/browse/CAMEL-25378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Christoph Deppisch updated CAMEL-25378:
---------------------------------------
    Description: 
Add a new camel-test-citrus test component that integrates with the Citrus 
integration test framework ([https://citrusframework.org/]) to perform message 
validation and response simulation on exchanges in Camel route tests.

*Architecture:* {{CitrusEndpoint}} extends {{{}MockEndpoint{}}}, inheriting all 
mock capabilities ({{{}assertIsSatisfied(){}}}, {{{}expectedMessageCount(){}}}, 
{{{}resetMocks(){}}}, context-wide assertions) and adding Citrus validation on 
top via the processor dispatch infrastructure ({{{}whenExchangeReceived{}}} / 
{{{}whenAnyExchangeReceived{}}}).

*Endpoint URI:* {{citrus:operation/name}} where {{operation}} is {{validate}} 
or {{{}receive{}}}, and {{name}} is an optional identifier.

*Operations:*
 - {{validate}} — validates exchanges without modifying them (pass-through 
validation). Validation failures are collected and reported via 
{{{}assertIsSatisfied(){}}}.
 - {{receive}} — validates exchanges and returns a simulated response 
(request/response simulation). Uses a Gherkin-style fluent API: 
{{{}when().receive().body(...).then().respond().body(...){}}}.

*Key capabilities:*
 - Producer-only endpoint — routes send exchanges to the citrus endpoint for 
validation
 - Supports {{messageType}} option ({{{}json{}}}, {{{}xml{}}}, {{{}yaml{}}}, 
{{{}plaintext{}}}) to select the appropriate Citrus validation module
 - Users configure expected message templates (body), header validation, and 
path validation expressions (JsonPath, XPath) via a fluent API on the endpoint
 - Per-exchange sequential validation with auto-incrementing or explicit 
1-based indexing
 - Default validation via {{validateAll()}} / {{receiveAll()}} with indexed 
specs taking priority
 - Propagates exchange properties and exchange variables as Citrus test 
variables
 - Variables extracted by Citrus (e.g. via {{{}@variable('name')@{}}}) are 
written back as exchange variables
 - Case-insensitive header validation matching Camel header behavior
 - StreamCache-safe body reading for pass-through validation

*Validation module dependencies:*
The component does not bundle Citrus validation modules out of the box. Users 
must explicitly add the required validation module dependency for their message 
type (e.g., {{{}citrus-validation-json{}}}, {{{}citrus-validation-xml{}}}) to 
their test classpath.

*Location:* under {{components/camel-test/}} alongside existing test modules.

*Dependencies:* Uses the Citrus version already managed in Camel (5.0.2).

  was:
Add a new camel-test-citrus test component that integrates with the Citrus 
integration test framework (https://citrusframework.org/) to perform message 
validation on exchanges arriving at a Camel endpoint.

*Endpoint URI:* {{citrus:validate}} (where {{validate}} is the initial 
operation, extensible in future releases).

*Key capabilities:*
* Consumer-side endpoint that validates each arriving exchange using Citrus 
message validation
* Supports {{messageType}} option ({{json}}, {{xml}}, {{plaintext}}) to select 
the appropriate Citrus validation module
* Users configure expected message templates (body), header validation 
expressions, and path validation expressions (JsonPath, XPath) via a *fluent 
API on the endpoint* — similar to how MockEndpoint provides methods to verify 
processed exchanges
* Propagates exchange properties as Citrus test variables, enabling use of 
Citrus functions and validation matchers in expected templates
* Prepares the Citrus runtime context automatically per exchange

*Validation module dependencies:*
The component does *not* bundle Citrus validation modules out of the box. Users 
must explicitly add the required validation module dependency for their message 
type (e.g., {{citrus-validation-json}}, {{citrus-validation-xml}}) to their 
test classpath.

*Scope (initial):*
* Java DSL only (XML/YAML DSL support can follow)
* Consumer-side validation only (producer-side capabilities can follow)
* Complementary to existing camel-test-* modules, not a replacement

*Location:* under {{components/camel-test/}} alongside existing test modules.

*Dependencies:* Uses the Citrus version already managed in Camel (5.0.2).


> Add camel-test-citrus component for Citrus message validation in Camel route 
> tests
> ----------------------------------------------------------------------------------
>
>                 Key: CAMEL-25378
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25378
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-test
>            Reporter: Christoph Deppisch
>            Assignee: Christoph Deppisch
>            Priority: Major
>             Fix For: 4.24.0
>
>
> Add a new camel-test-citrus test component that integrates with the Citrus 
> integration test framework ([https://citrusframework.org/]) to perform 
> message validation and response simulation on exchanges in Camel route tests.
> *Architecture:* {{CitrusEndpoint}} extends {{{}MockEndpoint{}}}, inheriting 
> all mock capabilities ({{{}assertIsSatisfied(){}}}, 
> {{{}expectedMessageCount(){}}}, {{{}resetMocks(){}}}, context-wide 
> assertions) and adding Citrus validation on top via the processor dispatch 
> infrastructure ({{{}whenExchangeReceived{}}} / 
> {{{}whenAnyExchangeReceived{}}}).
> *Endpoint URI:* {{citrus:operation/name}} where {{operation}} is {{validate}} 
> or {{{}receive{}}}, and {{name}} is an optional identifier.
> *Operations:*
>  - {{validate}} — validates exchanges without modifying them (pass-through 
> validation). Validation failures are collected and reported via 
> {{{}assertIsSatisfied(){}}}.
>  - {{receive}} — validates exchanges and returns a simulated response 
> (request/response simulation). Uses a Gherkin-style fluent API: 
> {{{}when().receive().body(...).then().respond().body(...){}}}.
> *Key capabilities:*
>  - Producer-only endpoint — routes send exchanges to the citrus endpoint for 
> validation
>  - Supports {{messageType}} option ({{{}json{}}}, {{{}xml{}}}, {{{}yaml{}}}, 
> {{{}plaintext{}}}) to select the appropriate Citrus validation module
>  - Users configure expected message templates (body), header validation, and 
> path validation expressions (JsonPath, XPath) via a fluent API on the endpoint
>  - Per-exchange sequential validation with auto-incrementing or explicit 
> 1-based indexing
>  - Default validation via {{validateAll()}} / {{receiveAll()}} with indexed 
> specs taking priority
>  - Propagates exchange properties and exchange variables as Citrus test 
> variables
>  - Variables extracted by Citrus (e.g. via {{{}@variable('name')@{}}}) are 
> written back as exchange variables
>  - Case-insensitive header validation matching Camel header behavior
>  - StreamCache-safe body reading for pass-through validation
> *Validation module dependencies:*
> The component does not bundle Citrus validation modules out of the box. Users 
> must explicitly add the required validation module dependency for their 
> message type (e.g., {{{}citrus-validation-json{}}}, 
> {{{}citrus-validation-xml{}}}) to their test classpath.
> *Location:* under {{components/camel-test/}} alongside existing test modules.
> *Dependencies:* Uses the Citrus version already managed in Camel (5.0.2).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to