author | nishjain |
Fri, 17 Jun 2016 21:42:38 +0900 | |
changeset 39053 | 668c400a8dd1 |
permissions | -rw-r--r-- |
39053
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
1 |
/* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
4 |
* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
8 |
* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
13 |
* accompanied this code). |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
14 |
* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
18 |
* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
21 |
* questions. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
22 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
23 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
24 |
/* |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
25 |
* @test |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
26 |
* @bug 8159420 |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
27 |
* @summary Checks the proper execution of LanguageRange.parse() and |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
28 |
* other LocaleMatcher methods when used in the locales like |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
29 |
* Turkish, because the toLowerCase() method is invoked in the |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
30 |
* parse() and other LocaleMatcher methods. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
31 |
* e.g. "HI-Deva".toLowerCase() in the Turkish locale returns |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
32 |
* "hı-deva", where 'ı' is the LATIN SMALL LETTER DOTLESS I character |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
33 |
* which is not allowed in the language ranges/tags. |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
34 |
* @compile -encoding utf-8 Bug8159420.java |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
35 |
* @run main Bug8159420 |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
36 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
37 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
38 |
import java.util.List; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
39 |
import java.util.Locale; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
40 |
import java.util.Locale.LanguageRange; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
41 |
import java.util.Locale.FilteringMode; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
42 |
import java.util.LinkedHashMap; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
43 |
import java.util.HashMap; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
44 |
import java.util.Iterator; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
45 |
import java.util.ArrayList; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
46 |
import static java.util.Locale.FilteringMode.EXTENDED_FILTERING; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
47 |
import static java.util.Locale.FilteringMode.AUTOSELECT_FILTERING; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
48 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
49 |
public class Bug8159420 { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
50 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
51 |
static boolean err = false; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
52 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
53 |
public static void main(String[] args) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
54 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
55 |
Locale origLocale = null; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
56 |
try { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
57 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
58 |
origLocale = Locale.getDefault(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
59 |
Locale.setDefault(new Locale("tr", "TR")); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
60 |
testParse(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
61 |
testFilter(EXTENDED_FILTERING); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
62 |
testFilter(AUTOSELECT_FILTERING); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
63 |
testLookup(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
64 |
testMapEquivalents(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
65 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
66 |
if (err) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
67 |
throw new RuntimeException("[LocaleMatcher method(s) in turkish" |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
68 |
+ " locale failed]"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
69 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
70 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
71 |
} finally { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
72 |
Locale.setDefault(origLocale); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
73 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
74 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
75 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
76 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
77 |
/* Before the fix, the testParse() method was throwing |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
78 |
* IllegalArgumentException in Turkish Locale |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
79 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
80 |
private static void testParse() { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
81 |
String ranges = "HI-Deva, ja-hIrA-JP, RKI"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
82 |
try { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
83 |
LanguageRange.parse(ranges); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
84 |
} catch (Exception ex) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
85 |
System.err.println("[testParse() failed on range string: " |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
86 |
+ ranges + "] due to "+ex); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
87 |
err = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
88 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
89 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
90 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
91 |
/* Before the fix, the testFilter() method was returning empty list in |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
92 |
* Turkish Locale |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
93 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
94 |
private static void testFilter(FilteringMode mode) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
95 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
96 |
String ranges = "hi-IN, itc-Ital"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
97 |
String tags = "hi-IN, itc-Ital"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
98 |
List<LanguageRange> priorityList = LanguageRange.parse(ranges); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
99 |
List<Locale> tagList = generateLocales(tags); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
100 |
String actualLocales = showLocales(Locale.filter(priorityList, tagList, mode)); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
101 |
String expectedLocales = "hi-IN, itc-Ital"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
102 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
103 |
if (!expectedLocales.equals(actualLocales)) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
104 |
System.err.println("testFilter(" + mode + ") failed on language ranges:" |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
105 |
+ " [" + ranges + "] and language tags: [" + tags + "]"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
106 |
err = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
107 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
108 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
109 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
110 |
/* Before the fix, the testLookup() method was returning null in Turkish |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
111 |
* Locale |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
112 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
113 |
private static void testLookup() { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
114 |
boolean error = false; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
115 |
String ranges = "hi-IN, itc-Ital"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
116 |
String tags = "hi-IN, itc-Ital"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
117 |
List<LanguageRange> priorityList = LanguageRange.parse(ranges); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
118 |
List<Locale> localeList = generateLocales(tags); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
119 |
Locale actualLocale |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
120 |
= Locale.lookup(priorityList, localeList); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
121 |
String actualLocaleString = ""; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
122 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
123 |
if (actualLocale != null) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
124 |
actualLocaleString = actualLocale.toLanguageTag(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
125 |
} else { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
126 |
error = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
127 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
128 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
129 |
String expectedLocale = "hi-IN"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
130 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
131 |
if (!expectedLocale.equals(actualLocaleString)) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
132 |
error = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
133 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
134 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
135 |
if (error) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
136 |
System.err.println("testLookup() failed on language ranges:" |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
137 |
+ " [" + ranges + "] and language tags: [" + tags + "]"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
138 |
err = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
139 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
140 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
141 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
142 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
143 |
/* Before the fix, testMapEquivalents() method was returning only "hi-in" |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
144 |
* in Turkish Locale |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
145 |
*/ |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
146 |
private static void testMapEquivalents() { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
147 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
148 |
String ranges = "HI-IN"; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
149 |
List<LanguageRange> priorityList = LanguageRange.parse(ranges); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
150 |
HashMap<String, List<String>> map = new LinkedHashMap<>(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
151 |
List<String> equivalentList = new ArrayList<>(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
152 |
equivalentList.add("HI"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
153 |
equivalentList.add("HI-Deva"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
154 |
map.put("HI", equivalentList); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
155 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
156 |
List<LanguageRange> expected = new ArrayList<>(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
157 |
expected.add(new LanguageRange("hi-in")); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
158 |
expected.add(new LanguageRange("hi-deva-in")); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
159 |
List<LanguageRange> got |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
160 |
= LanguageRange.mapEquivalents(priorityList, map); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
161 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
162 |
if (!areEqual(expected, got)) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
163 |
System.err.println("testMapEquivalents() failed"); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
164 |
err = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
165 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
166 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
167 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
168 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
169 |
private static boolean areEqual(List<LanguageRange> expected, |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
170 |
List<LanguageRange> got) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
171 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
172 |
boolean error = false; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
173 |
if (expected.equals(got)) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
174 |
return !error; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
175 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
176 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
177 |
List<LanguageRange> cloneExpected = new ArrayList<>(expected); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
178 |
cloneExpected.removeAll(got); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
179 |
if (!cloneExpected.isEmpty()) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
180 |
error = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
181 |
System.err.println("Found missing range(s): " + cloneExpected); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
182 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
183 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
184 |
// not creating the 'got' clone as the list will not be used after this |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
185 |
got.removeAll(expected); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
186 |
if (!got.isEmpty()) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
187 |
error = true; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
188 |
System.err.println("Found extra range(s): " + got); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
189 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
190 |
return !error; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
191 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
192 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
193 |
private static List<Locale> generateLocales(String tags) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
194 |
if (tags == null) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
195 |
return null; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
196 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
197 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
198 |
List<Locale> localeList = new ArrayList<>(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
199 |
if (tags.equals("")) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
200 |
return localeList; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
201 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
202 |
String[] t = tags.split(", "); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
203 |
for (String tag : t) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
204 |
localeList.add(Locale.forLanguageTag(tag)); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
205 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
206 |
return localeList; |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
207 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
208 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
209 |
private static String showLocales(List<Locale> locales) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
210 |
StringBuilder sb = new StringBuilder(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
211 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
212 |
Iterator<Locale> itr = locales.iterator(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
213 |
if (itr.hasNext()) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
214 |
sb.append(itr.next().toLanguageTag()); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
215 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
216 |
while (itr.hasNext()) { |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
217 |
sb.append(", "); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
218 |
sb.append(itr.next().toLanguageTag()); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
219 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
220 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
221 |
return sb.toString().trim(); |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
222 |
} |
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
223 |
|
668c400a8dd1
8159420: The LanguageRange.parse() method is throwing IllegalArgumentException in Turkish Locale
nishjain
parents:
diff
changeset
|
224 |
} |