LocaleHeaderDelegate implements RuntimeDelegate.HeaderDelegate<Locale> { @Override public Locale fromString(String header) { if (header == null) { throw new IllegalArgumentException(); } header = removeWhitespaces(header); int p = scan(header, ','); if (charAtIs(header, p, ',')) { header = header.substring(0, p); } p = scan(header, '-'); if (charAtIs(header, p, '-')) { return new Locale(header.substring(0, p), header.substring(p + 1)); } return new Locale(header); }  @Override Locale fromString(String header); @Override String toString(Locale locale);  }
@UseDataProvider("forFomString") @Test public void fromString(String header, Locale expectedResult) { Locale locale = localeHeaderDelegate.fromString(header); assertEquals(expectedResult, locale); }
@Test(expected = IllegalArgumentException.class) public void throwsExceptionWhenLanguageHeaderIsNull() throws Exception { localeHeaderDelegate.fromString(null); }