parent
f075aac7f9
commit
ff738e7670
|
@ -34,6 +34,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
* @author Sergey Podgurskiy
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public class MethodBasedEvaluationContext extends StandardEvaluationContext {
|
public class MethodBasedEvaluationContext extends StandardEvaluationContext {
|
||||||
|
@ -89,7 +90,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext {
|
||||||
String[] parameterNames = this.paramDiscoverer.getParameterNames(this.method);
|
String[] parameterNames = this.paramDiscoverer.getParameterNames(this.method);
|
||||||
// save parameter names (if discovered)
|
// save parameter names (if discovered)
|
||||||
if (parameterNames != null) {
|
if (parameterNames != null) {
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < this.args.length; i++) {
|
||||||
setVariable(parameterNames[i], this.args[i]);
|
setVariable(parameterNames[i], this.args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -30,6 +30,7 @@ import static org.junit.Assert.*;
|
||||||
* Unit tests for {@link MethodBasedEvaluationContext}.
|
* Unit tests for {@link MethodBasedEvaluationContext}.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
* @author Sergey Podgurskiy
|
||||||
*/
|
*/
|
||||||
public class MethodBasedEvaluationContextTests {
|
public class MethodBasedEvaluationContextTests {
|
||||||
|
|
||||||
|
@ -92,10 +93,11 @@ public class MethodBasedEvaluationContextTests {
|
||||||
@Test
|
@Test
|
||||||
public void varArgMultiple() {
|
public void varArgMultiple() {
|
||||||
Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class);
|
Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class);
|
||||||
MethodBasedEvaluationContext context = createEvaluationContext(method, new Object[] {null, new String[]{"hello", "hi"}});
|
MethodBasedEvaluationContext context = createEvaluationContext(method,
|
||||||
|
new Object[] {null, new String[]{"hello", "hi"}});
|
||||||
|
|
||||||
assertNull(context.lookupVariable("p0"));
|
assertNull(context.lookupVariable("p0"));
|
||||||
assertNotNull(context.lookupVariable("p1"));
|
assertArrayEquals(new String[]{"hello", "hi"}, (String[]) context.lookupVariable("p1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodBasedEvaluationContext createEvaluationContext(Method method, Object[] args) {
|
private MethodBasedEvaluationContext createEvaluationContext(Method method, Object[] args) {
|
||||||
|
@ -109,9 +111,10 @@ public class MethodBasedEvaluationContextTests {
|
||||||
private void hello(String foo, Boolean flag) {
|
private void hello(String foo, Boolean flag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hello(Boolean flag, String ... vararg){
|
private void hello(Boolean flag, String... vararg){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue