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

Examples of org.apache.wicket.protocol.http.mock.MockHttpServletRequest$UploadedFile


      throw new IllegalArgumentException("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = tester.getRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);
  }
View Full Code Here


          response.setCacheDurationToMaximum();
          return response;
        }
      };
      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()
      {
View Full Code Here

   * returns just the request uri to the error page without the query string
   */
  @Test
  public void wicket3599()
  {
    MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
    httpRequest.setURL("/" + httpRequest.getContextPath() + "/request/Uri");
    httpRequest.setParameter("some", "parameter");

    ServletWebRequest webRequest = new ServletWebRequest(httpRequest, "/");
    Url clientUrl = webRequest.getClientUrl();
    assertEquals("request/Uri?some=parameter", clientUrl.toString());

    // simulates a request that has errors metadata
    httpRequest.setAttribute("javax.servlet.error.request_uri",
      "/" + httpRequest.getContextPath() + "/any/source/of/error");
    ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, "");

    Url errorClientUrl = errorWebRequest.getClientUrl();

    assertEquals("/any/source/of/error", errorClientUrl.toString());
View Full Code Here

   * <a href="https://issues.apache.org/jira/browse/WICKET-4168">WICKET-4168</a>
   */
  @Test
  public void testClientURLIsContextRelativeInErrorResponses()
  {
    MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
    httpRequest.setURL(httpRequest.getContextPath() + "/request/Uri");

    String problematiURI = httpRequest.getContextPath() + "/any/source/of/error";

    httpRequest.setAttribute("javax.servlet.error.request_uri", problematiURI);

    ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, "");

    Url errorClientUrl = errorWebRequest.getClientUrl();

View Full Code Here

   * Relative Urls should be calculated against 'javax.servlet.forward.request_uri'
   */
  @Test
  public void parseForwardAttributes()
  {
    MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
    httpRequest.setURL(httpRequest.getContextPath() + "/request/Uri");

    String forwardedURI = httpRequest.getContextPath() + "/some/forwarded/url";

    httpRequest.setAttribute("javax.servlet.forward.request_uri", forwardedURI);

    ServletWebRequest forwardWebRequest = new ServletWebRequest(httpRequest, "");

    Url forwardClientUrl = forwardWebRequest.getClientUrl();

View Full Code Here

   */
  @Test
  public void getClientUrlAjaxWithoutBaseUrl()
  {

    MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
    httpRequest.setHeader(ServletWebRequest.HEADER_AJAX, "true");
    ServletWebRequest webRequest = new ServletWebRequest(httpRequest, "");
    try
    {
      webRequest.getClientUrl();
      fail("Should not be possible to get the request client url in Ajax request without base url");
View Full Code Here

   */
  @Test
  public void wicket5203()
  {
    String filterPath = "filterPath";
    MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
    httpRequest.setURL(httpRequest.getContextPath() + '/' + filterPath + "/request/Path");
    httpRequest.setParameter("some", "parameter");

    ServletWebRequest webRequest = new ServletWebRequest(httpRequest, filterPath);
    Url clientUrl = webRequest.getClientUrl();
    assertEquals("request/Path?some=parameter", clientUrl.toString());

    // simulates a request that has errors metadata
    httpRequest.setAttribute("javax.servlet.error.request_uri",
        httpRequest.getContextPath() + '/' + filterPath + "/any/source/of/error");
    ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, filterPath);
    Url errorClientUrl = errorWebRequest.getClientUrl();

    assertEquals("any/source/of/error", errorClientUrl.toString());
  }
View Full Code Here

      fail("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = tester.getRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);

    return this;
  }
View Full Code Here

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

    // assign protocol://host:port to next request unless the last request was ajax
    final boolean assignBaseLocation = lastRequest != null &&
      lastRequest.getHeader("Wicket-Ajax") == null;
View Full Code Here

      fail("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = tester.getRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);

    return this;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.protocol.http.mock.MockHttpServletRequest$UploadedFile

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.