Skip to content

Commit 5697ca7

Browse files
committed
1 parent 12b07bb commit 5697ca7

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

2 files changed

+5
-2
lines changed

ahao-spring-boot-jwt/src/test/java/com/ahao/spring/boot/jwt/JwtTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.api.extension.ExtendWith;
88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.boot.test.context.SpringBootTest;
10+
import org.springframework.http.MediaType;
1011
import org.springframework.test.context.ContextConfiguration;
1112
import org.springframework.test.context.junit.jupiter.SpringExtension;
1213
import org.springframework.test.web.servlet.MockMvc;
@@ -98,7 +99,8 @@ void failByNoToken() throws Exception {
9899
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
99100

100101
String responseString = mockMvc.perform(get("/test")
101-
.param("msg", "hello"))
102+
.param("msg", "hello")
103+
.accept(MediaType.APPLICATION_JSON_UTF8))
102104
.andExpect(status().is5xxServerError())
103105
.andDo(print())
104106
.andReturn()

ahao-spring-boot-validator/src/test/java/moe/ahao/spring/boot/validator/ValidatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.jupiter.api.extension.ExtendWith;
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.boot.test.context.SpringBootTest;
11+
import org.springframework.http.MediaType;
1112
import org.springframework.test.context.ContextConfiguration;
1213
import org.springframework.test.context.junit.jupiter.SpringExtension;
1314
import org.springframework.test.web.servlet.MockMvc;
@@ -31,7 +32,7 @@ public class ValidatorTest {
3132
@Test
3233
public void test1() throws Exception {
3334
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))
3536
.andExpect(status().isOk())
3637
.andDo(print())
3738
.andReturn()

0 commit comments

Comments
 (0)