Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockRequestDispatcher


    String url = "forward-to";

    HttpServletRequest request = mock(HttpServletRequest.class);
    given(request.getAttribute(View.PATH_VARIABLES)).willReturn(null);
    given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));

    MockHttpServletResponse response = new MockHttpServletResponse();
    InternalResourceView v = new InternalResourceView();
    v.setUrl(url);
    v.setAlwaysInclude(true);
View Full Code Here


    HttpServletRequest request = mock(HttpServletRequest.class);
    given(request.getAttribute(View.PATH_VARIABLES)).willReturn(null);

    given(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).willReturn("somepath");
    given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));

    MockHttpServletResponse response = new MockHttpServletResponse();
    InternalResourceView v = new InternalResourceView();
    v.setUrl(url);
View Full Code Here

    HttpServletRequest request = mock(HttpServletRequest.class);
    given(request.getAttribute(View.PATH_VARIABLES)).willReturn(null);

    given(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).willReturn(null);
    given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));

    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setCommitted(true);
    InternalResourceView v = new InternalResourceView();
    v.setUrl(url);
View Full Code Here

  private static class TestMockServletContext extends MockServletContext {

    @Override
    public RequestDispatcher getNamedDispatcher(String path) {
      if (path.equals("default") || path.equals("custom")) {
        return new MockRequestDispatcher("/");
      } else {
        return null;
      }
    }
View Full Code Here

    vr.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest(sc) {
      @Override
      public RequestDispatcher getRequestDispatcher(String path) {
        return new MockRequestDispatcher(path) {
          @Override
          public void forward(ServletRequest forwardRequest, ServletResponse forwardResponse) {
            assertTrue("Correct rc attribute", forwardRequest.getAttribute("rc") == null);
            assertEquals("value1", forwardRequest.getAttribute("key1"));
            assertEquals(new Integer(2), forwardRequest.getAttribute("key2"));
View Full Code Here

    vr.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest(sc) {
      @Override
      public RequestDispatcher getRequestDispatcher(String path) {
        return new MockRequestDispatcher(path) {
          @Override
          public void forward(ServletRequest forwardRequest, ServletResponse forwardResponse) {
            assertTrue("Correct rc attribute", forwardRequest.getAttribute("rc") == null);
            assertEquals("value1", forwardRequest.getAttribute("key1"));
            assertEquals(new Integer(2), forwardRequest.getAttribute("key2"));
View Full Code Here

    private String url;

    @Override
    public RequestDispatcher getNamedDispatcher(String url) {
      this.url = url;
      return new MockRequestDispatcher(url);
    }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.test.MockRequestDispatcher

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.