File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
main/java/com/jayway/jsonpath/internal/filter
test/java/com/jayway/jsonpath/internal/filter Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .jayway .jsonpath .InvalidPathException ;
4
4
5
+ import java .util .Locale ;
6
+
5
7
public enum RelationalOperator {
6
8
7
9
GTE (">=" ),
@@ -40,9 +42,10 @@ public enum RelationalOperator {
40
42
this .operatorString = operatorString ;
41
43
}
42
44
43
- public static RelationalOperator fromString (String operatorString ){
45
+ public static RelationalOperator fromString (String operatorString ) {
46
+ String upperCaseOperatorString = operatorString .toUpperCase (Locale .ROOT );
44
47
for (RelationalOperator operator : RelationalOperator .values ()) {
45
- if (operator .operatorString .equals (operatorString . toUpperCase () ) ){
48
+ if (operator .operatorString .equals (upperCaseOperatorString ) ){
46
49
return operator ;
47
50
}
48
51
}
Original file line number Diff line number Diff line change
1
+ package com .jayway .jsonpath .internal .filter ;
2
+
3
+ import static org .junit .Assert .*;
4
+
5
+ import org .junit .After ;
6
+ import org .junit .Before ;
7
+ import org .junit .Test ;
8
+
9
+ import java .util .Locale ;
10
+
11
+ public class RelationalOperatorTest {
12
+
13
+ Locale locale ;
14
+
15
+ @ Before
16
+ public void saveDefaultLocale () {
17
+ locale = Locale .getDefault ();
18
+ }
19
+
20
+ @ After
21
+ public void restoreDefaultLocale () {
22
+ Locale .setDefault (locale );
23
+ }
24
+
25
+ @ Test
26
+ public void testFromStringWithEnglishLocale () {
27
+ Locale .setDefault (Locale .ENGLISH );
28
+ assertEquals (RelationalOperator .IN , RelationalOperator .fromString ("in" ));
29
+ assertEquals (RelationalOperator .IN , RelationalOperator .fromString ("IN" ));
30
+ }
31
+
32
+ @ Test
33
+ public void testFromStringWithTurkishLocale () {
34
+ Locale .setDefault (new Locale ("tr" , "TR" ));
35
+ assertEquals (RelationalOperator .IN , RelationalOperator .fromString ("in" ));
36
+ assertEquals (RelationalOperator .IN , RelationalOperator .fromString ("IN" ));
37
+ }
38
+
39
+ }
You can’t perform that action at this time.
0 commit comments