### Question:
LocaleUtils { public static List<Locale> parseAcceptLanguage(final String header) { if (header == null || header.isEmpty()) { return Collections.emptyList(); } final List<Locale> result = new ArrayList<>(); for (final String str : header.split(",")) { final String[] arr = str.trim().replace("-", "_").split(";"); final Locale locale; final String[] l = arr[0].split("_"); switch (l.length) { case 2: locale = new Locale(l[0], l[1]); break; case 3: locale = new Locale(l[0], l[1], l[2]); break; default: locale = new Locale(l[0]); break; } result.add(locale); } return result; } LocaleUtils(); static List<Locale> parseAcceptLanguage(final String header);  }### Answer:
@Test public void testNull() { final List<Locale> list = LocaleUtils.parseAcceptLanguage(null); assertTrue(list.isEmpty()); }
@Test public void testEmpty() { final List<Locale> list = LocaleUtils.parseAcceptLanguage(""); assertTrue(list.isEmpty()); }
@Test public void testWild() { final List<Locale> list = LocaleUtils.parseAcceptLanguage("*"); assertEquals(1, list.size()); assertEquals("*", list.get(0).getLanguage()); }
@Test public void testMultiple() { final List<Locale> list = LocaleUtils.parseAcceptLanguage("en, fr"); assertEquals(2, list.size()); assertEquals("en", list.get(0).getLanguage()); assertEquals("fr", list.get(1).getLanguage()); }
@Test public void testMultipleWithCountry() { final List<Locale> list = LocaleUtils.parseAcceptLanguage("en-US, fr"); assertEquals(2, list.size()); assertEquals("en", list.get(0).getLanguage()); assertEquals("US", list.get(0).getCountry()); assertEquals("fr", list.get(1).getLanguage()); }
@Test public void testVariant() { final List<Locale> list = LocaleUtils.parseAcceptLanguage("de-DE-1996"); assertEquals(1, list.size()); assertEquals("de", list.get(0).getLanguage()); assertEquals("DE", list.get(0).getCountry()); assertEquals("1996", list.get(0).getVariant()); }