SWF-443 - Enhance MethodInvoker to allow type conversion on a method result.
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.binding.expression.support.StaticExpression;
|
||||
* Unit tests for {@link org.springframework.binding.method.MethodInvoker}.
|
||||
*
|
||||
* @author Erwin Vervaet
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class MethodInvokerTests extends TestCase {
|
||||
|
||||
@@ -55,17 +56,23 @@ public class MethodInvokerTests extends TestCase {
|
||||
Parameters parameters = new Parameters();
|
||||
Bean bean = new Bean();
|
||||
parameters.add(new Parameter(Bean.class, new StaticExpression(bean)));
|
||||
MethodSignature method = new MethodSignature("testBeanArg", parameters);
|
||||
MethodSignature method = new MethodSignature("testBeanArg", parameters, null);
|
||||
assertSame(bean, methodInvoker.invoke(method, new TestObject(), null));
|
||||
}
|
||||
|
||||
public void testPrimitiveArg() {
|
||||
Parameters parameters = new Parameters();
|
||||
parameters.add(new Parameter(Boolean.class, new StaticExpression(Boolean.TRUE)));
|
||||
MethodSignature method = new MethodSignature("testPrimitiveArg", parameters);
|
||||
MethodSignature method = new MethodSignature("testPrimitiveArg", parameters, null);
|
||||
assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null));
|
||||
}
|
||||
|
||||
public void testResultConversion() {
|
||||
Parameters parameters = Parameters.NONE;
|
||||
MethodSignature method = new MethodSignature("testConvertResult", parameters, Class.class);
|
||||
assertEquals(Object.class, methodInvoker.invoke(method, new TestObject(), null));
|
||||
}
|
||||
|
||||
private static class TestObject {
|
||||
|
||||
public void test() {
|
||||
@@ -76,6 +83,10 @@ public class MethodInvokerTests extends TestCase {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public String testConvertResult() {
|
||||
return "java.lang.Object";
|
||||
}
|
||||
|
||||
public boolean testPrimitiveArg(boolean primitive) {
|
||||
return primitive;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user