From aa7e84c89fde09c9563ede41d73f74ec83093c16 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 11 Feb 2025 15:48:00 +0100 Subject: [PATCH] Polishing --- .../expression/spel/VariableAndFunctionTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java index 88f8b0b8b39d..3cdccda00739 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test; 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.StandardTypeLocator; @@ -266,11 +267,10 @@ void functionViaMethodHandleForStaticMethodThatAcceptsOnlyVarargs() { @Test void functionMethodMustBeStatic() throws Exception { - SpelExpressionParser parser = new SpelExpressionParser(); - StandardEvaluationContext ctx = new StandardEvaluationContext(); - ctx.setVariable("notStatic", this.getClass().getMethod("nonStatic")); + context.registerFunction("nonStatic", this.getClass().getMethod("nonStatic")); + SpelExpression expression = parser.parseRaw("#nonStatic()"); assertThatExceptionOfType(SpelEvaluationException.class) - .isThrownBy(() -> parser.parseRaw("#notStatic()").getValue(ctx)) + .isThrownBy(() -> expression.getValue(context)) .satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(FUNCTION_MUST_BE_STATIC)); }