Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockHttpServletResponse$ResponseServletOutputStream


    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do");
    request.addPreferredLocale(Locale.GERMAN);
    request.addUserRole("role2");
    request.addParameter("locale", "en");
    request.addParameter("locale2", "en_CA");
    MockHttpServletResponse response = new MockHttpServletResponse();
    complexDispatcherServlet.service(request, response);
    assertTrue("Not forwarded", response.getForwardedUrl() == null);
  }
View Full Code Here


  public void testThemeChangeInterceptor1() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do");
    request.addPreferredLocale(Locale.CANADA);
    request.addUserRole("role1");
    request.addParameter("theme", "mytheme");
    MockHttpServletResponse response = new MockHttpServletResponse();
    complexDispatcherServlet.service(request, response);
    assertEquals(200, response.getStatus());
    assertEquals("forwarded to failed", "failed0.jsp", response.getForwardedUrl());
    assertTrue("Exception exposed", request.getAttribute("exception").getClass().equals(ServletException.class));
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do");
    request.addPreferredLocale(Locale.CANADA);
    request.addUserRole("role1");
    request.addParameter("theme", "mytheme");
    request.addParameter("theme2", "theme");
    MockHttpServletResponse response = new MockHttpServletResponse();
    try {
      complexDispatcherServlet.service(request, response);
      assertTrue("Not forwarded", response.getForwardedUrl() == null);
    }
    catch (ServletException ex) {
      fail("Should not have thrown ServletException: " + ex.getMessage());
    }
  }
View Full Code Here

  private AsyncHandlerInterceptor interceptor3;

  @Before
  public void setup() {
    this.request = new MockHttpServletRequest();
    this.response= new MockHttpServletResponse() ;

    this.handler = new Object();
    this.chain = new HandlerExecutionChain(this.handler);

    this.interceptor1 = mock(AsyncHandlerInterceptor.class);
View Full Code Here

      public int getMinorVersion() {
        return 4;
      }
    });

    MockHttpServletResponse response = new MockHttpServletResponse();
    view.render(model, request, response);
    assertEquals(url, response.getForwardedUrl());

    Set<String> keys = model.keySet();
    for (String key : keys) {
      assertEquals(model.get(key), request.getAttribute(key));
    }
View Full Code Here

    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);

    // Can now try multiple tests
    v.render(model, request, response);
    assertEquals(url, response.getIncludedUrl());

    Set<String> keys = model.keySet();
    for (String key : keys) {
      verify(request).setAttribute(key, model.get(key));
    }
View Full Code Here

    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);

    // Can now try multiple tests
    v.render(model, request, response);
    assertEquals(url, response.getIncludedUrl());

    Set<String> keys = model.keySet();
    for (String key : keys) {
      verify(request).setAttribute(key, model.get(key));
    }
View Full Code Here

    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);

    // Can now try multiple tests
    v.render(model, request, response);
    assertEquals(url, response.getIncludedUrl());

    Set<String> keys = model.keySet();
    for (String key : keys) {
      verify(request).setAttribute(key, model.get(key));
    }
View Full Code Here


  @Before
  public void setUp() {
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();

    jsContext = ContextFactory.getGlobal().enterContext();
    jsScope = jsContext.initStandardObjects();

    view = new MappingJackson2XmlView();
View Full Code Here

  @Before
  public void setUp() throws Exception {
    request = new MockHttpServletRequest();
    request.setMethod(WebContentGenerator.METHOD_GET);
    response = new MockHttpServletResponse();
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.test.MockHttpServletResponse$ResponseServletOutputStream

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.