Code example for MockMvc

Methods: perform

0
        MockHttpServletRequestBuilder composeMessage = 
            post("/") 
                .param("summary", "New Message") 
                .param("text", "This is a new message"); 
 
        mvc.perform(composeMessage) 
            .andExpect(status().isForbidden()); 
    } 
 
    @Test 
    @WithMockUser 
    public void composeMessage() throws Exception { 
        MockHttpServletRequestBuilder composeMessage = 
            post("/") 
                .param("summary", "New Message") 
                .param("text", "This is a new message") 
                .with(csrf()); 
 
        mvc.perform(composeMessage) 
            .andExpect(redirectedUrlPattern("/*"));