Package org.apache.wicket.protocol.http.mock

Examples of org.apache.wicket.protocol.http.mock.MockHttpServletResponse


    tester.setExposeExceptions(false);
    tester.startPage(InternalErrorCallsAjaxOnFailurePage.class);

    tester.clickLink("failure-link", true);

    MockHttpServletResponse errorPageResponse = tester.getLastResponse();
    assertEquals(500, errorPageResponse.getStatus());

    // assert that the original page is still the last rendered one
    tester.assertRenderedPage(InternalErrorCallsAjaxOnFailurePage.class);
  }
View Full Code Here


   */
  private void setupNextRequestCycle()
  {
    request = new MockHttpServletRequest(application, hsession, servletContext);
    request.setURL(request.getContextPath() + request.getServletPath() + "/");
    response = new MockHttpServletResponse(request);

    ServletWebRequest servletWebRequest = createServletWebRequest();
    requestCycle = application.createRequestCycle(servletWebRequest,
      createServletWebResponse(servletWebRequest));
    requestCycle.setCleanupFeedbackMessagesOnDetach(false);
View Full Code Here

      application.getSharedResources().add("foo.gif", resource);
      MockHttpServletRequest request = new MockHttpServletRequest(application, null, null);
      request.setURL(request.getContextPath() + request.getServletPath() +
        "/wicket/resource/" + Application.class.getName() + "/foo.gif");
      setIfModifiedSinceToNextWeek(request);
      MockHttpServletResponse response = new MockHttpServletResponse(request);
      filter.doFilter(request, response, new FilterChain()
      {
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
          throws IOException, ServletException
        {
        }
      });
      assertEquals(HttpServletResponse.SC_NOT_MODIFIED, response.getStatus());
      String responseExpiresHeader = response.getHeader("Expires");
      assertNotNull("Expires header must be set on not modified response",
        responseExpiresHeader);

      Date responseExpires = headerDateFormat.parse(responseExpiresHeader);
      assertTrue("Expected later than current date but was " + responseExpires,
View Full Code Here

    // check page is rendered
    tester.assertRenderedPage(ModifyCookiePage.class);

    // get response
    MockHttpServletResponse response = tester.getLastResponse();
    assertNotNull(response);

    // check that one cookie was set
    List<Cookie> cookies = response.getCookies();
    assertEquals(1, cookies.size());

    // check that cookie contains proper values
    Cookie cookie = cookies.get(0);
    assertEquals(ModifyCookiePage.COOKIE_NAME, cookie.getName());
View Full Code Here

      request.setServerPort(lastRequest.getServerPort());
    }

    transferCookies();

    response = new MockHttpServletResponse(request);

    ServletWebRequest servletWebRequest = newServletWebRequest();
    requestCycle = application.createRequestCycle(servletWebRequest,
      newServletWebResponse(servletWebRequest));
    ThreadContext.setRequestCycle(requestCycle);
View Full Code Here

      request.setServerPort(lastRequest.getServerPort());
    }

    transferCookies();

    response = new MockHttpServletResponse(request);

    ServletWebRequest servletWebRequest = newServletWebRequest();
    requestCycle = application.createRequestCycle(servletWebRequest,
      newServletWebResponse(servletWebRequest));
    requestCycle.setCleanupFeedbackMessagesOnDetach(false);
View Full Code Here

      request.setServerPort(lastRequest.getServerPort());
    }

    transferRequestCookies();

    response = new MockHttpServletResponse(request);

    // Preserve response cookies in redirects
    // XXX: is this really needed ? Browsers wont do that, but some
    // Wicket tests assert that a cookie is in the response,
    // even after redirects (see org.apache.wicket.util.cookies.SetCookieAndRedirectTest.statefulPage())
View Full Code Here

      application.getSharedResources().add("foo.gif", resource);
      MockHttpServletRequest request = new MockHttpServletRequest(application, null, null);
      request.setURL(request.getContextPath() + request.getServletPath() +
        "/wicket/resource/" + Application.class.getName() + "/foo.gif");
      setIfModifiedSinceToNextWeek(request);
      MockHttpServletResponse response = new MockHttpServletResponse(request);
      filter.doFilter(request, response, new FilterChain()
      {
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
          throws IOException, ServletException
        {
        }
      });
      assertEquals((Integer)HttpServletResponse.SC_NOT_MODIFIED, response.getStatus());
      String responseExpiresHeader = response.getHeader("Expires");
      assertNotNull("Expires header must be set on not modified response",
        responseExpiresHeader);

      Date responseExpires = headerDateFormat.parse(responseExpiresHeader);
      assertTrue("Expected later than current date but was " + responseExpires,
View Full Code Here

   */
  private void setupNextRequestCycle()
  {
    request = new MockHttpServletRequest(application, hsession, servletContext);
    request.setURL(request.getContextPath() + request.getServletPath() + "/");
    response = new MockHttpServletResponse(request);

    requestCycle = application.createRequestCycle(createServletWebRequest(),
      createServletWebResponse());
    requestCycle.setCleanupFeedbackMessagesOnDetach(false);
    ThreadContext.setRequestCycle(requestCycle);
View Full Code Here

      request.setSecure(lastRequest.isSecure());
      request.setServerName(lastRequest.getServerName());
      request.setServerPort(lastRequest.getServerPort());
    }

    response = new MockHttpServletResponse(request);

    ServletWebRequest servletWebRequest = newServletWebRequest();
    requestCycle = application.createRequestCycle(servletWebRequest,
      newServletWebResponse(servletWebRequest));
    requestCycle.setCleanupFeedbackMessagesOnDetach(false);
View Full Code Here

TOP

Related Classes of org.apache.wicket.protocol.http.mock.MockHttpServletResponse

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.