diff --git a/2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java b/2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java index 880d2823..a7c66f81 100644 --- a/2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java +++ b/2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java @@ -9,6 +9,9 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.RequestBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.filter.CharacterEncodingFilter; + +import java.nio.charset.StandardCharsets; import static org.hamcrest.Matchers.equalTo; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @@ -24,7 +27,9 @@ public class Chapter21ApplicationTests { @Before public void setUp() { - mvc = MockMvcBuilders.standaloneSetup(new UserController()).build(); + mvc = MockMvcBuilders.standaloneSetup(new UserController()) + .addFilters(new CharacterEncodingFilter(StandardCharsets.UTF_8.name(), true)) + .build(); } @Test