### Question:
LocaleUtility implements GlobalPropertyListener { public static Locale fromSpecification(String localeSpecification) { Locale createdLocale = null; localeSpecification = localeSpecification.trim(); String[] localeComponents = localeSpecification.split("_"); if (localeComponents.length == 1) { createdLocale = new Locale(localeComponents[0]); } else if (localeComponents.length == 2) { createdLocale = new Locale(localeComponents[0], localeComponents[1]); } else if (localeComponents.length > 2) { String variant = localeSpecification.substring(localeSpecification.indexOf(localeComponents[2])); createdLocale = new Locale(localeComponents[0], localeComponents[1], variant); } return createdLocale; }  static Locale getDefaultLocale(); static boolean areCompatible(Locale lhs, Locale rhs); static Locale fromSpecification(String localeSpecification); static Set<Locale> getLocalesInOrder(); static void setDefaultLocaleCache(Locale defaultLocaleCache); static void setLocalesAllowedListCache(List<Locale> localesAllowedListCache); @Override void globalPropertyChanged(GlobalProperty newValue); @Override void globalPropertyDeleted(String propertyName); @Override boolean supportsPropertyName(String propertyName); static boolean isValid(Locale locale);  }### Answer:
@Test public void fromSpecification_shouldGetLocaleFromTwoCharacterLanguageCode() { Assert.assertEquals(Locale.ENGLISH, LocaleUtility.fromSpecification("en")); }
@Test public void fromSpecification_shouldGetLocaleFromLanguageCodeAndCountryCode() { Assert.assertEquals(Locale.UK, LocaleUtility.fromSpecification("en_GB")); }
@Test public void fromSpecification_shouldGetLocaleFromLanguageCodeCountryCodeAndVariant() { Locale locale = LocaleUtility.fromSpecification("en_US_Traditional_WIN"); Assert.assertEquals(Locale.US.getLanguage(), locale.getLanguage()); Assert.assertEquals(Locale.US.getCountry(), locale.getCountry()); Assert.assertEquals("Traditional,WIN", locale.getDisplayVariant()); }
@Test @Verifies(value = "should get locale from two character language code", method = "fromSpecification(String)") public void fromSpecification_shouldGetLocaleFromTwoCharacterLanguageCode() throws Exception { Assert.assertEquals(Locale.ENGLISH, LocaleUtility.fromSpecification("en")); }
@Test @Verifies(value = "should get locale from language code and country code", method = "fromSpecification(String)") public void fromSpecification_shouldGetLocaleFromLanguageCodeAndCountryCode() throws Exception { Assert.assertEquals(Locale.UK, LocaleUtility.fromSpecification("en_GB")); }
@Test @Verifies(value = "should get locale from language code country code and variant", method = "fromSpecification(String)") public void fromSpecification_shouldGetLocaleFromLanguageCodeCountryCodeAndVariant() throws Exception { Locale locale = LocaleUtility.fromSpecification("en_US_Traditional_WIN"); Assert.assertEquals(Locale.US.getLanguage(), locale.getLanguage()); Assert.assertEquals(Locale.US.getCountry(), locale.getCountry()); Assert.assertEquals("Traditional,WIN", locale.getDisplayVariant()); }