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 22
33import com .jayway .jsonpath .InvalidPathException ;
44
5+ import java .util .Locale ;
6+
57public enum RelationalOperator {
68
79 GTE (">=" ),
@@ -40,9 +42,10 @@ public enum RelationalOperator {
4042 this .operatorString = operatorString ;
4143 }
4244
43- public static RelationalOperator fromString (String operatorString ){
45+ public static RelationalOperator fromString (String operatorString ) {
46+ String upperCaseOperatorString = operatorString .toUpperCase (Locale .ROOT );
4447 for (RelationalOperator operator : RelationalOperator .values ()) {
45- if (operator .operatorString .equals (operatorString . toUpperCase () ) ){
48+ if (operator .operatorString .equals (upperCaseOperatorString ) ){
4649 return operator ;
4750 }
4851 }
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