Code example for MockMvc

Methods: perform

0
 
    @Test 
    public void testCancel() throws Exception { 
        log.debug("testing cancel..."); 
 
        mockMvc.perform((post("/userform") 
            .param("cancel", ""))) 
            .andExpect(redirectedUrl("/home")); 
    } 
 
    @Test 
    public void testEdit() throws Exception { 
        log.debug("testing edit..."); 
 
        HttpSession session = mockMvc.perform(post("/j_security_check") 
            .param("j_username", "admin").param("j_password", "admin")) 
            .andExpect(status().is(HttpStatus.FOUND.value())) 
            .andExpect(redirectedUrl("/")) 
            .andReturn() 
            .getRequest() 
Contextual code suggestions in your IDE  Get Codota for Java