< prev index next >

test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java

Print this page

  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432
 27  *      8258795 8267038 8287180 8302512 8304761 8306031 8308021
 28  * @summary Checks the IANA language subtag registry data update
 29  *          (LSR Revision: 2023-05-11) with Locale and Locale.LanguageRange
 30  *          class methods.
 31  * @run main LanguageSubtagRegistryTest
 32  */
 33 
 34 import java.util.ArrayList;
 35 import java.util.Iterator;
 36 import java.util.Locale;
 37 import java.util.List;
 38 import java.util.Locale.LanguageRange;
 39 import java.util.Locale.FilteringMode;
 40 import static java.util.Locale.FilteringMode.EXTENDED_FILTERING;
 41 
 42 public class LanguageSubtagRegistryTest {
 43 
 44     static boolean err = false;
 45 
 46     private static final String ACCEPT_LANGUAGE =
 47         "Accept-Language: aam, adp, aeb, ajs, aog, apc, ajp, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema,"
 48         + " en-gb-oed, gti, iba, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm,"
 49         + " ngv, nns, ola, oyb, pat, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx,"
 50         + " umi, uss, uth, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4";
 51     private static final List<LanguageRange> EXPECTED_RANGE_LIST = List.of(
 52             new LanguageRange("aam", 1.0),
 53             new LanguageRange("aas", 1.0),
 54             new LanguageRange("adp", 1.0),
 55             new LanguageRange("dz", 1.0),
 56             new LanguageRange("aeb", 1.0),
 57             new LanguageRange("ar-aeb", 1.0),
 58             new LanguageRange("ajt", 1.0),
 59             new LanguageRange("ajs", 1.0),
 60             new LanguageRange("sgn-ajs", 1.0),
 61             new LanguageRange("aog", 1.0),
 62             new LanguageRange("myd", 1.0),
 63             new LanguageRange("apc", 1.0),
 64             new LanguageRange("ar-apc", 1.0),
 65             new LanguageRange("ar-ajp", 1.0),
 66             new LanguageRange("ajp", 1.0),
 67             new LanguageRange("aue", 1.0),
 68             new LanguageRange("ktz", 1.0),
 69             new LanguageRange("bcg", 1.0),
 70             new LanguageRange("bgm", 1.0),

 85             new LanguageRange("zh-csp", 1.0),
 86             new LanguageRange("csx", 1.0),
 87             new LanguageRange("sgn-csx", 1.0),
 88             new LanguageRange("dif", 1.0),
 89             new LanguageRange("dit", 1.0),
 90             new LanguageRange("dmw", 1.0),
 91             new LanguageRange("xrq", 1.0),
 92             new LanguageRange("dsz", 1.0),
 93             new LanguageRange("sgn-dsz", 1.0),
 94             new LanguageRange("ehs", 1.0),
 95             new LanguageRange("sgn-ehs", 1.0),
 96             new LanguageRange("ema", 1.0),
 97             new LanguageRange("uok", 1.0),
 98             new LanguageRange("en-gb-oed", 1.0),
 99             new LanguageRange("en-gb-oxendict", 1.0),
100             new LanguageRange("gti", 1.0),
101             new LanguageRange("nyc", 1.0),
102             new LanguageRange("iba", 1.0),
103             new LanguageRange("snb", 1.0),
104             new LanguageRange("blg", 1.0),


105             new LanguageRange("jks", 1.0),
106             new LanguageRange("sgn-jks", 1.0),
107             new LanguageRange("kdz", 1.0),
108             new LanguageRange("ncp", 1.0),
109             new LanguageRange("kjh", 1.0),
110             new LanguageRange("zkb", 1.0),
111             new LanguageRange("kmb", 1.0),
112             new LanguageRange("smd", 1.0),
113             new LanguageRange("koj", 1.0),
114             new LanguageRange("kwv", 1.0),
115             new LanguageRange("kru", 1.0),
116             new LanguageRange("kxl", 1.0),
117             new LanguageRange("ksp", 1.0),
118             new LanguageRange("lak", 1.0),
119             new LanguageRange("kwq", 1.0),
120             new LanguageRange("yam", 1.0),
121             new LanguageRange("kxe", 1.0),
122             new LanguageRange("tvd", 1.0),
123             new LanguageRange("kzk", 1.0),
124             new LanguageRange("gli", 1.0),
125             new LanguageRange("drr", 1.0),
126             new LanguageRange("lgs", 1.0),
127             new LanguageRange("sgn-lgs", 1.0),
128             new LanguageRange("lii", 1.0),
129             new LanguageRange("raq", 1.0),
130             new LanguageRange("lmm", 1.0),
131             new LanguageRange("rmx", 1.0),
132             new LanguageRange("lsb", 1.0),
133             new LanguageRange("sgn-lsb", 1.0),
134             new LanguageRange("lsc", 1.0),
135             new LanguageRange("sgn-lsc", 1.0),
136             new LanguageRange("lsn", 1.0),
137             new LanguageRange("sgn-lsn", 1.0),
138             new LanguageRange("lsv", 1.0),
139             new LanguageRange("sgn-lsv", 1.0),
140             new LanguageRange("lsw", 1.0),
141             new LanguageRange("sgn-lsw", 1.0),
142             new LanguageRange("lvi", 1.0),


143             new LanguageRange("mtm", 1.0),
144             new LanguageRange("ymt", 1.0),
145             new LanguageRange("ngv", 1.0),
146             new LanguageRange("nnx", 1.0),
147             new LanguageRange("nns", 1.0),
148             new LanguageRange("nbr", 1.0),
149             new LanguageRange("ola", 1.0),
150             new LanguageRange("thw", 1.0),
151             new LanguageRange("oyb", 1.0),
152             new LanguageRange("thx", 1.0),
153             new LanguageRange("skk", 1.0),
154             new LanguageRange("jeg", 1.0),
155             new LanguageRange("pat", 1.0),
156             new LanguageRange("kxr", 1.0),


157             new LanguageRange("phr", 1.0),
158             new LanguageRange("pmu", 1.0),
159             new LanguageRange("plu", 1.0),
160             new LanguageRange("kgm", 1.0),
161             new LanguageRange("pnd", 1.0),
162             new LanguageRange("pub", 1.0),
163             new LanguageRange("puz", 1.0),
164             new LanguageRange("rib", 1.0),
165             new LanguageRange("sgn-rib", 1.0),
166             new LanguageRange("rnb", 1.0),
167             new LanguageRange("sgn-rnb", 1.0),
168             new LanguageRange("rsn", 1.0),
169             new LanguageRange("sgn-rsn", 1.0),
170             new LanguageRange("scv", 1.0),
171             new LanguageRange("zir", 1.0),
172             new LanguageRange("snz", 1.0),
173             new LanguageRange("asd", 1.0),
174             new LanguageRange("sqx", 1.0),
175             new LanguageRange("sgn-sqx", 1.0),
176             new LanguageRange("suj", 1.0),
177             new LanguageRange("szy", 1.0),
178             new LanguageRange("taj", 1.0),
179             new LanguageRange("tsf", 1.0),
180             new LanguageRange("tdg", 1.0),
181             new LanguageRange("tmk", 1.0),
182             new LanguageRange("tjj", 1.0),
183             new LanguageRange("tjp", 1.0),
184             new LanguageRange("tpn", 1.0),
185             new LanguageRange("tpw", 1.0),
186             new LanguageRange("tvx", 1.0),
187             new LanguageRange("umi", 1.0),
188             new LanguageRange("szd", 1.0),
189             new LanguageRange("uss", 1.0),
190             new LanguageRange("uth", 1.0),




191             new LanguageRange("ysm", 1.0),
192             new LanguageRange("sgn-ysm", 1.0),
193             new LanguageRange("zko", 1.0),
194             new LanguageRange("xss", 1.0),
195             new LanguageRange("wkr", 0.9),
196             new LanguageRange("ar-hyw", 0.8),
197             new LanguageRange("yug", 0.5),
198             new LanguageRange("yuu", 0.5),
199             new LanguageRange("gfx", 0.4),
200             new LanguageRange("oun", 0.4),
201             new LanguageRange("mwj", 0.4),
202             new LanguageRange("vaj", 0.4)
203         );
204 
205     public static void main(String[] args) {
206         testLanguageRange();
207         testLocale();
208 
209         if (err) {
210             throw new RuntimeException("Failed.");

  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8025703 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432
 27  *      8258795 8267038 8287180 8302512 8304761 8306031 8308021
 28  * @summary Checks the IANA language subtag registry data update
 29  *          (LSR Revision: 2023-05-11) with Locale and Locale.LanguageRange
 30  *          class methods.
 31  * @run main LanguageSubtagRegistryTest
 32  */
 33 
 34 import java.util.ArrayList;
 35 import java.util.Iterator;
 36 import java.util.Locale;
 37 import java.util.List;
 38 import java.util.Locale.LanguageRange;
 39 import java.util.Locale.FilteringMode;
 40 import static java.util.Locale.FilteringMode.EXTENDED_FILTERING;
 41 
 42 public class LanguageSubtagRegistryTest {
 43 
 44     static boolean err = false;
 45 
 46     private static final String ACCEPT_LANGUAGE =
 47         "Accept-Language: aam, adp, aeb, ajs, aog, apc, ajp, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema,"
 48         + " en-gb-oed, gti, iba, ilw, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, meg, mtm,"
 49         + " ngv, nns, ola, oyb, pat, pcr, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx,"
 50         + " umi, uss, uth, xia, yos, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4";
 51     private static final List<LanguageRange> EXPECTED_RANGE_LIST = List.of(
 52             new LanguageRange("aam", 1.0),
 53             new LanguageRange("aas", 1.0),
 54             new LanguageRange("adp", 1.0),
 55             new LanguageRange("dz", 1.0),
 56             new LanguageRange("aeb", 1.0),
 57             new LanguageRange("ar-aeb", 1.0),
 58             new LanguageRange("ajt", 1.0),
 59             new LanguageRange("ajs", 1.0),
 60             new LanguageRange("sgn-ajs", 1.0),
 61             new LanguageRange("aog", 1.0),
 62             new LanguageRange("myd", 1.0),
 63             new LanguageRange("apc", 1.0),
 64             new LanguageRange("ar-apc", 1.0),
 65             new LanguageRange("ar-ajp", 1.0),
 66             new LanguageRange("ajp", 1.0),
 67             new LanguageRange("aue", 1.0),
 68             new LanguageRange("ktz", 1.0),
 69             new LanguageRange("bcg", 1.0),
 70             new LanguageRange("bgm", 1.0),

 85             new LanguageRange("zh-csp", 1.0),
 86             new LanguageRange("csx", 1.0),
 87             new LanguageRange("sgn-csx", 1.0),
 88             new LanguageRange("dif", 1.0),
 89             new LanguageRange("dit", 1.0),
 90             new LanguageRange("dmw", 1.0),
 91             new LanguageRange("xrq", 1.0),
 92             new LanguageRange("dsz", 1.0),
 93             new LanguageRange("sgn-dsz", 1.0),
 94             new LanguageRange("ehs", 1.0),
 95             new LanguageRange("sgn-ehs", 1.0),
 96             new LanguageRange("ema", 1.0),
 97             new LanguageRange("uok", 1.0),
 98             new LanguageRange("en-gb-oed", 1.0),
 99             new LanguageRange("en-gb-oxendict", 1.0),
100             new LanguageRange("gti", 1.0),
101             new LanguageRange("nyc", 1.0),
102             new LanguageRange("iba", 1.0),
103             new LanguageRange("snb", 1.0),
104             new LanguageRange("blg", 1.0),
105             new LanguageRange("ilw", 1.0),
106             new LanguageRange("gal", 1.0),
107             new LanguageRange("jks", 1.0),
108             new LanguageRange("sgn-jks", 1.0),
109             new LanguageRange("kdz", 1.0),
110             new LanguageRange("ncp", 1.0),
111             new LanguageRange("kjh", 1.0),
112             new LanguageRange("zkb", 1.0),
113             new LanguageRange("kmb", 1.0),
114             new LanguageRange("smd", 1.0),
115             new LanguageRange("koj", 1.0),
116             new LanguageRange("kwv", 1.0),
117             new LanguageRange("kru", 1.0),
118             new LanguageRange("kxl", 1.0),
119             new LanguageRange("ksp", 1.0),
120             new LanguageRange("lak", 1.0),
121             new LanguageRange("kwq", 1.0),
122             new LanguageRange("yam", 1.0),
123             new LanguageRange("kxe", 1.0),
124             new LanguageRange("tvd", 1.0),
125             new LanguageRange("kzk", 1.0),
126             new LanguageRange("gli", 1.0),
127             new LanguageRange("drr", 1.0),
128             new LanguageRange("lgs", 1.0),
129             new LanguageRange("sgn-lgs", 1.0),
130             new LanguageRange("lii", 1.0),
131             new LanguageRange("raq", 1.0),
132             new LanguageRange("lmm", 1.0),
133             new LanguageRange("rmx", 1.0),
134             new LanguageRange("lsb", 1.0),
135             new LanguageRange("sgn-lsb", 1.0),
136             new LanguageRange("lsc", 1.0),
137             new LanguageRange("sgn-lsc", 1.0),
138             new LanguageRange("lsn", 1.0),
139             new LanguageRange("sgn-lsn", 1.0),
140             new LanguageRange("lsv", 1.0),
141             new LanguageRange("sgn-lsv", 1.0),
142             new LanguageRange("lsw", 1.0),
143             new LanguageRange("sgn-lsw", 1.0),
144             new LanguageRange("lvi", 1.0),
145             new LanguageRange("meg", 1.0),
146             new LanguageRange("cir", 1.0),
147             new LanguageRange("mtm", 1.0),
148             new LanguageRange("ymt", 1.0),
149             new LanguageRange("ngv", 1.0),
150             new LanguageRange("nnx", 1.0),
151             new LanguageRange("nns", 1.0),
152             new LanguageRange("nbr", 1.0),
153             new LanguageRange("ola", 1.0),
154             new LanguageRange("thw", 1.0),
155             new LanguageRange("oyb", 1.0),
156             new LanguageRange("thx", 1.0),
157             new LanguageRange("skk", 1.0),
158             new LanguageRange("jeg", 1.0),
159             new LanguageRange("pat", 1.0),
160             new LanguageRange("kxr", 1.0),
161             new LanguageRange("pcr", 1.0),
162             new LanguageRange("adx", 1.0),
163             new LanguageRange("phr", 1.0),
164             new LanguageRange("pmu", 1.0),
165             new LanguageRange("plu", 1.0),
166             new LanguageRange("kgm", 1.0),
167             new LanguageRange("pnd", 1.0),
168             new LanguageRange("pub", 1.0),
169             new LanguageRange("puz", 1.0),
170             new LanguageRange("rib", 1.0),
171             new LanguageRange("sgn-rib", 1.0),
172             new LanguageRange("rnb", 1.0),
173             new LanguageRange("sgn-rnb", 1.0),
174             new LanguageRange("rsn", 1.0),
175             new LanguageRange("sgn-rsn", 1.0),
176             new LanguageRange("scv", 1.0),
177             new LanguageRange("zir", 1.0),
178             new LanguageRange("snz", 1.0),
179             new LanguageRange("asd", 1.0),
180             new LanguageRange("sqx", 1.0),
181             new LanguageRange("sgn-sqx", 1.0),
182             new LanguageRange("suj", 1.0),
183             new LanguageRange("szy", 1.0),
184             new LanguageRange("taj", 1.0),
185             new LanguageRange("tsf", 1.0),
186             new LanguageRange("tdg", 1.0),
187             new LanguageRange("tmk", 1.0),
188             new LanguageRange("tjj", 1.0),
189             new LanguageRange("tjp", 1.0),
190             new LanguageRange("tpn", 1.0),
191             new LanguageRange("tpw", 1.0),
192             new LanguageRange("tvx", 1.0),
193             new LanguageRange("umi", 1.0),
194             new LanguageRange("szd", 1.0),
195             new LanguageRange("uss", 1.0),
196             new LanguageRange("uth", 1.0),
197             new LanguageRange("xia", 1.0),
198             new LanguageRange("acn", 1.0),
199             new LanguageRange("yos", 1.0),
200             new LanguageRange("zom", 1.0),
201             new LanguageRange("ysm", 1.0),
202             new LanguageRange("sgn-ysm", 1.0),
203             new LanguageRange("zko", 1.0),
204             new LanguageRange("xss", 1.0),
205             new LanguageRange("wkr", 0.9),
206             new LanguageRange("ar-hyw", 0.8),
207             new LanguageRange("yug", 0.5),
208             new LanguageRange("yuu", 0.5),
209             new LanguageRange("gfx", 0.4),
210             new LanguageRange("oun", 0.4),
211             new LanguageRange("mwj", 0.4),
212             new LanguageRange("vaj", 0.4)
213         );
214 
215     public static void main(String[] args) {
216         testLanguageRange();
217         testLocale();
218 
219         if (err) {
220             throw new RuntimeException("Failed.");
< prev index next >