ammachado opened a new pull request, #28652:
URL: https://github.com/apache/camel/pull/28652

   # Description
   
   [CAMEL-25231](https://issues.apache.org/jira/browse/CAMEL-25231): regression 
tests for the source type the type converter registry chooses for a CXF 
`CachedCxfPayload`.
   
   **Stacked on #28651 (CAMEL-26392).** This PR carries that commit too; only 
the last commit (`CAMEL-25231: ...`) is new here. I'll rebase it once #28651 is 
merged, and keep it a draft until then.
   
   ## Background
   
   A `CachedCxfPayload` extends `CxfPayload` and implements `StreamCache`, and 
both have converters to the XML sources (camel-xml-jaxp's from `StreamCache`, 
`CxfPayloadConverter`'s from `CxfPayload`). The ticket reports that the 
converter chosen for it changed between JVM runs, because it depended on the 
iteration order of the converters map. That non-determinism triggered 
CAMEL-25224 (xslt).
   
   As gnodet noted on the ticket, main already fixed this, with no production 
change needed here:
   
   - CAMEL-24976 (073c6cf7ec20): `tryMatch` walks the type hierarchy breadth 
first in a stable order, interfaces before the super class.
   - CAMEL-21513 (4faa92ecfac6): `tryAssignableFrom` picks the nearest 
converter, ties broken by class name.
   
   `CoreTypeConverterRegistryTest.testAssignableMatchIsDeterministic` covers 
the helper with a model of the CXF types. This PR adds tests at the levels the 
ticket is about: through the registry's public `lookup`/`convertTo` (which 
`CxfPayloadConverter`'s fallback calls, and which #28651 now caches), and with 
the real CXF types.
   
   ## Tests added
   
   camel-cxf-soap, `CachedCxfPayloadTest`:
   - `testCachedCxfPayloadUsesTheStreamCacheConverters`: for `Source`, 
`SAXSource`, `DOMSource`, `StAXSource`, `StreamSource` and `Document`, 
`lookup(type, CachedCxfPayload)` returns the converter from `StreamCache`, 
which differs from the one from `CxfPayload`.
   - `testCachedCxfPayloadToDOMSourceHoldsTheDocument`: the `DOMSource` holds 
the `Document`, not its document element (the shape that bypassed a template 
matching `/` in CAMEL-25224), for a payload built from a DOM body and from a 
StAX body.
   - `testXPathOnCachedCxfPayload`: a namespaced xpath evaluates on both 
payloads.
   
   camel-core, `TypeConverterLookupCacheTest`:
   - `testCachedLookupFromInterfaceAndSuperClassIsDeterministic`: with 
converters from an interface and from the super class added in either order, 
`lookup` and `convertTo` both choose the interface's converter (only that one 
is invoked), and the cached lookup keeps returning it.
   
   ## Verification
   
   - Focused tests pass locally (JDK 25, macOS): camel-core 
`TypeConverterLookupCacheTest`, `CoreTypeConverterRegistryTest` and 
`EnumConverterTest` (25 tests); camel-cxf-soap `CachedCxfPayloadTest` and 
`CxfPayloadConverterTest` (20 tests). I did not run the full module suites.
   - Mutation check: with `tryMatch` changed to try the super class before the 
interfaces, `testCachedCxfPayloadUsesTheStreamCacheConverters` and 
`testCachedLookupFromInterfaceAndSuperClassIsDeterministic` fail. The DOMSource 
and xpath tests still pass under that mutation; they check behavior, not the 
order.
   - A temporary probe (not committed) printed every lookup and conversion 
above for a `CachedCxfPayload` with camel-base built from `origin/main` and 
then from the #28651 branch: the results were identical, so the lookup cache 
does not change the choice.
   - A single JVM can't reproduce the original JVM-to-JVM variation, which came 
from the map's hash order. The tests pin the documented order instead, so a 
regression that reintroduces map-order dependence changes the winner and fails 
them.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
     Not from the root folder: the change is test-only. I ran `mvn 
formatter:format impsort:sort` and the tests in `core/camel-core` and 
`components/camel-cxf/camel-cxf-soap`, and `git status` was clean afterwards.
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code) on behalf of 
Adriano Machado (@ammachado)
   
   _This was generated by an AI agent and may contain inaccuracies. Please 
verify before relying on it._
   


-- 
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]

Reply via email to