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());
    }
}

你可能感兴趣的:(#,java,web,-,测试)