getAcceptLanguageAsLocale(s) returns most preferred Locale

An update on the last commit switching from:
List<Locale> getAcceptLanguageAsLocales() to
Locale getAcceptLanguageAsLocale()

This best supports the scenario for the most preferred Locale.
If there is a need to look at the prioritized list of languages it's
best to use Locale.filter with the LocaleRange's.

This is explained in the Javadoc for getAcceptLanguage().

Issue: SPR-15024
This commit is contained in:
Rossen Stoyanchev
2016-12-16 17:15:43 -05:00
parent fa56361ad2
commit bd8af55bc7
2 changed files with 15 additions and 15 deletions

View File

@@ -437,13 +437,7 @@ public class HttpHeadersTests {
);
assertEquals(expectedRanges, headers.getAcceptLanguage());
List<Locale> expectedLocales = Arrays.asList(
Locale.forLanguageTag("fr-ch"),
Locale.forLanguageTag("fr"),
Locale.forLanguageTag("en"),
Locale.forLanguageTag("de")
);
assertEquals(expectedLocales, headers.getAcceptLanguageAsLocales());
assertEquals(Locale.forLanguageTag("fr-ch"), headers.getAcceptLanguageAsLocale());
}
@Test