Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

.perform()에 .andReturn(); 를 추가하고  MvcResult 로 받음

 

MvcResult result = 
this.mockMvc.perform(
post("/users/regist")
.param("name", "Joe")
.param("age", "56")
.andDo(print())
.andExpect(status().isOk())
.andReturn();
String content = result.getResponse().getContentAsString();

ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
UserRegistResult user = mapper.readValue(content, UserRegistResult.class);

System.err.println("JSon Result=" + mapper.defaultPrettyPrintingWriter().writeValueAsString(user));

assertTrue(user.getResult().equals("ok"));
  • No labels