Polishing
This commit is contained in:
parent
bd1c7b379f
commit
aa7e84c89f
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 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.
|
||||||
|
@ -19,6 +19,7 @@ package org.springframework.expression.spel;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpression;
|
||||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
import org.springframework.expression.spel.support.StandardTypeLocator;
|
import org.springframework.expression.spel.support.StandardTypeLocator;
|
||||||
|
|
||||||
|
@ -266,11 +267,10 @@ class VariableAndFunctionTests extends AbstractExpressionTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void functionMethodMustBeStatic() throws Exception {
|
void functionMethodMustBeStatic() throws Exception {
|
||||||
SpelExpressionParser parser = new SpelExpressionParser();
|
context.registerFunction("nonStatic", this.getClass().getMethod("nonStatic"));
|
||||||
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
SpelExpression expression = parser.parseRaw("#nonStatic()");
|
||||||
ctx.setVariable("notStatic", this.getClass().getMethod("nonStatic"));
|
|
||||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||||
.isThrownBy(() -> parser.parseRaw("#notStatic()").getValue(ctx))
|
.isThrownBy(() -> expression.getValue(context))
|
||||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(FUNCTION_MUST_BE_STATIC));
|
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(FUNCTION_MUST_BE_STATIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue