/*
* @testName: methodExpressionMatchingAmbiguousTest
*
* @assertion_ids: EL:SPEC:80
*
* @test_Strategy: Validate that MethodExpression does not match a method when
* the match is ambiguous and that a MethodNotFoundException is thrown
*/
public void methodExpressionMatchingAmbiguousTest() throws Fault {
StringBuffer buf = new StringBuffer();
String exprStr = "#{bean.targetE('aaa',1234)}";
boolean pass = true;
try {
ExpressionFactory expFactory = ExpressionFactory.newInstance();
ELContext context = (new VarMapperELContext(testProps)).getELContext();
MethodsBean bean = new MethodsBean();
ValueExpression ve = expFactory.createValueExpression(bean, MethodsBean.class);
context.getVariableMapper().setVariable("bean", ve);
MethodExpression me = expFactory.createMethodExpression(context, exprStr, String.class, null);
me.getMethodInfo(context);
pass = false;
} catch (MethodNotFoundException mnfe) {
pass = true;
} catch (Exception ex) {
pass = false;
TestUtil.logErr("Call to getMethodInfo() with ambiguous method _expression_ "
+ "threw the wrong Exception!" + NL + "Expected: MethodNotFoundException"
+ NL + "Received: " + ex.toString() + NL);
ex.printStackTrace();
}
if (!pass)
throw new Fault(ELTestUtil.FAIL + buf.toString());
else
TestUtil.logTrace(buf.toString());
}
public String targetE(Long arg0, Long arg1) {
return "Long-Long";
}
public String targetE(String arg0, String arg1) {
return "String-String";
}
I don't see a (String, [number]) overload, so I think the method is not testing an ambiguous match, but just a method not found.
Those happen to throw the same exception, so it goes undetected here.
Thoughts?
Kind regards,
Arjan