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

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


      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

      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

  @Test
  public void setDispositionHeader()
  {
    ServletWebRequest webRequest = mock(ServletWebRequest.class);
    MockHttpServletRequest httpRequest = mock(MockHttpServletRequest.class);
    HttpServletResponse httpResponse = new MockHttpServletResponse(httpRequest);
    ServletWebResponse response = new ServletWebResponse(webRequest, httpResponse);

    response.setInlineHeader("name with spaces");
    String header = httpResponse.getHeader("Content-Disposition");
    assertEquals(
      "inline; filename=\"name%20with%20spaces\"; filename*=UTF-8''name%20with%20spaces",
      header);

    // says: "name with bulgarian"
    response.setInlineHeader("name with български");
    header = httpResponse.getHeader("Content-Disposition");
    assertEquals(
      "inline; filename=\"name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8\"; filename*=UTF-8''name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8",
      header);

    response.setAttachmentHeader("name with spaces");
    header = httpResponse.getHeader("Content-Disposition");
    assertEquals(
      "attachment; filename=\"name%20with%20spaces\"; filename*=UTF-8''name%20with%20spaces",
      header);

    // says: "name with bulgarian"
    response.setAttachmentHeader("name with български");
    header = httpResponse.getHeader("Content-Disposition");
    assertEquals(
      "attachment; filename=\"name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8\"; filename*=UTF-8''name%20with%20%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8",
      header);
  }
 
View Full Code Here

    tester.startPage(InternalErrorCallsAjaxOnFailurePage.class);

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

    // the response before current should holds the error page markup
    MockHttpServletResponse errorPageResponse = tester.getLastResponse();
    assertEquals(500, errorPageResponse.getStatus());
    assertTrue(errorPageResponse.getDocument().contains(
      InternalErrorCallsAjaxOnFailurePage.ERROR_MESSAGE));

    // assert the page with detailed error explanation is rendered
    tester.assertRenderedPage(ExceptionErrorPage.class);
  }
View Full Code Here

    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);
    tester.destroy();
  }
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()
      {
        @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.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

    tester.startPage(InternalErrorCallsAjaxOnFailurePage.class);

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

    // the response before current should holds the error page markup
    MockHttpServletResponse errorPageResponse = tester.getLastResponse();
    assertEquals(500, errorPageResponse.getStatus());
    assertTrue(errorPageResponse.getDocument().contains(
      InternalErrorCallsAjaxOnFailurePage.ERROR_MESSAGE));

    // assert the page with detailed error explanation is rendered
    tester.assertRenderedPage(ExceptionErrorPage.class);
  }
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.