8
8
9
9
import org .hibernate .validator .internal .engine .messageinterpolation .InterpolationTermType ;
10
10
import org .hibernate .validator .internal .engine .messageinterpolation .parser .MessageDescriptorFormatException ;
11
+ import org .hibernate .validator .internal .engine .messageinterpolation .parser .Token ;
11
12
import org .hibernate .validator .internal .engine .messageinterpolation .parser .TokenCollector ;
13
+
14
+ import org .assertj .core .api .Assertions ;
15
+ import org .assertj .core .api .ListAssert ;
12
16
import org .testng .annotations .Test ;
13
17
14
18
/**
@@ -29,10 +33,25 @@ public void testParameterWithoutOpeningBraceThrowsException() throws Exception {
29
33
}
30
34
31
35
@ Test (expectedExceptions = MessageDescriptorFormatException .class , expectedExceptionsMessageRegExp = "HV000168.*" )
32
- public void testELExpressionWithoutOpeningBraceThrowsException () throws Exception {
36
+ public void testELExpressionDollarThenClosingBraceThrowsException () throws Exception {
33
37
new TokenCollector ( "$}" , InterpolationTermType .EL );
34
38
}
35
39
40
+ @ Test
41
+ public void testELExpressionDollarThenEscapeInterpretedAsLiterals () {
42
+ ListAssert <Token > assertion = Assertions .assertThat (
43
+ new TokenCollector ( "$\\ A{1+1}" , InterpolationTermType .EL )
44
+ .getTokenList ()
45
+ )
46
+ .hasSize ( 2 );
47
+ assertion .element ( 0 )
48
+ .returns ( "$\\ A" , Token ::getTokenValue )
49
+ .returns ( false , Token ::isParameter );
50
+ assertion .element ( 1 )
51
+ .returns ( "{1+1}" , Token ::getTokenValue )
52
+ .returns ( false , Token ::isParameter );
53
+ }
54
+
36
55
@ Test (expectedExceptions = MessageDescriptorFormatException .class , expectedExceptionsMessageRegExp = "HV000168.*" )
37
56
public void testTermWithoutClosingBraceThrowsException () throws Exception {
38
57
new TokenCollector ( "{foo" , InterpolationTermType .PARAMETER );
0 commit comments