Package org.springframework.test.web.servlet

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


        mvc = MockMvcBuilders.standaloneSetup(ctrl).setMessageConverters(new JSONMessageConverter()).build();
    }

    @Test
    public void testGet() throws Exception {
        MvcResult result = mvc.perform(get("/api/projections/epsg:3005"))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andReturn();

        JSONObj proj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
        assertEquals("EPSG:3005", proj.str("srs"));
        assertNotNull(proj.str("wkt"));
    }
View Full Code Here


        assertNotNull(proj.str("wkt"));
    }

    @Test
    public void testRecent() throws Exception {
        MvcResult result = mvc.perform(get("/api/projections/recent"))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andReturn();

        JSONArr list = JSONWrapper.read(result.getResponse().getContentAsString()).toArray();
        assertTrue(list.size() > 0);

        Iterables.find(list, new Predicate<Object>() {
            @Override
            public boolean apply(@Nullable Object input) {
View Full Code Here

      GeoServerResourceLoader rl = this.geoServer.getCatalog().getResourceLoader();
      Resource d = rl.get("workspaces/foo/styles");
      assertEquals( d.getType(), Type.DIRECTORY );
      assertEquals( 3, d.list().size() );
     
      MvcResult result = mvc.perform(get("/api/icons/foo"))
              .andExpect(status().isOk())
              .andExpect(content().contentType(MediaType.APPLICATION_JSON))
              .andReturn();

      JSONArr arr = JSONWrapper.read(result.getResponse().getContentAsString()).toArray();
      assertEquals( 2, arr.size() );
      for( Iterator<Object> i = arr.iterator(); i.hasNext();){
          Object item = i.next();
          if( item instanceof JSONObj){
              JSONObj obj = (JSONObj) item;
View Full Code Here

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

      MvcResult result = mvc.perform(get("/api/icons/foo/icon.png"))
              .andExpect(status().isOk())
              .andExpect(content().contentType(MediaType.IMAGE_PNG_VALUE))
              .andReturn();

      String raw = result.getResponse().getContentAsString();
     
      assertEquals("PNG8",raw);
    }
View Full Code Here

    this.mockMvc = standaloneSetup(this.asyncController).build();
  }

  @Test
  public void testCallable() throws Exception {
    MvcResult mvcResult = this.mockMvc.perform(get("/1").param("callable", "true"))
      .andExpect(request().asyncStarted())
      .andExpect(request().asyncResult(new Person("Joe")))
      .andReturn();

    this.mockMvc.perform(asyncDispatch(mvcResult))
View Full Code Here

      .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
  }

  @Test
  public void testDeferredResult() throws Exception {
    MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResult", "true"))
      .andExpect(request().asyncStarted())
      .andReturn();

    this.asyncController.onMessage("Joe");
View Full Code Here

    .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
  }

  @Test
  public void testDeferredResultWithSetValue() throws Exception {
    MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithSetValue", "true"))
        .andExpect(request().asyncStarted())
        .andExpect(request().asyncResult(new Person("Joe")))
        .andReturn();

    this.mockMvc.perform(asyncDispatch(mvcResult))
View Full Code Here

        .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
  }

  @Test
  public void testListenableFuture() throws Exception {
    MvcResult mvcResult = this.mockMvc.perform(get("/1").param("listenableFuture", "true"))
        .andExpect(request().asyncStarted())
        .andReturn();

    this.asyncController.onMessage("Joe");
View Full Code Here

    List<AssertionError> failures = new ArrayList<AssertionError>();

    for(HttpStatus status : HttpStatus.values()) {
      MockHttpServletResponse response = new MockHttpServletResponse();
      response.setStatus(status.value());
      MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response);
      try {
        Method method = getMethodForHttpStatus(status);
        ResultMatcher matcher = (ResultMatcher) ReflectionUtils.invokeMethod(method, this.matchers);
        try {
          matcher.match(mvcResult);
View Full Code Here

    for(HttpStatus status : HttpStatus.values()) {

      MockHttpServletResponse response = new MockHttpServletResponse();
      response.setStatus(status.value());
      MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response);
      switch (status.series().value()) {
        case 1:
          this.matchers.is1xxInformational().match(mvcResult);
          break;
        case 2:
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.