您的位置:首页 > 移动开发

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

2017-12-08 16:08 1101 查看
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()));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐