Examples of MvcResult


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

        assertThat(alert.text(), containsString("You must authenticate and authorize"));
    }

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

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        Element alert = html.select(".alert.alert-error").first();
        assertThat("Unexpected alert on page ", alert, is(nullValue()));
    }
View Full Code Here

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

                "githubusername",
                AuthorityUtils
                        .commaSeparatedStringToAuthorityList("ROLE_USER"));
        SecurityContextHolder.getContext().setAuthentication(authentication);

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

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        Element alert = html.select("#authentication").first();
        assertThat("No authentication element found ", alert, is(notNullValue()));

        Element signOutLink = html.select("#authentication a").first();
        assertThat(alert.text(), containsString("Sign out"));
View Full Code Here

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

        stubRestClient.putResponse("/repos/spring-guides/understanding/contents/amqp/README.md", readmeHtml);

        String sidebarHtml = Fixtures.load("/fixtures/understanding/amqp/SIDEBAR.html");
        stubRestClient.putResponse("/repos/spring-guides/understanding/contents/amqp/SIDEBAR.md", sidebarHtml);

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

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("title").text(), containsString("Understanding AMqp"));
        assertThat(html.select("h1").text(), containsString("Understanding: AMQP"));
        assertThat(html.select("aside").text(), containsString("Messaging with RabbitMQ"));
    }
View Full Code Here

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

    @Test
    public void showGuidesIndex() throws Exception {
        stubRestClient.putResponse("/orgs/spring-guides/repos", Fixtures.githubRepoListJson());

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

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("ul li.active").text(), equalTo("Guides"));
        Assert.assertThat(html.text(), containsString("Building a RESTful Web Service"));
        Assert.assertThat(html.text(), containsString("Learn how to create a RESTful web service with Spring"));
        Assert.assertThat(html.text(), containsString("Designing and Implementing RESTful Web Services with Spring"));
        Assert.assertThat(html.text(),
View Full Code Here

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

        postRepository.save(PostBuilder.post()
                .title("Yet another")
                .build());

        MvcResult response = mockMvc.perform(get("/blog/broadcasts")).andReturn();

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

        assertThat(html.select(".blog-category.active").text(), equalTo("Broadcasts"));

        assertThat(numberOfBlogPosts(html), is(2));
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/broadcasts")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("#pagination_control").first(), is(nullValue()));
    }
View Full Code Here

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

    @Test
    public void givenManyPosts_blogIndexShowsPaginationControl() throws Exception {
        createManyPostsInNovember(21);

        MvcResult response = mockMvc.perform(get("/blog/broadcasts?page=2")).andReturn();

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

        Element previousLink = html.select("#pagination_control a.previous").first();
        assertThat("No previous pagination link found", previousLink, is(notNullValue()));
        String previousHref = previousLink.attributes().get("href");
        assertThat(previousHref, is("/blog/broadcasts?page=1"));
View Full Code Here

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")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
    }
View Full Code Here

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")).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

        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());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
    }
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.