@Before public void setup() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); for (int i = 0; i < 5; i++) { Party party = PartyDAOTest.buildParty(); partyDAO.insert(party); if (i == 3) { lastId = party.getId(); } System.out.println(party); } }
@Test public void createTest() throws Exception { Party party = PartyDAOTest.buildParty(); String content = JSON.toJSONString(party); this.mockMvc .perform( post("/party/create") .accept(MediaType.APPLICATION_JSON) .characterEncoding("UTF-8") .content(content) .contentType(MediaType.APPLICATION_JSON) .header(CommonHeader.CLIENT_VERSION_HEADER, "0.0.2")) .andExpect(status().isOk()) .andDo( result -> { result.getResponse().setCharacterEncoding("UTF-8"); String resContent = result.getResponse().getContentAsString(); System.out.println(resContent); }); }