Code example for MockMvc

Methods: perform

0
        postRepository.deleteAll(); 
    } 
 
    @Test 
    public void getNewBlogPage() throws Exception { 
        mockMvc.perform(get("/admin/blog/new")) 
                .andExpect(status().isOk()) 
                .andExpect(content().contentTypeCompatibleWith("text/html")) 
                .andExpect(content().string(containsString("Add New Post"))); 
    } 
 
    @Test 
    public void redirectToPublishedPostAfterCreation() throws Exception { 
        MockHttpServletRequestBuilder createPostRequest = getCreatePostRequest(); 
        createPostRequest.param("title", "Post Title"); 
        createPostRequest.param("content", "My Content"); 
        createPostRequest.param("category", PostCategory.NEWS_AND_EVENTS.name()); 
        createPostRequest.param("draft", "false"); 
        createPostRequest.param("publishAt", "2013-07-01 13:15");