| | |
| | | } |
| | | |
| | | |
| | | public void checkPost(String url,Object param) throws Exception{ |
| | | public JSONObject checkPost(String url,Object param) throws Exception{ |
| | | MockHttpServletRequestBuilder builder = BaseMockMvcRequestBuilders.post(url); |
| | | if(param != null){ |
| | | builder.content((new ObjectMapper()).valueToTree(param).toString());//请求的参数 |
| | |
| | | resultActions.andDo(print()); |
| | | //对数据进行预期的判断 |
| | | Assert.assertEquals("20000", response.getString("code")); |
| | | return response; |
| | | } |
| | | |
| | | public void checkGet(String url) throws Exception{ |
| | | public JSONObject checkGet(String url) throws Exception{ |
| | | MockHttpServletRequestBuilder builder = BaseMockMvcRequestBuilders.get(url); |
| | | ResultActions resultActions = mockMvc.perform(builder); |
| | | JSONObject response = ResultActionsUtil.getResponse(resultActions); |
| | |
| | | resultActions.andDo(print()); |
| | | //对数据进行预期的判断 |
| | | Assert.assertEquals("20000", response.getString("code")); |
| | | return response; |
| | | } |
| | | } |