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

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


    tester.startPage(SimplePage.class);
    tester.assertRenderedPage(SimplePage.class);
    tester.assertResultPage(SimplePage.class, "SimplePageExpectedResult.html");

    MockHttpServletResponse resp = tester.getResponse();

    // @TODO should there be any header in the response ????
    // assertEquals("140.211.11.130", resp.getHeader("x-forwarded-for"));
    // assertEquals("proxy1", resp.getHeader("x-forwarded-by"));
  }
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

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

    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

      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));
    ThreadContext.setRequestCycle(requestCycle);
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

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

    ServletWebRequest servletWebRequest = newServletWebRequest();
    requestCycle = application.createRequestCycle(servletWebRequest,
      newServletWebResponse(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()
      {
        @Override
        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

      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

      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

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.