author | okutsu |
Fri, 17 Jun 2016 17:06:16 +0900 | |
changeset 39051 | 1b0204c55914 |
parent 38747 | 469920616f3a |
child 39734 | 7701942a1e7b |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
2 |
* Copyright (c) 2016, 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. |
|
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 |
import java.nio.file.Path; |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
25 |
import java.util.Arrays; |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
26 |
import java.util.ArrayList; |
36511 | 27 |
import java.util.List; |
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
28 |
import java.util.Locale; |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
29 |
import java.util.stream.Collectors; |
36511 | 30 |
|
31 |
import jdk.tools.jlink.plugin.Plugin; |
|
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
32 |
import jdk.tools.jlink.plugin.PluginException; |
36511 | 33 |
import jdk.tools.jlink.internal.PluginRepository; |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
34 |
import jdk.tools.jlink.internal.TaskHelper; |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
35 |
import jdk.tools.jlink.internal.plugins.PluginsResourceBundle; |
36511 | 36 |
import tests.Helper; |
37 |
import tests.JImageGenerator; |
|
38 |
import tests.JImageValidator; |
|
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
39 |
import tests.Result; |
36511 | 40 |
|
41 |
/* |
|
42 |
* @test |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
43 |
* @bug 8152143 8152704 8155649 |
36511 | 44 |
* @summary IncludeLocalesPlugin tests |
45 |
* @author Naoto Sato |
|
46 |
* @library ../../lib |
|
47 |
* @modules java.base/jdk.internal.jimage |
|
48 |
* jdk.jdeps/com.sun.tools.classfile |
|
49 |
* jdk.jlink/jdk.tools.jlink.internal |
|
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
50 |
* jdk.jlink/jdk.tools.jlink.internal.plugins |
36511 | 51 |
* jdk.jlink/jdk.tools.jmod |
52 |
* jdk.jlink/jdk.tools.jimage |
|
53 |
* jdk.compiler |
|
54 |
* @build tests.* |
|
55 |
* @build tools.jlink.plugins.GetAvailableLocales |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
56 |
* @run main/othervm -Xmx1g IncludeLocalesPluginTest |
36511 | 57 |
*/ |
58 |
public class IncludeLocalesPluginTest { |
|
59 |
||
60 |
private final static String moduleName = "IncludeLocalesTest"; |
|
61 |
private static Helper helper; |
|
62 |
private final static int INCLUDE_LOCALES_OPTION = 0; |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
63 |
private final static int ADDMODS_OPTION = 1; |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
64 |
private final static int EXPECTED_LOCATIONS = 2; |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
65 |
private final static int UNEXPECTED_PATHS = 3; |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
66 |
private final static int AVAILABLE_LOCALES = 4; |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
67 |
private final static int ERROR_MESSAGE = 5; |
36511 | 68 |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
69 |
private static int errors; |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
70 |
|
36511 | 71 |
private final static Object[][] testData = { |
72 |
// without --include-locales option: should include all locales |
|
73 |
{ |
|
74 |
"", |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
75 |
"jdk.localedata", |
36511 | 76 |
List.of( |
77 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
78 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
79 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
80 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", |
|
81 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
82 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
83 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", |
|
84 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), |
|
85 |
List.of(), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
86 |
Arrays.stream(Locale.getAvailableLocales()) |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
87 |
// "(root)" for Locale.ROOT rather than "" |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
88 |
.map(loc -> loc.equals(Locale.ROOT) ? "(root)" : loc.toString()) |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
89 |
.collect(Collectors.toList()), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
90 |
"", |
36511 | 91 |
}, |
92 |
||
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
93 |
// All English and Japanese locales |
36511 | 94 |
{ |
95 |
"--include-locales=en,ja", |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
96 |
"jdk.localedata", |
36511 | 97 |
List.of( |
98 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
99 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
100 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
101 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class"), |
|
102 |
List.of( |
|
103 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
104 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
105 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
106 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
107 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
108 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
109 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", |
|
110 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", |
|
111 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
112 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
113 |
"(root)", "en", "en_001", "en_150", "en_AG", "en_AI", "en_AS", "en_AT", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
114 |
"en_AU", "en_BB", "en_BE", "en_BI", "en_BM", "en_BS", "en_BW", "en_BZ", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
115 |
"en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
116 |
"en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
117 |
"en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GU", "en_GY", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
118 |
"en_HK", "en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
119 |
"en_KE", "en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
120 |
"en_MH", "en_MO", "en_MP", "en_MS", "en_MT", "en_MU", "en_MW", "en_MY", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
121 |
"en_NA", "en_NF", "en_NG", "en_NL", "en_NR", "en_NU", "en_NZ", "en_PG", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
122 |
"en_PH", "en_PK", "en_PN", "en_PR", "en_PW", "en_RW", "en_SB", "en_SC", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
123 |
"en_SD", "en_SE", "en_SG", "en_SH", "en_SI", "en_SL", "en_SS", "en_SX", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
124 |
"en_SZ", "en_TC", "en_TK", "en_TO", "en_TT", "en_TV", "en_TZ", "en_UG", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
125 |
"en_UM", "en_US", "en_US_POSIX", "en_VC", "en_VG", "en_VI", "en_VU", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
126 |
"en_WS", "en_ZA", "en_ZM", "en_ZW", "ja", "ja_JP", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
127 |
"ja_JP_JP_#u-ca-japanese"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
128 |
"", |
36511 | 129 |
}, |
130 |
||
131 |
// All locales in India |
|
132 |
{ |
|
133 |
"--include-locales=*-IN", |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
134 |
"jdk.localedata", |
36511 | 135 |
List.of( |
136 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_IN.class", |
|
137 |
"/jdk.localedata/sun/text/resources/ext/FormatData_hi_IN.class", |
|
138 |
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class", |
|
139 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
140 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class", |
|
141 |
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_kok_IN.class", |
|
38747 | 142 |
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_pa_Guru_IN.class"), |
36511 | 143 |
List.of( |
144 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
145 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
146 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
147 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
148 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
149 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
150 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
151 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
152 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", |
|
153 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
154 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", |
|
155 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
156 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
157 |
"(root)", "as_IN", "bn_IN", "bo_IN", "brx_IN", "en", /* "en_001", */ |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
158 |
"en_IN", "en_US", "en_US_POSIX", "gu_IN", "hi_IN", "kn_IN", "kok_IN", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
159 |
"ks_IN", "ml_IN", "mr_IN", "ne_IN", "or_IN", "pa_IN", "pa_IN_#Guru", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
160 |
"ta_IN", "te_IN", "ur_IN"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
161 |
"", |
36511 | 162 |
}, |
163 |
||
164 |
// Thai |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
165 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
166 |
"--include-locales=th", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
167 |
"jdk.localedata", |
36511 | 168 |
List.of( |
169 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
170 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
171 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
172 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
173 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
174 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class"), |
|
175 |
List.of( |
|
176 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
177 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
178 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", |
|
179 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
180 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
181 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
182 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
183 |
"(root)", "en", "en_US", "en_US_POSIX", "th", "th_TH", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
184 |
"th_TH_TH_#u-nu-thai"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
185 |
"", |
36511 | 186 |
}, |
187 |
||
188 |
// Hong Kong |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
189 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
190 |
"--include-locales=zh-HK", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
191 |
"jdk.localedata", |
36511 | 192 |
List.of( |
193 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", |
|
194 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_HK.class", |
|
195 |
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_TW.class", |
|
196 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), |
|
197 |
List.of( |
|
198 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
199 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
200 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
201 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
202 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
203 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
204 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
205 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
206 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
207 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
208 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
209 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
210 |
"(root)", "en", "en_US", "en_US_POSIX", "zh_HK", "zh_HK_#Hans", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
211 |
"zh_HK_#Hant"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
212 |
"", |
36511 | 213 |
}, |
214 |
||
215 |
// Norwegian |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
216 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
217 |
"--include-locales=nb,nn,no", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
218 |
"jdk.localedata", |
36511 | 219 |
List.of( |
220 |
"/jdk.localedata/sun/text/resources/ext/FormatData_no.class", |
|
221 |
"/jdk.localedata/sun/text/resources/ext/FormatData_no_NO.class", |
|
222 |
"/jdk.localedata/sun/text/resources/ext/FormatData_no_NO_NY.class", |
|
223 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nb.class", |
|
224 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nn.class"), |
|
225 |
List.of( |
|
226 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
227 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
228 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
229 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
230 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
231 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
232 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
233 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
234 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
235 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
236 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
237 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
238 |
"(root)", "en", "en_US", "en_US_POSIX", "nb", "nb_NO", "nb_SJ", "nn", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
239 |
"nn_NO", "no", "no_NO", "no_NO_NY"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
240 |
"", |
36511 | 241 |
}, |
242 |
||
243 |
// Hebrew/Indonesian/Yiddish |
|
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
244 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
245 |
"--include-locales=he,id,yi", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
246 |
"jdk.localedata", |
36511 | 247 |
List.of( |
248 |
"/jdk.localedata/sun/text/resources/ext/FormatData_in.class", |
|
249 |
"/jdk.localedata/sun/text/resources/ext/FormatData_in_ID.class", |
|
250 |
"/jdk.localedata/sun/text/resources/ext/FormatData_iw.class", |
|
251 |
"/jdk.localedata/sun/text/resources/ext/FormatData_iw_IL.class", |
|
252 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_in.class", |
|
253 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_iw.class", |
|
254 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ji.class"), |
|
255 |
List.of( |
|
256 |
"/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", |
|
257 |
"/jdk.localedata/sun/text/resources/thai_dict", |
|
258 |
"/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", |
|
259 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", |
|
260 |
"/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", |
|
261 |
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", |
|
262 |
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", |
|
263 |
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class", |
|
264 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", |
|
265 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", |
|
266 |
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
267 |
List.of( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
268 |
"(root)", "en", "en_US", "en_US_POSIX", "in", "in_ID", "iw", "iw_IL", |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
269 |
"ji", "ji_001"), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
270 |
"", |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
271 |
}, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
272 |
|
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
273 |
// Error case: No matching locales |
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
274 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
275 |
"--include-locales=xyz", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
276 |
"jdk.localedata", |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
277 |
null, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
278 |
null, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
279 |
null, |
36739
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
280 |
new PluginException(String.format( |
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
281 |
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"), "xyz")) |
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
282 |
.getMessage(), |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
283 |
}, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
284 |
|
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
285 |
// Error case: Invalid argument |
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
286 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
287 |
"--include-locales=en,zh_HK", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
288 |
"jdk.localedata", |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
289 |
null, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
290 |
null, |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
291 |
null, |
36739
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
292 |
new PluginException(String.format( |
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
293 |
PluginsResourceBundle.getMessage("include-locales.invalidtag"), "zh_HK")) |
145210aba850
8152704: jlink command line output/help message improvement
naoto
parents:
36666
diff
changeset
|
294 |
.getMessage(), |
36511 | 295 |
}, |
37790
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
296 |
|
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
297 |
// Error case: jdk.localedata is not added |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
298 |
{ |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
299 |
"--include-locales=en-US", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
300 |
"java.base", |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
301 |
null, |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
302 |
null, |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
303 |
null, |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
304 |
new PluginException( |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
305 |
PluginsResourceBundle.getMessage("include-locales.localedatanotfound")) |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
306 |
.getMessage(), |
71c730d5e73a
8155649: IncludeLocalesPlugin throws NPE when jdk.localedata not resolved
naoto
parents:
36739
diff
changeset
|
307 |
}, |
36511 | 308 |
}; |
309 |
||
310 |
public static void main(String[] args) throws Exception { |
|
311 |
helper = Helper.newHelper(); |
|
312 |
if (helper == null) { |
|
313 |
System.err.println("Test not run"); |
|
314 |
return; |
|
315 |
} |
|
316 |
helper.generateDefaultModules(); |
|
317 |
||
318 |
for (Object[] data : testData) { |
|
319 |
// create image for each test data |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
320 |
System.out.println("Invoking jlink with \"" + data[INCLUDE_LOCALES_OPTION] + "\""); |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
321 |
Result result = JImageGenerator.getJLinkTask() |
36511 | 322 |
.modulePath(helper.defaultModulePath()) |
323 |
.output(helper.createNewImageDir(moduleName)) |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
324 |
.addMods((String) data[ADDMODS_OPTION]) |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
325 |
.option((String) data[INCLUDE_LOCALES_OPTION]) |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
326 |
.call(); |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
327 |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
328 |
String errorMsg = (String) data[ERROR_MESSAGE]; |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
329 |
if (errorMsg.isEmpty()) { |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
330 |
Path image = result.assertSuccess(); |
36511 | 331 |
|
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
332 |
// test locale data entries |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
333 |
testLocaleDataEntries(image, |
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
334 |
(List<String>) data[EXPECTED_LOCATIONS], |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
335 |
(List<String>) data[UNEXPECTED_PATHS]); |
36511 | 336 |
|
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
337 |
// test available locales |
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
338 |
testAvailableLocales(image, (List<String>) data[AVAILABLE_LOCALES]); |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
339 |
} else { |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
340 |
result.assertFailure(new TaskHelper(TaskHelper.JLINK_BUNDLE) |
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
341 |
.getMessage("error.prefix") + " " +errorMsg); |
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
342 |
System.out.println("\tExpected failure: " + result.getMessage()); |
36666
bf6dce37a2f0
8152143: jlink --include-locales should gracefully detect certain user error
naoto
parents:
36511
diff
changeset
|
343 |
} |
36511 | 344 |
} |
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
345 |
|
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
346 |
if (errors > 0) { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
347 |
throw new RuntimeException("Test failed"); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
348 |
} |
36511 | 349 |
} |
350 |
||
351 |
private static void testLocaleDataEntries(Path image, List<String> expectedLocations, |
|
352 |
List<String> unexpectedPaths) throws Exception { |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
353 |
System.out.println("testLocaleDataEntries:"); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
354 |
try { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
355 |
JImageValidator.validate( |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
356 |
image.resolve("lib").resolve("modules"), |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
357 |
expectedLocations, unexpectedPaths); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
358 |
} catch (Exception e) { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
359 |
System.out.println("\tFailed with: " + e); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
360 |
e.printStackTrace(); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
361 |
errors++; |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
362 |
} |
36511 | 363 |
} |
364 |
||
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
365 |
private static void testAvailableLocales(Path image, List<String> availableLocales) throws Exception { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
366 |
System.out.println("testAvailableLocales:"); |
36511 | 367 |
Path launcher = image.resolve("bin/java" + |
368 |
(System.getProperty("os.name").startsWith("Windows") ? ".exe" : "")); |
|
39051
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
369 |
List<String> args = new ArrayList<>(availableLocales.size() + 2); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
370 |
args.add(launcher.toString()); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
371 |
args.add("GetAvailableLocales"); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
372 |
args.addAll(availableLocales); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
373 |
Process proc = new ProcessBuilder(args).inheritIO().start(); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
374 |
|
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
375 |
int len = Math.min(10, args.size()); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
376 |
String command = args.subList(0, len).stream().collect(Collectors.joining(" ")) |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
377 |
+ (len < availableLocales.size() ? " ..." : ""); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
378 |
|
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
379 |
int status = proc.waitFor(); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
380 |
if (status == 0) { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
381 |
System.out.println("\tDone\t" + command); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
382 |
} else { |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
383 |
System.out.println("\tExit " + status + "\t" + command); |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
384 |
errors++; |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
385 |
} |
1b0204c55914
8158272: IncludeLocalesPluginTest.java fails with timeout
okutsu
parents:
38747
diff
changeset
|
386 |
System.out.println(); |
36511 | 387 |
} |
388 |
} |