File tree 1 file changed +5
-5
lines changed
spring-expression/src/test/java/org/springframework/expression/spel
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
19
19
import org .junit .jupiter .api .Test ;
20
20
21
21
import org .springframework .expression .spel .standard .SpelExpressionParser ;
22
+ import org .springframework .expression .spel .standard .SpelExpression ;
22
23
import org .springframework .expression .spel .support .StandardEvaluationContext ;
23
24
import org .springframework .expression .spel .support .StandardTypeLocator ;
24
25
@@ -266,11 +267,10 @@ void functionViaMethodHandleForStaticMethodThatAcceptsOnlyVarargs() {
266
267
267
268
@ Test
268
269
void functionMethodMustBeStatic () throws Exception {
269
- SpelExpressionParser parser = new SpelExpressionParser ();
270
- StandardEvaluationContext ctx = new StandardEvaluationContext ();
271
- ctx .setVariable ("notStatic" , this .getClass ().getMethod ("nonStatic" ));
270
+ context .registerFunction ("nonStatic" , this .getClass ().getMethod ("nonStatic" ));
271
+ SpelExpression expression = parser .parseRaw ("#nonStatic()" );
272
272
assertThatExceptionOfType (SpelEvaluationException .class )
273
- .isThrownBy (() -> parser . parseRaw ( "#notStatic()" ). getValue (ctx ))
273
+ .isThrownBy (() -> expression . getValue (context ))
274
274
.satisfies (ex -> assertThat (ex .getMessageCode ()).isEqualTo (FUNCTION_MUST_BE_STATIC ));
275
275
}
276
276
You can’t perform that action at this time.
0 commit comments