File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
ahao-spring-boot-jwt/src/test/java/com/ahao/spring/boot/jwt
ahao-spring-boot-validator/src/test/java/moe/ahao/spring/boot/validator Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 7
7
import org .junit .jupiter .api .extension .ExtendWith ;
8
8
import org .springframework .beans .factory .annotation .Autowired ;
9
9
import org .springframework .boot .test .context .SpringBootTest ;
10
+ import org .springframework .http .MediaType ;
10
11
import org .springframework .test .context .ContextConfiguration ;
11
12
import org .springframework .test .context .junit .jupiter .SpringExtension ;
12
13
import org .springframework .test .web .servlet .MockMvc ;
@@ -98,7 +99,8 @@ void failByNoToken() throws Exception {
98
99
MockMvc mockMvc = MockMvcBuilders .webAppContextSetup (wac ).build ();
99
100
100
101
String responseString = mockMvc .perform (get ("/test" )
101
- .param ("msg" , "hello" ))
102
+ .param ("msg" , "hello" )
103
+ .accept (MediaType .APPLICATION_JSON_UTF8 ))
102
104
.andExpect (status ().is5xxServerError ())
103
105
.andDo (print ())
104
106
.andReturn ()
Original file line number Diff line number Diff line change 8
8
import org .junit .jupiter .api .extension .ExtendWith ;
9
9
import org .springframework .beans .factory .annotation .Autowired ;
10
10
import org .springframework .boot .test .context .SpringBootTest ;
11
+ import org .springframework .http .MediaType ;
11
12
import org .springframework .test .context .ContextConfiguration ;
12
13
import org .springframework .test .context .junit .jupiter .SpringExtension ;
13
14
import org .springframework .test .web .servlet .MockMvc ;
@@ -31,7 +32,7 @@ public class ValidatorTest {
31
32
@ Test
32
33
public void test1 () throws Exception {
33
34
MockMvc mockMvc = MockMvcBuilders .webAppContextSetup (wac ).build ();
34
- String responseString = mockMvc .perform (get ("/hello" ))
35
+ String responseString = mockMvc .perform (get ("/hello" ). accept ( MediaType . APPLICATION_JSON_UTF8 ) )
35
36
.andExpect (status ().isOk ())
36
37
.andDo (print ())
37
38
.andReturn ()
You can’t perform that action at this time.
0 commit comments