mock mvc contrller test

@SpringBootTest
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
@Transactional
public class InterceptorTest {

    @Autowired
    private MockMvc mockMvc;

    @Before
    public void setUp() throws Exception {
    }

    @Test
    public void testServiceSecret() throws Exception {
        mockMvc.perform(get("/v1/status/xxx")
                .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON))
                .andDo(print())
                .andExpect(status().is5xxServerError());
    }
}

猜你喜欢

转载自blog.csdn.net/wuzhong8809/article/details/106413071