MockMvcController { @RequestMapping(value = "/postByJson", method = RequestMethod.POST) String postByJson(@RequestBody Role role, String method) { logger.info("role: {}; method: {}", role.toString(), method); return SUCCESS; }    }
@Test public void testPostByJson() throws Exception{ mockMvc.perform(post("/mock/postByJson") .param("method", "getPost") .content(objectMapper.writeValueAsString(new Role(2, "ROLE_USER"))).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is(200)) .andExpect(content().string("success")); }