Details
Description
camel-bean incorectly choice method if class has overloaded methods and one of the paramets has bracket close symbol ")".
Here is a test case:
@ExtendWith(MockitoExtension.class) public class BeanProcessorOverloadedMethodsWithBracketsTest extends CamelTestSupport { private final String strArgWithBrackets = ")(string_with_brackets()))())"; @Test public void testOverloadedMethodWithBracketsParams() throws InterruptedException { template.sendBody("direct:start", null); MockEndpoint mock = getMockEndpoint("mock:result"); String receivedExchangeBody = mock.getExchanges().get(0).getMessage().getBody(String.class); assertEquals(new MyOverloadedClass().myMethod(strArgWithBrackets, strArgWithBrackets), receivedExchangeBody); } @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from("direct:start") .bean(MyOverloadedClass.class, "myMethod('" + strArgWithBrackets + "', '" + strArgWithBrackets + "')") .to("mock:result"); } }; } public static class MyOverloadedClass { public String myMethod() { return ""; } public String myMethod(String str) { return str; } public String myMethod(String str1, String str2) { return str1 + str2; } } }
In test example above I am trying to call myMethod with two arguments, but instead of it camel-bean chooses method with one argument.
Test returns the assertion error:
org.opentest4j.AssertionFailedError: Expected :)(string_with_brackets()))()))(string_with_brackets()))()) Actual :)(string_with_brackets()))())
Attachments
Issue Links
- links to