LocaleUtil { public static String getCanonicalCharset(String charset) { return Charset.forName(charset).name(); }  static boolean isLocaleSupported(Locale locale); static boolean isCharsetSupported(String charset); static Locale parseLocale(String localeString); static String getCanonicalCharset(String charset); static List<String> calculateBundleNames(String baseName, Locale locale); static List<String> calculateBundleNames(String baseName, Locale locale, boolean noext); static LocaleInfo getSystem(); static LocaleInfo getDefault(); static LocaleInfo setDefault(Locale locale); static LocaleInfo setDefault(Locale locale, String charset); static LocaleInfo setDefault(LocaleInfo localeInfo); static void resetDefault(); static LocaleInfo getContext(); static LocaleInfo setContext(Locale locale); static LocaleInfo setContext(Locale locale, String charset); static LocaleInfo setContext(LocaleInfo localeInfo); static void resetContext();  }
@Test public void getCanonicalCharset() { assertEquals("ISO-8859-1", LocaleUtil.getCanonicalCharset("8859_1")); assertEquals("ISO-8859-1", LocaleUtil.getCanonicalCharset("ISO8859_1")); try { LocaleUtil.getCanonicalCharset("aaaabbbbcccc"); fail("Expected UnsupportedCharsetException"); } catch (UnsupportedCharsetException e) { } try { LocaleUtil.getCanonicalCharset("aaaa<bbbb>cccc"); fail("Expected IllegalCharsetNameException"); } catch (IllegalCharsetNameException e) { } }