Content type expected:<application/json;charset=UTF-8> but was:<application/hal+json;charset=UTF-8>

来源:互联网 发布:军训合照能上传网络吗 编辑:程序博客网 时间:2024/06/10 04:55

spring boot junit测试时报错

解决方法:

    private MediaType contentType = new MediaType("application", "hal+json", Charset.forName("UTF-8"));

@Test    public void testGetUsers() throws Exception {mockMvc.perform(get("/api/user")).andExpect(status().isOk()).andExpect(content().contentType(contentType)).andExpect(jsonPath("$.errcode", is(0))).andExpect(jsonPath("$.p2pdata", notNullValue()));    }


阅读全文
0 0
原创粉丝点击