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"));
解决方法:
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())); }
相关文章推荐
- 获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>意义
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- 获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- <meta charset="utf-8"/>与<meta http-equiv="Content-Type">
- pageEncoding和charset 编码 以及<%@ page contentType="text/html; charset=utf-8"....>作用
- Retrofit学习"Content-Type: application/json;charset=UTF-8"@Body的使用
- (转)获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- <meta charset="gbk">或者<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">乱码
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>意义
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- HTML——<meta http-equiv="content-type" content="text/html; charset=UTF-8">
- 【HTML】明明加了<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />却还是乱码的可能原因
- Retrofit学习"Content-Type: application/json;charset=UTF-8"@Body的使用
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">是什么意思?
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>意义
- pageEncoding和charset 编码 以及<%@ page contentType="text/html; charset=utf-8"....>作用
- <%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%>这几个编码分别代表什么意思?
- 关于<meta http-equiv="Content-Type" content="text/html:charset=UTF-8">
- Content type 'application/json;charset=UTF-8' not