Affects: 5.4.3
HttpEncodingAutoConfiguration
is not added to the WebMvcTest
slice. Not sure if this is intentional but when running with full auto-configuration this configuration is loaded in the application context. When starting a test application context with @WebMvcTest
the CharacterEncodingFilter
provided by the HttpEncodingAutoConfiguration
is not added which makes http request processing different in those tests compared to @SpringBootTest
or production application context. By default that filter makes request character encoding always UTF-8. see (filter config with default utf-8 being forced for requests)
This is triggered by spring-projects/spring-framework#22788. That made us use MediaType.APPLICATION_JSON
(without the character encoding) for the requests during WebMvcTest
s.
Comment From: bclozel
Indeed, the WebMvcTypeExcludeFilter
includes FilterRegistrationBean
but not the HttpEncodingAutoConfiguration
, which configures the CharacterEncodingFilter
if the configuration property is set.