I18nResources { public Locale getLocale(String languageRanges) { if ((languageRanges == null) || languageRanges.isEmpty()) { return null; } try { return Locale.lookup(Locale.LanguageRange.parse(languageRanges), i18nResources.keySet()); } catch (IllegalArgumentException e) { return null; } }  void addI18nResource(Locale locale, Properties i18n); Locale getLocale(String languageRanges); String getMessage(Locale locale, String messageKey, Object[] messageParams, String defaultMessage);  }
@Test(dataProvider = "locales") public void testGetLocale(String localeString, Locale expectedLocale) { I18nResources i18nResources = createI18nResources(); Assert.assertEquals(i18nResources.getLocale(localeString), expectedLocale); }