Examples of MvcResult


Examples of org.springframework.test.web.servlet.MvcResult

        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog/" + post.getPublicSlug())).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertTrue(html.select("a.author").isEmpty());
        assertThat(html.text(), containsString("Hidden Author"));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

        return builder.parse(new ByteArrayInputStream(atomFeed.getBytes()));
    }

    private Document doGetForDocument(String path) throws Exception {
        ResultActions resultActions = mockMvc.perform(get(path));
        MvcResult mvcResult = resultActions.andReturn();
        return getAtomFeedDocument(mvcResult);
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    public void containsBlogPostFields() throws Exception {
        Post post = PostBuilder.post().category(PostCategory.ENGINEERING).isBroadcast().build();
        postRepository.save(post);

        ResultActions resultActions = mockMvc.perform(get("/blog.atom"));
        MvcResult mvcResult = resultActions
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("application/atom+xml"))
                .andReturn();

        assertThat(mvcResult.getResponse().getCharacterEncoding(), equalTo("utf-8"));

        String atomFeed = mvcResult.getResponse().getContentAsString();
        assertThat(atomFeed, containsString(post.getTitle()));
        assertThat(atomFeed, containsString(post.getRenderedContent()));

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setTimeZone(DateFactory.DEFAULT_TIME_ZONE);
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    @Autowired
    private PostRepository postRepository;

    @Test
    public void showsBlogIndex() throws Exception {
        MvcResult result = mockMvc.perform(get("/blog")).andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html")).andReturn();

        Document document = Jsoup.parse(result.getResponse().getContentAsString());
        assertThat(document.select("ul.nav li.active").text(), equalTo("Blog"));

        assertThat(document.select(".secondary-nav .blog-category.active").text(), equalTo("All Posts"));

        assertThat(document.select(".content--title.blog-category.active").text(), equalTo("The Spring Blog"));
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    @Test
    public void given1Post_blogIndexShowsPostSummary() throws Exception {
        Post post = createSinglePost();

        MvcResult response = mockMvc.perform(get("/blog"))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html")).andReturn();

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select(".blog--title a").first().text(), is(post.getTitle()));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

        String content = summary;
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
        assertThat(response, not(containsString("Read more")));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

        }
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
        assertThat(response, containsString("Read more"));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    @Test
    public void givenManyPosts_blogIndexShowsLatest10PostSummaries() throws Exception {
        createManyPostsInNovember(11);

        MvcResult response = mockMvc.perform(get("/blog"))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html")).andReturn();

        Document html = Jsoup.parse(response.getResponse().getContentAsString());

        assertThat(numberOfBlogPosts(html), is(10));
        assertThat(html.select(".blog--container .date").first().text(), is("November 11, 2012"));
        assertThat(html.select(".blog--container .date").last().text(), is("November 2, 2012"));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    public void givenPostsCreatedOutOfOrder_blogIndexShowsPostsOrderedByPublishedDate() throws Exception {
        createPublishedPost("Happy New Year", "2013-01-01 00:00");
        createPublishedPost("Back to Work", "2013-01-03 00:00");
        createPublishedPost("Off to the Sales", "2013-01-02 00:00");

        MvcResult response = mockMvc.perform(get("/blog"))
                .andExpect(status().isOk())
                .andReturn();

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        List<String> titles = html.select(".blog--title").stream()
                .map(Element::text).collect(toList());
        assertThat(titles, contains("Back to Work", "Off to the Sales", "Happy New Year"));
    }
View Full Code Here

Examples of org.springframework.test.web.servlet.MvcResult

    @Test
    public void given1PageOfResults_blogIndexDoesNotShowPaginationControl() throws Exception {
        createManyPostsInNovember(1);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("#pagination_control").first(), is(nullValue()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.