test/sun/text/resources/LocaleDataTest.java

Print this page

        

*** 33,45 **** * 6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259 * 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611 * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495 * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 ! * 7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 8017142 ! * 8037343 8055222 8042126 8074791 8075173 * @summary Verify locale data * */ /* * --- 33,47 ---- * 6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259 * 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611 * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495 * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 ! * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 ! * 8017142 8037343 8055222 8042126 8074791 8075173 * @summary Verify locale data + * @run main LocaleDataTest + * @run main LocaleDataTest -cldr * */ /* *
*** 97,107 **** * You can use language tag with '-' in locale field like this:<pre> * LocaleNames/sr-Latn/SR=Surinam * FormatData/sr-Latn-BA/DayNames/2=utorak</pre> * * The command-line syntax of this test is ! * <tt>java LocaleDataTest [-w] [{ -s | <filename> }]</tt> * * This program always sends its results to standard output. If -w is not specified, * this program prints out only the differences between the data file and the actual * resource data. If -w is specified, the program prints out every entry, comment, * and blank line from the data file. Where there is a difference between the data --- 99,109 ---- * You can use language tag with '-' in locale field like this:<pre> * LocaleNames/sr-Latn/SR=Surinam * FormatData/sr-Latn-BA/DayNames/2=utorak</pre> * * The command-line syntax of this test is ! * <tt>java LocaleDataTest [-w] [{ -s | <filename> }] [-cldr]</tt> * * This program always sends its results to standard output. If -w is not specified, * this program prints out only the differences between the data file and the actual * resource data. If -w is specified, the program prints out every entry, comment, * and blank line from the data file. Where there is a difference between the data
*** 115,124 **** --- 117,129 ---- * directory the program itself resides in. * * The -nothrow option prevents the program from throwing an exception when it * gets an error. -w implies -nothrow. * + * -cldr option specifies to test CLDR locale data. The default data file name for this + * option is "CLDRLocaleData". + * * Other command-line options can be specified, but are ignored. * * It's important to note what this test will NOT test. Certain changes to the locale * data are meant to have certain effects on the internationalization frameworks. For * instance, we could ensure round-trip formatting/parsing integrity for the full
*** 147,156 **** --- 152,163 ---- public class LocaleDataTest { static final String TEXT_RESOURCES_PACKAGE ="sun.text.resources"; static final String UTIL_RESOURCES_PACKAGE ="sun.util.resources"; + static final String DEFAULT_DATAFILE ="LocaleData"; + static String cldrSuffix = ""; public static void main(String[] args) throws Exception { // set up our flags and our input and output streams based on the // command-line arguments (exceptions generated here will propagate out
*** 167,185 **** } else if (args[i].equals("-nothrow")) doThrow = false; else if (args[i].equals("-s") && in == null) in = new BufferedReader(new EscapeReader(new InputStreamReader(System.in, "ISO8859_1"))); else if (!args[i].startsWith("-") && in == null) in = new BufferedReader(new EscapeReader(new InputStreamReader(new FileInputStream(args[i]), "ISO8859_1"))); } if (in == null) { ! File localeData = new File(System.getProperty("test.src", "."), "LocaleData"); in = new BufferedReader(new EscapeReader(new InputStreamReader(new FileInputStream(localeData), "ISO8859_1"))); } out = new PrintWriter(new EscapeWriter(new OutputStreamWriter(System.out, "ISO8859_1")), true); --- 174,196 ---- } else if (args[i].equals("-nothrow")) doThrow = false; + else if (args[i].equals("-cldr")) { + cldrSuffix = ".cldr"; + } + else if (args[i].equals("-s") && in == null) in = new BufferedReader(new EscapeReader(new InputStreamReader(System.in, "ISO8859_1"))); else if (!args[i].startsWith("-") && in == null) in = new BufferedReader(new EscapeReader(new InputStreamReader(new FileInputStream(args[i]), "ISO8859_1"))); } if (in == null) { ! File localeData = new File(System.getProperty("test.src", "."), DEFAULT_DATAFILE + cldrSuffix); in = new BufferedReader(new EscapeReader(new InputStreamReader(new FileInputStream(localeData), "ISO8859_1"))); } out = new PrintWriter(new EscapeWriter(new OutputStreamWriter(System.out, "ISO8859_1")), true);
*** 289,301 **** String fullName = null; if (rbName.equals("CalendarData") || rbName.equals("CurrencyNames") || rbName.equals("LocaleNames") || rbName.equals("TimeZoneNames")) { ! fullName = UTIL_RESOURCES_PACKAGE + "." + rbName; } else { ! fullName = TEXT_RESOURCES_PACKAGE + "." + rbName; } Locale locale; if (use_tag) { locale = Locale.forLanguageTag(localeName); } else { --- 300,312 ---- String fullName = null; if (rbName.equals("CalendarData") || rbName.equals("CurrencyNames") || rbName.equals("LocaleNames") || rbName.equals("TimeZoneNames")) { ! fullName = UTIL_RESOURCES_PACKAGE + cldrSuffix + "." + rbName; } else { ! fullName = TEXT_RESOURCES_PACKAGE + cldrSuffix + "." + rbName; } Locale locale; if (use_tag) { locale = Locale.forLanguageTag(localeName); } else {
*** 370,406 **** throw new NullPointerException(); } return null; } - private static final String CLDR = ".cldr"; - /** ! * Changes baseName to its per-language package name and * calls the super class implementation. For example, * if the baseName is "sun.text.resources.FormatData" and locale is ja_JP, ! * the baseName is changed to "sun.text.resources.ja.FormatData". If * baseName contains "cldr", such as "sun.text.resources.cldr.FormatData", ! * the name is changed to "sun.text.resources.cldr.jp.FormatData". */ @Override public String toBundleName(String baseName, Locale locale) { String newBaseName = baseName; String lang = locale.getLanguage(); if (lang.length() > 0) { ! if (baseName.startsWith(UTIL_RESOURCES_PACKAGE) ! || baseName.startsWith(TEXT_RESOURCES_PACKAGE)) { // Assume the lengths are the same. if (UTIL_RESOURCES_PACKAGE.length() != TEXT_RESOURCES_PACKAGE.length()) { throw new InternalError("The resources package names have different lengths."); } ! int index = TEXT_RESOURCES_PACKAGE.length(); ! if (baseName.indexOf(CLDR, index) > 0) { ! index += CLDR.length(); ! } ! newBaseName = baseName.substring(0, index + 1) + lang + baseName.substring(index); } } return super.toBundleName(newBaseName, locale); } --- 381,414 ---- throw new NullPointerException(); } return null; } /** ! * Changes baseName to its per-language/country package name and * calls the super class implementation. For example, * if the baseName is "sun.text.resources.FormatData" and locale is ja_JP, ! * the baseName is changed to "sun.text.resources.ja.JP.FormatData". If * baseName contains "cldr", such as "sun.text.resources.cldr.FormatData", ! * the name is changed to "sun.text.resources.cldr.ja.JP.FormatData". */ @Override public String toBundleName(String baseName, Locale locale) { String newBaseName = baseName; String lang = locale.getLanguage(); + String ctry = locale.getCountry(); if (lang.length() > 0) { ! if (baseName.startsWith(UTIL_RESOURCES_PACKAGE + cldrSuffix) ! || baseName.startsWith(TEXT_RESOURCES_PACKAGE + cldrSuffix)) { // Assume the lengths are the same. if (UTIL_RESOURCES_PACKAGE.length() != TEXT_RESOURCES_PACKAGE.length()) { throw new InternalError("The resources package names have different lengths."); } ! int index = (TEXT_RESOURCES_PACKAGE + cldrSuffix).length(); ! ctry = (ctry.length() == 2) ? ("." + ctry) : ""; ! newBaseName = baseName.substring(0, index + 1) + lang + ctry + baseName.substring(index); } } return super.toBundleName(newBaseName, locale); }