-
Couldn't load subscription status.
- 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
I wrote simple controller:
@RestController
public class TestController {
@GetMapping("/api")
public Map<String, String> simpleTest() {
// here is the text with special characters, all in UTF-8
return Collections.singletonMap("test", "Příliš žluťoučký kůň úpěl ďábelské ódy");
}
}Also very simple tutorial-like test:
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void test() throws Exception {
this.mockMvc.perform(get("/api"))
.andDo(print())
.andExpect(jsonPath("$.test").value("Příliš žluťoučký kůň úpěl ďábelské ódy"));
}The test fails in version 5.2.0.M3 now. Test passes in the previous milestone version 5.2.0.M2 and earlier versions.
The issue is somehow related to deprecation of org.springframework.http.MediaType#APPLICATION_JSON_UTF8_VALUE.
Of course it is possible to fix the test by adding accept but I rather do not do that, because APPLICATION_JSON_UTF8_VALUE is deprecated now.
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE)I have also prepared simple maven project to simulate the problem.
springutf8.zip
It seems to me, that MockMvc client does not handle UTF-8 characters well, like other modern browsers.
JohannesFluegel, yanshenxian and InegoJohannesFluegel
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