Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockRequestDispatcher


    private MockServletContext initServletContext(String warRootDir, ResourceLoader resourceLoader) {
        return new MockServletContext(warRootDir, resourceLoader) {
            // Required for DefaultServletHttpRequestHandler...
            public RequestDispatcher getNamedDispatcher(String path) {
                return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
            }
        };
    }
View Full Code Here


      request.setAttribute(key, model.get(key));
      reqControl.setVoidCallable(1);
    }

    request.getRequestDispatcher(url);
    reqControl.setReturnValue(new MockRequestDispatcher(url));
    reqControl.replay();

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

    }

    request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
    reqControl.setReturnValue("somepath");
    request.getRequestDispatcher(url);
    reqControl.setReturnValue(new MockRequestDispatcher(url));
    reqControl.replay();

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

    }

    request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
    reqControl.setReturnValue(null);
    request.getRequestDispatcher(url);
    reqControl.setReturnValue(new MockRequestDispatcher(url));
    reqControl.replay();

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

    vr.setExposeContextBeansAsAttributes(true);
    vr.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest(sc) {
      public RequestDispatcher getRequestDispatcher(String path) {
        return new MockRequestDispatcher(path) {
          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"));
            assertSame(wac.getBean("myBean"), forwardRequest.getAttribute("myBean"));
View Full Code Here

    vr.setExposedContextBeanNames(new String[] {"myBean2"});
    vr.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest(sc) {
      public RequestDispatcher getRequestDispatcher(String path) {
        return new MockRequestDispatcher(path) {
          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"));
            assertNull(forwardRequest.getAttribute("myBean"));
View Full Code Here

  private MockServletContext initServletContext(String warRootDir, ResourceLoader resourceLoader) {
    return new MockServletContext(warRootDir, resourceLoader) {
      // Required for DefaultServletHttpRequestHandler...
      public RequestDispatcher getNamedDispatcher(String path) {
        return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
      }
    };
  }
View Full Code Here

  protected WebApplicationContext initWebApplicationContext() {

    ServletContext servletContext =  new MockServletContext(this.webResourceBasePath, this.webResourceLoader) {
      // Required for DefaultServletHttpRequestHandler...
      public RequestDispatcher getNamedDispatcher(String path) {
        return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
      }
    };

    this.webAppContext.setServletContext(servletContext);
    this.webAppContext.refresh();
View Full Code Here

  private MockServletContext initServletContext(String warRootDir, ResourceLoader resourceLoader) {
    return new MockServletContext(warRootDir, resourceLoader) {
      // Required for DefaultServletHttpRequestHandler...
      public RequestDispatcher getNamedDispatcher(String path) {
        return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
      }
    };
  }
View Full Code Here

  private MockServletContext initServletContext(String warRootDir, ResourceLoader resourceLoader) {
    return new MockServletContext(warRootDir, resourceLoader) {
      // Required for DefaultServletHttpRequestHandler...
      public RequestDispatcher getNamedDispatcher(String path) {
        return (path.equals("default")) ? new MockRequestDispatcher(path) : super.getNamedDispatcher(path);
      }
    };
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.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.