22 */ |
22 */ |
23 /** |
23 /** |
24 * @test |
24 * @test |
25 * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 |
25 * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 |
26 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 |
26 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 |
27 * 4147315 4147317 4147552 4335196 4778440 5010672 6475525 6544471 6627549 6786276 |
27 * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549 |
|
28 * 6786276 |
28 * @summary test Locales |
29 * @summary test Locales |
29 */ |
30 */ |
30 /* |
31 /* |
31 * |
32 * |
32 * |
33 * |
893 " for locale '" + locale + "' rather than exception" ); |
894 " for locale '" + locale + "' rather than exception" ); |
894 } catch(MissingResourceException e) { } |
895 } catch(MissingResourceException e) { } |
895 } |
896 } |
896 |
897 |
897 /** |
898 /** |
898 * @bug 4147317 |
899 * @bug 4147317 4940539 |
899 * java.util.Locale.getISO3Language() works wrong for non ISO-3166 codes. |
900 * java.util.Locale.getISO3Language() works wrong for non ISO-639 codes. |
900 * Should throw an exception for unknown locales |
901 * Should throw an exception for unknown locales, except they have three |
|
902 * letter language codes. |
901 */ |
903 */ |
902 public void Test4147317() { |
904 public void Test4147317() { |
903 // Try with codes that are the wrong length but happen to match text |
905 // Try a three letter language code, and check whether it is |
904 // at a valid offset in the mapping table |
906 // returned as is. |
905 Locale locale = new Locale("aaa", "CCC"); |
907 Locale locale = new Locale("aaa", "CCC"); |
906 |
908 |
|
909 String result = locale.getISO3Language(); |
|
910 if (!result.equals("aaa")) { |
|
911 errln("ERROR: getISO3Language() returns: " + result + |
|
912 " for locale '" + locale + "' rather than returning it as is" ); |
|
913 } |
|
914 |
|
915 // Try an invalid two letter language code, and check whether it |
|
916 // throws a MissingResourceException. |
|
917 locale = new Locale("zz", "CCC"); |
|
918 |
907 try { |
919 try { |
908 String result = locale.getISO3Language(); |
920 result = locale.getISO3Language(); |
909 |
921 |
910 errln("ERROR: getISO3Language() returns: " + result + |
922 errln("ERROR: getISO3Language() returns: " + result + |
911 " for locale '" + locale + "' rather than exception" ); |
923 " for locale '" + locale + "' rather than exception" ); |
912 } catch(MissingResourceException e) { } |
924 } catch(MissingResourceException e) { } |
913 } |
925 } |