Remove obsolete "test" prefix from test method names

Although this commit also changes the visibility of some test methods
to package-private, the remainder of that task will be addressed in
conjunction with gh-36496.

Closes gh-36495

(cherry picked from commit 4c14abf0cd)
This commit is contained in:
Sam Brannen
2026-03-16 13:37:56 +01:00
parent 40562e2485
commit 01248c7753
581 changed files with 3212 additions and 3235 deletions
@@ -31,17 +31,17 @@ import org.springframework.expression.spel.support.StandardTypeConverter;
class BooleanExpressionTests extends AbstractExpressionTests {
@Test
void testBooleanTrue() {
void booleanTrue() {
evaluate("true", Boolean.TRUE, Boolean.class);
}
@Test
void testBooleanFalse() {
void booleanFalse() {
evaluate("false", Boolean.FALSE, Boolean.class);
}
@Test
void testOr() {
void or() {
evaluate("false or false", Boolean.FALSE, Boolean.class);
evaluate("false or true", Boolean.TRUE, Boolean.class);
evaluate("true or false", Boolean.TRUE, Boolean.class);
@@ -49,7 +49,7 @@ class BooleanExpressionTests extends AbstractExpressionTests {
}
@Test
void testAnd() {
void and() {
evaluate("false and false", Boolean.FALSE, Boolean.class);
evaluate("false and true", Boolean.FALSE, Boolean.class);
evaluate("true and false", Boolean.FALSE, Boolean.class);
@@ -57,7 +57,7 @@ class BooleanExpressionTests extends AbstractExpressionTests {
}
@Test
void testNot() {
void not() {
evaluate("!false", Boolean.TRUE, Boolean.class);
evaluate("!true", Boolean.FALSE, Boolean.class);
@@ -66,21 +66,21 @@ class BooleanExpressionTests extends AbstractExpressionTests {
}
@Test
void testCombinations01() {
void combinations01() {
evaluate("false and false or true", Boolean.TRUE, Boolean.class);
evaluate("true and false or true", Boolean.TRUE, Boolean.class);
evaluate("true and false or false", Boolean.FALSE, Boolean.class);
}
@Test
void testWritability() {
void writability() {
evaluate("true and true", Boolean.TRUE, Boolean.class, false);
evaluate("true or true", Boolean.TRUE, Boolean.class, false);
evaluate("!false", Boolean.TRUE, Boolean.class, false);
}
@Test
void testBooleanErrors01() {
void booleanErrors01() {
evaluateAndCheckError("1.0 or false", SpelMessage.TYPE_CONVERSION_ERROR, 0);
evaluateAndCheckError("false or 39.4", SpelMessage.TYPE_CONVERSION_ERROR, 9);
evaluateAndCheckError("true and 'hello'", SpelMessage.TYPE_CONVERSION_ERROR, 9);
@@ -90,7 +90,7 @@ class BooleanExpressionTests extends AbstractExpressionTests {
}
@Test
void testConvertAndHandleNull() { // SPR-9445
void convertAndHandleNull() { // SPR-9445
// without null conversion
evaluateAndCheckError("null or true", SpelMessage.TYPE_CONVERSION_ERROR, 0, "null", "boolean");
evaluateAndCheckError("null and true", SpelMessage.TYPE_CONVERSION_ERROR, 0, "null", "boolean");
@@ -39,7 +39,7 @@ class CachedMethodExecutorTests {
@Test
void testCachedExecutionForParameters() {
void cachedExecutionForParameters() {
Expression expression = this.parser.parseExpression("echo(#var)");
assertMethodExecution(expression, 42, "int: 42");
@@ -49,7 +49,7 @@ class CachedMethodExecutorTests {
}
@Test
void testCachedExecutionForTarget() {
void cachedExecutionForTarget() {
Expression expression = this.parser.parseExpression("#var.echo(42)");
assertMethodExecution(expression, new RootObject(), "int: 42");
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ComparatorTests {
@Test
void testPrimitives() throws EvaluationException {
void primitives() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
// primitive int
assertThat(comparator.compare(1, 2)).isLessThan(0);
@@ -69,7 +69,7 @@ class ComparatorTests {
}
@Test
void testNonPrimitiveNumbers() throws EvaluationException {
void nonPrimitiveNumbers() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
BigDecimal bdOne = new BigDecimal("1");
@@ -98,7 +98,7 @@ class ComparatorTests {
}
@Test
void testNulls() throws EvaluationException {
void nulls() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.compare(null,"abc")).isLessThan(0);
assertThat(comparator.compare(null,null)).isEqualTo(0);
@@ -106,7 +106,7 @@ class ComparatorTests {
}
@Test
void testObjects() throws EvaluationException {
void objects() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.compare("a","a")).isEqualTo(0);
assertThat(comparator.compare("a","b")).isLessThan(0);
@@ -114,7 +114,7 @@ class ComparatorTests {
}
@Test
void testCanCompare() throws EvaluationException {
void canCompare() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.canCompare(null,1)).isTrue();
assertThat(comparator.canCompare(1,null)).isTrue();
@@ -60,7 +60,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: using the standard infrastructure and running simple expression evaluation.
*/
@Test
void testScenario_UsingStandardInfrastructure() {
void usingStandardInfrastructure() {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Parse an expression
@@ -78,7 +78,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: using the standard context but adding your own variables
*/
@Test
void testScenario_DefiningVariablesThatWillBeAccessibleInExpressions() {
void definingVariablesThatWillBeAccessibleInExpressions() {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
@@ -105,7 +105,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: using your own root context object
*/
@Test
void testScenario_UsingADifferentRootContextObject() {
void usingADifferentRootContextObject() {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
@@ -151,7 +151,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: using your own java methods and calling them from the expression
*/
@Test
void testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem() throws Exception {
void registeringJavaMethodsAsFunctionsAndCallingThem() throws Exception {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
@@ -167,7 +167,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: looking up your own MethodHandles and calling them from the expression
*/
@Test
void testScenario_RegisteringJavaMethodsAsMethodHandlesAndCallingThem() throws Exception {
void registeringJavaMethodsAsMethodHandlesAndCallingThem() throws Exception {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
//this.context is already populated with all relevant MethodHandle examples
@@ -201,7 +201,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
* Scenario: add a property resolver that will get called in the resolver chain, this one only supports reading.
*/
@Test
void testScenario_AddingYourOwnPropertyResolvers_1() {
void addingYourOwnPropertyResolvers_1() {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
@@ -217,7 +217,7 @@ class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
}
@Test
void testScenario_AddingYourOwnPropertyResolvers_2() {
void addingYourOwnPropertyResolvers_2() {
// Create a parser
SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
class ParserErrorMessagesTests extends AbstractExpressionTests {
@Test
void testBrokenExpression01() {
void brokenExpression01() {
// will not fit into an int, needs L suffix
parseAndCheckError("0xCAFEBABE", SpelMessage.NOT_AN_INTEGER);
evaluate("0xCAFEBABEL", 0xCAFEBABEL, Long.class);
@@ -34,25 +34,25 @@ class ParserErrorMessagesTests extends AbstractExpressionTests {
}
@Test
void testBrokenExpression02() {
void brokenExpression02() {
// rogue 'G' on the end
parseAndCheckError("0xB0BG", SpelMessage.MORE_INPUT, 5, "G");
}
@Test
void testBrokenExpression04() {
void brokenExpression04() {
// missing right operand
parseAndCheckError("true or ", SpelMessage.RIGHT_OPERAND_PROBLEM, 5);
}
@Test
void testBrokenExpression05() {
void brokenExpression05() {
// missing right operand
parseAndCheckError("1 + ", SpelMessage.RIGHT_OPERAND_PROBLEM, 2);
}
@Test
void testBrokenExpression07() {
void brokenExpression07() {
// T() can only take an identifier (possibly qualified), not a literal
// message ought to say identifier rather than ID
parseAndCheckError("null instanceof T('a')", SpelMessage.NOT_EXPECTED_TOKEN, 18,
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests {
@Test
void testScenario01_Roles() {
void roles() {
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
Expression expr = parser.parseRaw("hasAnyRole('MANAGER','TELLER')");
@@ -61,7 +61,7 @@ class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests
}
@Test
void testScenario02_ComparingNames() {
void comparingNames() {
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -96,7 +96,7 @@ class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests
}
@Test
void testScenario03_Arithmetic() {
void arithmetic() {
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -119,7 +119,7 @@ class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests
// Here i'm going to change which hasRole() executes and make it one of my own Java methods
@Test
void testScenario04_ControllingWhichMethodsRun() {
void controllingWhichMethodsRun() {
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -128,7 +128,7 @@ class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests
ctx.addMethodResolver(new MyMethodResolver()); // NEEDS TO OVERRIDE THE REFLECTION ONE - SHOW REORDERING MECHANISM
// Might be better with a as a variable although it would work as a property too...
// Variable references using a '#'
// SpelExpression expr = parser.parseExpression("(hasRole('SUPERVISOR') or (#a < 1.042)) and hasIpAddress('10.10.0.0/16')");
// SpelExpression expr = parser.parseExpression("(hasRole('SUPERVISOR') or (#a < 1.042)) and hasIpAddress('10.10.0.0/16')");
Expression expr = parser.parseRaw("(hasRole(3) or (#a < 1.042)) and hasIpAddress('10.10.0.0/16')");
Boolean value = null;
@@ -137,10 +137,10 @@ class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests
value = expr.getValue(ctx,Boolean.class);
assertThat((boolean) value).isTrue();
// ctx.setRootObject(new Manager("Luke"));
// ctx.setVariable("a",1.043d);
// value = (Boolean)expr.getValue(ctx,Boolean.class);
// assertFalse(value);
// ctx.setRootObject(new Manager("Luke"));
// ctx.setVariable("a",1.043d);
// value = (Boolean)expr.getValue(ctx,Boolean.class);
// assertFalse(value);
}
@@ -2157,7 +2157,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test // gh-27421
public void nullSafeMethodChainingWithNonStaticVoidMethod() {
void nullSafeMethodChainingWithNonStaticVoidMethod() {
FooObjectHolder foh = new FooObjectHolder();
StandardEvaluationContext context = new StandardEvaluationContext(foh);
SpelExpression expression = (SpelExpression) parser.parseExpression("getFoo()?.doFoo()");
@@ -2436,7 +2436,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
@ParameterizedTest
@ValueSource(strings = {"voidMethod", "voidWrapperMethod"})
public void voidFunctionReference(String method) throws Exception {
void voidFunctionReference(String method) throws Exception {
assertVoidFunctionReferenceBehavior(method);
}
@@ -5347,7 +5347,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test // gh-27421
public void nullSafeInvocationOfNonStaticVoidMethod() {
void nullSafeInvocationOfNonStaticVoidMethod() {
// non-static method, no args, void return
expression = parser.parseExpression("new %s()?.one()".formatted(TestClass5.class.getName()));
@@ -5364,7 +5364,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test // gh-27421
public void nullSafeInvocationOfStaticVoidMethod() {
void nullSafeInvocationOfStaticVoidMethod() {
// static method, no args, void return
expression = parser.parseExpression("T(%s)?.two()".formatted(TestClass5.class.getName()));
@@ -5381,7 +5381,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test // gh-27421
public void nullSafeInvocationOfNonStaticVoidWrapperMethod() {
void nullSafeInvocationOfNonStaticVoidWrapperMethod() {
// non-static method, no args, Void return
expression = parser.parseExpression("new %s()?.oneVoidWrapper()".formatted(TestClass5.class.getName()));
@@ -5398,7 +5398,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test // gh-27421
public void nullSafeInvocationOfStaticVoidWrapperMethod() {
void nullSafeInvocationOfStaticVoidWrapperMethod() {
// static method, no args, Void return
expression = parser.parseExpression("T(%s)?.twoVoidWrapper()".formatted(TestClass5.class.getName()));
@@ -6190,7 +6190,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Test
void testNullComparison_SPR22358() {
void nullComparison_SPR22358() {
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.OFF, null);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -55,7 +55,7 @@ class SpelExceptionTests {
@Test
@SuppressWarnings("serial")
public void spelExpressionMapWithVariables() {
void spelExpressionMapWithVariables() {
ExpressionParser parser = new SpelExpressionParser();
Expression spelExpression = parser.parseExpression("#aMap['one'] eq 1");
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -94,7 +94,7 @@ class SpelExceptionTests {
@Test
@SuppressWarnings("serial")
public void spelExpressionListWithVariables() {
void spelExpressionListWithVariables() {
ExpressionParser parser = new SpelExpressionParser();
Expression spelExpression = parser.parseExpression("#aList.contains('one')");
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -116,7 +116,7 @@ class SpelExceptionTests {
@Test
@SuppressWarnings("serial")
public void spelExpressionListIndexAccessWithVariables() {
void spelExpressionListIndexAccessWithVariables() {
ExpressionParser parser = new SpelExpressionParser();
Expression spelExpression = parser.parseExpression("#aList[0] eq 'one'");
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -146,7 +146,7 @@ class SpelExceptionTests {
@Test
@SuppressWarnings("serial")
public void spelExpressionArrayWithVariables() {
void spelExpressionArrayWithVariables() {
ExpressionParser parser = new SpelExpressionParser();
Expression spelExpression = parser.parseExpression("#anArray[0] eq 1");
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -688,7 +688,7 @@ class SpelReproTests extends AbstractExpressionTests {
}
@Test
void testCompiledExpressionForProxy_SPR16191() {
void compiledExpressionForProxy_SPR16191() {
SpelExpressionParser expressionParser =
new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null));
Expression expression = expressionParser.parseExpression("#target.process(#root)");
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class StandardTypeComparatorTests {
@Test
void testPrimitives() throws EvaluationException {
void primitives() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
// primitive int
assertThat(comparator.compare(1, 2)).isNegative();
@@ -64,7 +64,7 @@ class StandardTypeComparatorTests {
}
@Test
void testNonPrimitiveNumbers() throws EvaluationException {
void nonPrimitiveNumbers() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
BigDecimal bdOne = new BigDecimal("1");
@@ -93,7 +93,7 @@ class StandardTypeComparatorTests {
}
@Test
void testNulls() throws EvaluationException {
void nulls() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.compare(null, "abc")).isNegative();
assertThat(comparator.compare(null, null)).isZero();
@@ -101,7 +101,7 @@ class StandardTypeComparatorTests {
}
@Test
void testObjects() throws EvaluationException {
void objects() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.compare("a", "a")).isZero();
assertThat(comparator.compare("a", "b")).isNegative();
@@ -109,7 +109,7 @@ class StandardTypeComparatorTests {
}
@Test
void testCanCompare() throws EvaluationException {
void canCompare() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
assertThat(comparator.canCompare(null, 1)).isTrue();
assertThat(comparator.canCompare(1, null)).isTrue();
@@ -244,7 +244,7 @@ class SpelParserTests {
}
@Test
void testStringLiterals_DoubleQuotes_spr9620() {
void stringLiterals_DoubleQuotes_spr9620() {
SpelExpression expr = parser.parseRaw("\"double quote: \"\".\"");
assertThat(expr.getValue()).isEqualTo("double quote: \".");
expr = parser.parseRaw("\"hello \"\" world\"");
@@ -252,7 +252,7 @@ class SpelParserTests {
}
@Test
void testStringLiterals_DoubleQuotes_spr9620_2() {
void stringLiterals_DoubleQuotes_spr9620_2() {
assertParseExceptionThrownBy(() -> parser.parseRaw("\"double quote: \\\"\\\".\""))
.satisfies(ex -> {
assertThat(ex.getPosition()).isEqualTo(17);