Skip to content

Instantly share code, notes, and snippets.

@dannyduc
Created November 5, 2013 00:49
Show Gist options
  • Save dannyduc/7312002 to your computer and use it in GitHub Desktop.
Save dannyduc/7312002 to your computer and use it in GitHub Desktop.
@Test
public void addTodo() throws Exception {
final Todo formObject = new Todo();
formObject.setTitle("my title");
formObject.setDescription("some description");
mockMvc.perform(post("/todo/add")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.with(new RequestPostProcessor() {
@Override
public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
IntegrationTestUtil.addParameters(formObject, request);
return request;
}
})
).andDo(print())
.andExpect(status().is(302))
.andExpect(view().name("redirect:/todo/update/{id}"))
.andExpect(redirectedUrl("/todo/update/1"))
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment