use of org.springframework.expression.MethodExecutor in project spring-framework by spring-projects.
the class SpelReproTests method wideningPrimitiveConversion_8224.
/**
* Test whether {@link ReflectiveMethodResolver} handles Widening Primitive Conversion. That's passing an 'int' to a
* method accepting 'long' is ok.
*/
@Test
public void wideningPrimitiveConversion_8224() throws Exception {
class WideningPrimitiveConversion {
public int getX(long i) {
return 10;
}
}
final Integer INTEGER_VALUE = Integer.valueOf(7);
WideningPrimitiveConversion target = new WideningPrimitiveConversion();
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
List<TypeDescriptor> args = new ArrayList<>();
args.add(TypeDescriptor.forObject(INTEGER_VALUE));
MethodExecutor me = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target, "getX", args);
final int actual = (Integer) me.execute(emptyEvalContext, target, INTEGER_VALUE).getValue();
final int compiler = target.getX(INTEGER_VALUE);
assertEquals(compiler, actual);
}
Aggregations