gnodet commented on code in PR #21969:
URL: https://github.com/apache/camel/pull/21969#discussion_r2935840734
##########
core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java:
##########
@@ -449,6 +450,54 @@ public void testParseError() throws Exception {
assertTrue(e.getMessage().startsWith("Unexpected attribute '{}ref'"));
}
+ @Test
+ public void testMethodAfterStepsInWhenClauseShouldFail() throws Exception {
+ String routesXml = """
+ <routes xmlns="http://camel.apache.org/schema/xml-io">
+ <route>
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <simple>${header.foo} == 'bar'</simple>
+ <log message="Condition met"/>
+ <method ref="someBean" method="processFooBar"/>
+ </when>
+ <otherwise>
+ <to uri="mock:other"/>
+ </otherwise>
+ </choice>
+ </route>
+ </routes>
+ """;
+ Exception e = assertThrows(Exception.class, () -> {
+ new ModelParser(new
StringReader(routesXml)).parseRoutesDefinition();
+ });
+ assertThat(e).hasStackTraceContaining("already has a predicate");
+ }
+
+ @Test
+ public void testMethodAsPredicateInWhenClauseShouldWork() throws Exception
{
+ String routesXml = """
+ <routes xmlns="http://camel.apache.org/schema/xml-io">
+ <route>
+ <from uri="direct:start"/>
+ <choice>
+ <when>
+ <method ref="someBean" method="isFoo"/>
+ <to uri="mock:foo"/>
Review 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.
--
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]