From 7971f6b63804b32aaf29c37ffef94722ddf49cab Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 28 Jul 2014 19:12:39 +0300 Subject: [PATCH] Document that mock request doesn't support Accept-Language header This commit updates the Javadoc for getLocale() and getLocales() in MockHttpServletRequest to point out that the mock implementation does not comply with the the Servlet specification with regard to the Accept-Language header. Issue: SPR-12043 --- .../mock/web/MockHttpServletRequest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java index f4228b3b3c..f28a3008e4 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java @@ -634,11 +634,37 @@ public class MockHttpServletRequest implements HttpServletRequest { this.locales.addAll(locales); } + /** + * Returns the first preferred {@linkplain Locale locale} configured + * in this mock request. + *

If no locales have been explicitly configured, the default, + * preferred {@link Locale} for the server mocked by this + * request is {@link Locale#ENGLISH}. + *

In contrast to the Servlet specification, this mock implementation + * does not take into consideration any locales + * specified via the {@code Accept-Language} header. + * @see javax.servlet.ServletRequest#getLocale() + * @see #addPreferredLocale(Locale) + * @see #setPreferredLocales(List) + */ @Override public Locale getLocale() { return this.locales.get(0); } + /** + * Returns an {@linkplain Enumeration enumeration} of the preferred + * {@linkplain Locale locales} configured in this mock request. + *

If no locales have been explicitly configured, the default, + * preferred {@link Locale} for the server mocked by this + * request is {@link Locale#ENGLISH}. + *

In contrast to the Servlet specification, this mock implementation + * does not take into consideration any locales + * specified via the {@code Accept-Language} header. + * @see javax.servlet.ServletRequest#getLocales() + * @see #addPreferredLocale(Locale) + * @see #setPreferredLocales(List) + */ @Override public Enumeration getLocales() { return Collections.enumeration(this.locales);