Skip to content

Commit aa7e84c

Browse files
committed
Polishing
1 parent bd1c7b3 commit aa7e84c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.expression.spel.standard.SpelExpressionParser;
22+
import org.springframework.expression.spel.standard.SpelExpression;
2223
import org.springframework.expression.spel.support.StandardEvaluationContext;
2324
import org.springframework.expression.spel.support.StandardTypeLocator;
2425

@@ -266,11 +267,10 @@ void functionViaMethodHandleForStaticMethodThatAcceptsOnlyVarargs() {
266267

267268
@Test
268269
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()");
272272
assertThatExceptionOfType(SpelEvaluationException.class)
273-
.isThrownBy(() -> parser.parseRaw("#notStatic()").getValue(ctx))
273+
.isThrownBy(() -> expression.getValue(context))
274274
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(FUNCTION_MUST_BE_STATIC));
275275
}
276276

0 commit comments

Comments
 (0)