CAMEL-22884: Validate method attribute placement in when clause#21969
CAMEL-22884: Validate method attribute placement in when clause#21969
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
Outdated
Show resolved
Hide resolved
core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
Show resolved
Hide resolved
| <choice> | ||
| <when> | ||
| <method ref="someBean" method="isFoo"/> | ||
| <to uri="mock:foo"/> |
There was a problem hiding this comment.
Would it be good to add a here as the exception message tells
There was a problem hiding this comment.
Good idea — adding a <bean id="someBean" type="..."/> would make the test XML more realistic, even though this is purely a parser-level test (no runtime resolution). I'll update both test methods.
There was a problem hiding this comment.
Actually, on second thought — <bean> declarations live at the <camel> root level, not inside <routes>. This test uses parseRoutesDefinition() which expects <routes> as root. Restructuring to use a <camel> wrapper would require a different parse method and adds complexity for a purely parser-level test where bean refs aren't resolved. Happy to change it if you still think it's worth it, but I'd lean toward keeping it simple since the test is only validating XML structure parsing, not runtime behavior.
Summary
BasicOutputExpressionNode.setExpression()to detect when an expression element (e.g.<method>) appears after processing steps inside a<when>clause in XML/YAML DSL<method>element placed after<log>or other steps in a<when>clause would silently overwrite the predicate expression instead of being treated as a processor or raising an errorExpressionClauseis legitimately resolved to the actual expression duringpreCreateProcessor()Test plan
testMethodAfterStepsInWhenClauseShouldFailto verify that placing<method>after processing steps in a<when>clause raises an errortestMethodAsPredicateInWhenClauseShouldWorkto verify that<method>as the first (and only expression) child of<when>still works correctly