File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/test/java/com/somemore/support Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11package com .somemore .support ;
22
33
4+ import static org .springframework .test .web .servlet .result .MockMvcResultHandlers .print ;
5+
46import com .fasterxml .jackson .databind .ObjectMapper ;
7+ import org .junit .jupiter .api .BeforeEach ;
58import org .springframework .beans .factory .annotation .Autowired ;
69import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
710import org .springframework .boot .test .context .SpringBootTest ;
811import org .springframework .test .context .ActiveProfiles ;
912import org .springframework .test .web .servlet .MockMvc ;
13+ import org .springframework .test .web .servlet .setup .MockMvcBuilders ;
14+ import org .springframework .web .context .WebApplicationContext ;
15+ import org .springframework .web .filter .CharacterEncodingFilter ;
1016
1117@ ActiveProfiles ("test" )
1218@ SpringBootTest
@@ -16,6 +22,17 @@ public abstract class ControllerTestSupport {
1622 @ Autowired
1723 protected MockMvc mockMvc ;
1824
25+ @ Autowired
26+ private WebApplicationContext ctx ;
27+
1928 @ Autowired
2029 protected ObjectMapper objectMapper ;
30+
31+ @ BeforeEach
32+ public void setup () {
33+ this .mockMvc = MockMvcBuilders .webAppContextSetup (ctx )
34+ .addFilters (new CharacterEncodingFilter ("UTF-8" , true ))
35+ .alwaysDo (print ())
36+ .build ();
37+ }
2138}
You can’t perform that action at this time.
0 commit comments