diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java index 6134533eb1b..56555b209d9 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java @@ -16,7 +16,8 @@ package org.springframework.expression.spel; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; @@ -29,6 +30,7 @@ import org.junit.Assert; import org.junit.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.AccessException; +import org.springframework.expression.BeanResolver; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionInvocationTargetException; @@ -44,6 +46,7 @@ import org.springframework.expression.spel.testresources.PlaceOfBirth; * Tests invocation of methods. * * @author Andy Clement + * @author Phillip Webb */ public class MethodInvocationTests extends ExpressionTestCase { @@ -369,4 +372,30 @@ public class MethodInvocationTests extends ExpressionTestCase { Object value = expression.getValue(new StandardEvaluationContext(String.class)); assertEquals(value, "java.lang.String"); } + + @Test + public void invokeMethodWithoutConversion() throws Exception { + final BytesService service = new BytesService(); + byte[] bytes = new byte[100]; + StandardEvaluationContext context = new StandardEvaluationContext(bytes); + context.setBeanResolver(new BeanResolver() { + public Object resolve(EvaluationContext context, String beanName) + throws AccessException { + if ("service".equals(beanName)) { + return service; + } + return null; + } + }); + Expression expression = parser.parseExpression("@service.handleBytes(#root)"); + byte[] outBytes = expression.getValue(context, byte[].class); + assertSame(bytes, outBytes); + } + + public static class BytesService { + + public byte[] handleBytes(byte[] bytes) { + return bytes; + } + } }