-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regressionA bug that is also a regression
Milestone
Description
When MediaType.APPLICATION_JSON_UTF8
was deprecated, the content type of JSON that gets sent from a @RestController
changed to application/json
(without charset).
This breaks MockMvc
tests that use .andExpect(content().json())
. Here is a sample test:
@Test
public void returnsTheExpectedResponse() throws Exception {
mockMvc.perform(get("/"))
.andExpect(status().isOk())
.andExpect(content().json("{\"name\":\"Jürgen\"}"));
}
The test runs fine with Spring 5.1.9 but fails with Spring 5.2.0.RC2
java.lang.AssertionError: name
Expected: Jürgen
got: Jürgen
You can find a sample Spring Boot project to reproduce the problem at https://github.com/sgybas/mockmvc-json-utf8
There was a similar issue for jsonPath()
(#23219).
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regressionA bug that is also a regression