### Question:
LocaleUtil { public static Locale createLocale(String localeString) { String[] parts = localeString.split("[_-]", 3); switch (parts.length) { case 3: return new Locale(parts[0], parts[1], parts[2]); case 2: return new Locale(parts[0], parts[1]); case 1: return new Locale(parts[0]); default: throw new IllegalArgumentException("Invalid locale: " + localeString); } } private  LocaleUtil(); static Locale getLocaleConstant(String localeConstant); static Locale createLocale(String localeString); static Locale getLocale(String localeString);  }### Answer:
@Test public void testCreateLocale() { assertEquals(new Locale("en", "US"), createLocale("en-US")); assertEquals(new Locale("es"), createLocale("es")); assertEquals(new Locale("ko", "KR"), createLocale("ko-KR")); assertEquals(new Locale("es", "ES", "Traditional_WIN"), createLocale("es-ES-Traditional_WIN")); assertEquals(new Locale("en", "US", "Colorado"), createLocale("en-US-Colorado")); assertEquals(new Locale("en", "US", "Colorado-Boulder"), createLocale("en-US-Colorado-Boulder")); assertEquals(new Locale("de", "", "POSIX"), createLocale("de--POSIX")); assertEquals(new Locale("en"), createLocale("en")); assertEquals(new Locale("de", "DE"), createLocale("de_DE")); assertEquals(new Locale("", "GB"), createLocale("_GB")); assertEquals(new Locale("en", "US", "WIN"), createLocale("en_US_WIN")); assertEquals(new Locale("de", "", "POSIX"), createLocale("de__POSIX")); assertEquals(new Locale("fr", "", "MAC"), createLocale("fr__MAC")); }