@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2022 the original author or authors .
* Copyright 2002 - 2023 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 .
@ -24,6 +24,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
@@ -24,6 +24,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException ;
/ * *
* Parse some expressions and check we get the AST we expect .
@ -42,6 +43,58 @@ class ParsingTests {
@@ -42,6 +43,58 @@ class ParsingTests {
@Nested
class Miscellaneous {
@Test
void supportedCharactersInIdentifiers ( ) {
parseCheck ( "#var='value'" ) ;
parseCheck ( "#Varz='value'" ) ;
parseCheck ( "#VarZ='value'" ) ;
parseCheck ( "#_var='value'" ) ;
parseCheck ( "#$var='value'" ) ;
parseCheck ( "#_$_='value'" ) ;
parseCheck ( "age" ) ;
parseCheck ( "getAge()" ) ;
parseCheck ( "get$age()" ) ;
parseCheck ( "age" ) ;
parseCheck ( "Age" ) ;
parseCheck ( "__age" ) ;
parseCheck ( "get__age()" ) ;
parseCheck ( "person.age" ) ;
parseCheck ( "person.getAge()" ) ;
parseCheck ( "person.get$age()" ) ;
parseCheck ( "person$1.age" ) ;
parseCheck ( "person_1.Age" ) ;
parseCheck ( "person_1.__age" ) ;
parseCheck ( "Person_1.get__age()" ) ;
}
@Test
void unsupportedCharactersInIdentifiers ( ) {
// Invalid syntax
assertThatIllegalStateException ( )
. isThrownBy ( ( ) - > parser . parseRaw ( "apple~banana" ) )
. withMessage ( "Unsupported character '~' (126) encountered at position 6 in expression." ) ;
// German characters
assertThatIllegalStateException ( )
. isThrownBy ( ( ) - > parser . parseRaw ( "begrüssung" ) )
. withMessage ( "Unsupported character 'ü' (252) encountered at position 5 in expression." ) ;
assertThatIllegalStateException ( )
. isThrownBy ( ( ) - > parser . parseRaw ( "Spaß" ) )
. withMessage ( "Unsupported character 'ß' (223) encountered at position 4 in expression." ) ;
// Spanish characters
assertThatIllegalStateException ( )
. isThrownBy ( ( ) - > parser . parseRaw ( "buenos_sueños" ) )
. withMessage ( "Unsupported character 'ñ' (241) encountered at position 11 in expression." ) ;
// Chinese characters
assertThatIllegalStateException ( )
. isThrownBy ( ( ) - > parser . parseRaw ( "have乐趣()" ) )
. withMessage ( "Unsupported character '乐' (20048) encountered at position 5 in expression." ) ;
}
@Test
void literalNull ( ) {
parseCheck ( "null" ) ;