Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.DispatcherServlet.service()


    assertEquals("myView", response.getContentAsString());

    request = new MockHttpServletRequest("POST", "/myOtherHandle.do");
    request.addParameter("myParam", "myValue");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myOtherView", response.getContentAsString());

    request = new MockHttpServletRequest("POST", "/myLangHandle.do");
    request.addParameter("myParam", "myValue");
    response = new MockHttpServletResponse();
View Full Code Here


    assertEquals("myOtherView", response.getContentAsString());

    request = new MockHttpServletRequest("POST", "/myLangHandle.do");
    request.addParameter("myParam", "myValue");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myLangView", response.getContentAsString());

    request = new MockHttpServletRequest("POST", "/mySurpriseHandle.do");
    request.addParameter("myParam", "myValue");
    response = new MockHttpServletResponse();
View Full Code Here

    assertEquals("myLangView", response.getContentAsString());

    request = new MockHttpServletRequest("POST", "/mySurpriseHandle.do");
    request.addParameter("myParam", "myValue");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("mySurpriseView", response.getContentAsString());
  }

  @Test
  public void relativePathDispatchingController() throws Exception {
View Full Code Here

    String requestBody = "Hello World";
    request.setContent(requestBody.getBytes("UTF-8"));
    request.addHeader("Content-Type", "text/plain; charset=utf-8");
    request.addHeader("Accept", "application/pdf, application/msword");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals(406, response.getStatus());
  }

  @Test
  public void responseBodyWildCardMediaType() throws ServletException, IOException {
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
    String requestBody = "Hello World";
    request.setContent(requestBody.getBytes("UTF-8"));
    request.addHeader("Content-Type", "application/pdf");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals(415, response.getStatus());
    assertNotNull("No Accept response header set", response.getHeader("Accept"));
  }

  @Test
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
    String requestBody = "Hello World";
    request.setContent(requestBody.getBytes("UTF-8"));
    request.addHeader("Content-Type", "application/pdf");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("Invalid response status code", HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
  }

  @Test
  public void httpEntity() throws ServletException, IOException {
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
    request.setContent("Hello World".getBytes("UTF-8"));
    request.addHeader("Content-Type", "text/plain; charset=utf-8");
    request.addHeader("Accept", "application/json, text/javascript, */*");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("Invalid response status code", "application/json", response.getHeader("Content-Type"));
  }

  @Test
  public void responseBodyVoid() throws ServletException, IOException {
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
    String requestBody = "<b/>";
    request.setContent(requestBody.getBytes("UTF-8"));
    request.addHeader("Content-Type", "application/xml; charset=utf-8");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals(400, response.getStatus());
  }


  @Test
View Full Code Here

    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myValue", response.getContentAsString());

  }

  @Test
View Full Code Here

    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/handle");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("handle null", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/handle");
    request.addParameter("p", "value");
    response = new MockHttpServletResponse();
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.