@@ -62,6 +62,42 @@ public void nullArgument() {
6262 assertNull (context .lookupVariable ("p0" ));
6363 }
6464
65+ @ Test
66+ public void varArgEmpty () {
67+ Method method = ReflectionUtils .findMethod (SampleMethods .class , "hello" , Boolean .class , String [].class );
68+ MethodBasedEvaluationContext context = createEvaluationContext (method , new Object [] {null });
69+
70+ assertNull (context .lookupVariable ("p0" ));
71+ assertNull (context .lookupVariable ("p1" ));
72+ }
73+
74+ @ Test
75+ public void varArgNull () {
76+ Method method = ReflectionUtils .findMethod (SampleMethods .class , "hello" , Boolean .class , String [].class );
77+ MethodBasedEvaluationContext context = createEvaluationContext (method , new Object [] {null , null });
78+
79+ assertNull (context .lookupVariable ("p0" ));
80+ assertNull (context .lookupVariable ("p1" ));
81+ }
82+
83+ @ Test
84+ public void varArgSingle () {
85+ Method method = ReflectionUtils .findMethod (SampleMethods .class , "hello" , Boolean .class , String [].class );
86+ MethodBasedEvaluationContext context = createEvaluationContext (method , new Object [] {null , "hello" });
87+
88+ assertNull (context .lookupVariable ("p0" ));
89+ assertEquals ("hello" , context .lookupVariable ("p1" ));
90+ }
91+
92+ @ Test
93+ public void varArgMultiple () {
94+ Method method = ReflectionUtils .findMethod (SampleMethods .class , "hello" , Boolean .class , String [].class );
95+ MethodBasedEvaluationContext context = createEvaluationContext (method , new Object [] {null , new String []{"hello" , "hi" }});
96+
97+ assertNull (context .lookupVariable ("p0" ));
98+ assertNotNull (context .lookupVariable ("p1" ));
99+ }
100+
65101 private MethodBasedEvaluationContext createEvaluationContext (Method method , Object [] args ) {
66102 return new MethodBasedEvaluationContext (this , method , args , this .paramDiscover );
67103 }
@@ -73,6 +109,9 @@ private static class SampleMethods {
73109 private void hello (String foo , Boolean flag ) {
74110 }
75111
112+ private void hello (Boolean flag , String ... vararg ){
113+
114+ }
76115 }
77116
78117}
0 commit comments