1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @test
28 * @bug 4397357 6565620 6959267 7070436 7198195 8032446 8072600
29 * @summary Confirm normal case mappings are handled correctly.
30 * @run main/timeout=200 UnicodeCasingTest
31 */
32
33 import java.io.BufferedReader;
34 import java.io.IOException;
35 import java.nio.file.Files;
36 import java.nio.file.Paths;
37 import java.util.ArrayList;
38 import java.util.Locale;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42
43 public class UnicodeCasingTest {
44
45 private static boolean err = false;
46
47 // Locales which are used for testing
48 private static List<Locale> locales = new ArrayList<>();
49 static {
53
54 // Default locale
55 private static String defaultLang;
56
57 // List for Unicode characters whose mappings are included in
58 // SpecialCasing.txt and mappings in UnicodeData.txt isn't applicable.
59 private static Map<String, String> excludeList = new HashMap<>();
60
61 public static void main(String[] args) {
62 UnicodeCasingTest specialCasingTest = new UnicodeCasingTest();
63 specialCasingTest.test();
64 }
65
66 private void test() {
67 Locale defaultLocale = Locale.getDefault();
68 BufferedReader in = null;
69 try {
70 // First, we create exlude lists of characters whose mappings exist
71 // in SpecialCasing.txt and mapping rules in UnicodeData.txt aren't
72 // applicable.
73 in = Files.newBufferedReader(Paths.get(System.getProperty("test.src.path"), "..", "/Character/SpecialCasing.txt")
74 .toRealPath());
75 String line;
76 while ((line = in.readLine()) != null) {
77 if (line.length() == 0 || line.charAt(0) == '#') {
78 continue;
79 }
80 updateExcludeList(line);
81 }
82 in.close();
83 in = null;
84 int locale_num = locales.size();
85 for (int l = 0; l < locale_num; l++) {
86 Locale locale = locales.get(l);
87 Locale.setDefault(locale);
88 defaultLang = locale.getLanguage();
89 // System.out.println("Testing on " + locale + " locale....");
90 System.err.println("Testing on " + locale + " locale....");
91 in = Files.newBufferedReader(Paths.get(System.getProperty("test.src.path"), "..", "/Character/UnicodeData.txt")
92 .toRealPath());
93 while ((line = in.readLine()) != null) {
94 if (line.length() == 0 || line.charAt(0) == '#') {
95 continue;
96 }
97 test(line);
98 }
99 in.close();
100 in = null;
101 }
102 }
103 catch (IOException e) {
104 err = true;
105 e.printStackTrace();
106 }
107 finally {
108 if (in != null) {
109 try {
110 in.close();
111 }
112 catch (IOException e) {
|
1 /*
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @test
28 * @bug 4397357 6565620 6959267 7070436 7198195 8032446 8072600 8221431
29 * @summary Confirm normal case mappings are handled correctly.
30 * @library /lib/testlibrary/java/lang
31 * @run main/timeout=200 UnicodeCasingTest
32 */
33
34 import java.io.BufferedReader;
35 import java.io.IOException;
36 import java.nio.file.Files;
37 import java.nio.file.Paths;
38 import java.util.ArrayList;
39 import java.util.Locale;
40 import java.util.HashMap;
41 import java.util.List;
42 import java.util.Map;
43
44 public class UnicodeCasingTest {
45
46 private static boolean err = false;
47
48 // Locales which are used for testing
49 private static List<Locale> locales = new ArrayList<>();
50 static {
54
55 // Default locale
56 private static String defaultLang;
57
58 // List for Unicode characters whose mappings are included in
59 // SpecialCasing.txt and mappings in UnicodeData.txt isn't applicable.
60 private static Map<String, String> excludeList = new HashMap<>();
61
62 public static void main(String[] args) {
63 UnicodeCasingTest specialCasingTest = new UnicodeCasingTest();
64 specialCasingTest.test();
65 }
66
67 private void test() {
68 Locale defaultLocale = Locale.getDefault();
69 BufferedReader in = null;
70 try {
71 // First, we create exlude lists of characters whose mappings exist
72 // in SpecialCasing.txt and mapping rules in UnicodeData.txt aren't
73 // applicable.
74 in = Files.newBufferedReader(UCDFiles.SPECIAL_CASING.toRealPath());
75 String line;
76 while ((line = in.readLine()) != null) {
77 if (line.length() == 0 || line.charAt(0) == '#') {
78 continue;
79 }
80 updateExcludeList(line);
81 }
82 in.close();
83 in = null;
84 int locale_num = locales.size();
85 for (int l = 0; l < locale_num; l++) {
86 Locale locale = locales.get(l);
87 Locale.setDefault(locale);
88 defaultLang = locale.getLanguage();
89 // System.out.println("Testing on " + locale + " locale....");
90 System.err.println("Testing on " + locale + " locale....");
91 in = Files.newBufferedReader(UCDFiles.UNICODE_DATA.toRealPath());
92 while ((line = in.readLine()) != null) {
93 if (line.length() == 0 || line.charAt(0) == '#') {
94 continue;
95 }
96 test(line);
97 }
98 in.close();
99 in = null;
100 }
101 }
102 catch (IOException e) {
103 err = true;
104 e.printStackTrace();
105 }
106 finally {
107 if (in != null) {
108 try {
109 in.close();
110 }
111 catch (IOException e) {
|