|
18 | 18 |
|
19 | 19 | import java.io.ByteArrayOutputStream;
|
20 | 20 | import java.io.PrintStream;
|
| 21 | +import java.lang.reflect.InvocationHandler; |
21 | 22 | import java.lang.reflect.Method;
|
| 23 | +import java.lang.reflect.Proxy; |
22 | 24 | import java.util.ArrayList;
|
23 | 25 | import java.util.List;
|
24 | 26 |
|
25 | 27 | import org.junit.jupiter.api.Test;
|
26 | 28 |
|
27 | 29 | import org.springframework.core.convert.TypeDescriptor;
|
28 |
| -import org.springframework.expression.EvaluationContext; |
29 |
| -import org.springframework.expression.ParseException; |
30 |
| -import org.springframework.expression.PropertyAccessor; |
31 |
| -import org.springframework.expression.TypedValue; |
| 30 | +import org.springframework.expression.*; |
32 | 31 | import org.springframework.expression.spel.AbstractExpressionTests;
|
33 | 32 | import org.springframework.expression.spel.SpelUtilities;
|
34 | 33 | import org.springframework.expression.spel.standard.SpelExpression;
|
35 | 34 | import org.springframework.expression.spel.support.ReflectionHelper.ArgumentsMatchKind;
|
| 35 | +import org.springframework.util.Assert; |
36 | 36 |
|
37 | 37 | import static org.assertj.core.api.Assertions.assertThat;
|
38 | 38 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
@@ -364,6 +364,19 @@ public void testOptimalReflectivePropertyAccessor() throws Exception {
|
364 | 364 | field.write(ctx, tester, "field", null));
|
365 | 365 | }
|
366 | 366 |
|
| 367 | + @Test |
| 368 | + void testReflectiveMethodResolver() throws AccessException { |
| 369 | + MethodResolver resolver=new ReflectiveMethodResolver(); |
| 370 | + StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); |
| 371 | + Object obj= Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[]{Runnable.class}, new InvocationHandler() { |
| 372 | + @Override |
| 373 | + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
| 374 | + return null; |
| 375 | + } |
| 376 | + }); |
| 377 | + MethodExecutor mexec=resolver.resolve(evaluationContext,obj,"toString",new ArrayList<>()); |
| 378 | + Assert.notNull(mexec,"MethodExecutor should not be empty."); |
| 379 | + } |
367 | 380 |
|
368 | 381 | /**
|
369 | 382 | * Used to validate the match returned from a compareArguments call.
|
|
0 commit comments