Package org.springframework.test.web.servlet

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


                    .rawContent("Content")
                    .category(PostCategory.ENGINEERING).build();
            postRepository.save(post);
        }

        MvcResult response = mockMvc.perform(get("/blog/2012/11/02?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/2012/11/02?page=1"));
View Full Code Here


                    .rawContent("Content")
                    .category(PostCategory.ENGINEERING).build();
            postRepository.save(post);
        }

        MvcResult response = mockMvc.perform(get("/blog/2012/06?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/2012/06?page=1"));
View Full Code Here

                    .rawContent("Content")
                    .category(PostCategory.ENGINEERING).build();
            postRepository.save(post);
        }

        MvcResult response = mockMvc.perform(get("/blog/2012?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/2012?page=1"));
View Full Code Here

                .category(PostCategory.ENGINEERING).build());

        Page<Post> posts = postRepository.findByCategoryAndDraftFalse(PostCategory.ENGINEERING, new PageRequest(0, 10));
        MatcherAssert.assertThat(posts.getSize(), greaterThanOrEqualTo(1));

        MvcResult response = mockMvc.perform(get(path))
                .andExpect(content().contentTypeCompatibleWith("text/html"))
                .andExpect(content().string(containsString("An Engineering Post")))
                .andExpect(content().string(not(containsString("DO NOT LOOK AT ME"))))
                .andExpect(content().string(containsString(PostCategory.ENGINEERING.toString())))
                .andReturn();

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

        assertThat(html.select(".secondary-nav .blog-category.active").text(), equalTo(PostCategory.ENGINEERING
                .getDisplayName()));

        assertThat(html.select(".content--title.blog-category.active").text(), equalTo(PostCategory.ENGINEERING
View Full Code Here

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

        MvcResult response = mockMvc.perform(get(path)).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("#pagination_control").first(), is(nullValue()));
    }
View Full Code Here

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

        MvcResult response = mockMvc.perform(get(path + "?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(path + "?page=1"));
View Full Code Here

        try {
          MockHttpServletRequestBuilder requestBuilder = request(httpMethod, uri.toString());
          requestBuilder.content(getBodyAsBytes());
          requestBuilder.headers(getHeaders());

          MvcResult mvcResult = MockMvcClientHttpRequestFactory.this.mockMvc.perform(requestBuilder).andReturn();

          MockHttpServletResponse servletResponse = mvcResult.getResponse();
          HttpStatus status = HttpStatus.valueOf(servletResponse.getStatus());
          byte[] body = servletResponse.getContentAsByteArray();
          HttpHeaders headers = getResponseHeaders(servletResponse);

          MockClientHttpResponse clientResponse = new MockClientHttpResponse(body, status);
View Full Code Here

                "foo"), Predicates.fullTextSearch("o"))), isA(Integer.class), isA(Integer.class), isA(SortBy.class))).thenAnswer(a);
       
        when(catalog.count(eq(LayerInfo.class), eq(Predicates.and(Predicates.equal("resource.namespace.prefix",
                "foo"), Predicates.fullTextSearch(""))))).thenReturn(layers.size());
       
        MvcResult result = mvc.perform(get("/api/layers/foo"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andReturn();

        JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
        assertEquals(2, obj.integer("total").intValue());
        assertEquals(2, obj.integer("count").intValue());
        assertEquals(0, obj.integer("page").intValue());

        JSONArr arr = obj.array("layers");
View Full Code Here

            .workspace("foo", "http://scratch.org", true)
                .layer("one").info("The layer", "This layer is cool!")
                .featureType().defaults().store("foo")
            .geoServer().build(geoServer);

        MvcResult result = mvc.perform(get("/api/layers/foo/one"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andReturn();

        JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();

        assertEquals("one", obj.str("name"));
        assertEquals("foo", obj.str("workspace"));
        assertEquals("vector", obj.str("type"));
        assertEquals("The layer", obj.str("title"));
View Full Code Here

          .workspace("foo", "http://scratch.org", true)
            .layer("one")
              .style().point()
          .geoServer().build(geoServer);

        MvcResult result = mvc.perform(get("/api/layers/foo/one/style"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(YsldMessageConverter.MEDIA_TYPE))
            .andReturn();

        StyledLayerDescriptor sld = Ysld.parse(result.getResponse().getContentAsString());
        Style style = ((NamedLayer)sld.layers().get(0)).getStyles()[0];

        assertTrue(style.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0) instanceof PointSymbolizer);
    }
View Full Code Here

TOP

Related Classes of org.springframework.test.web.servlet.MvcResult

Copyright © 2018 www.massapicom. 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.