Package org.apache.wicket.protocol.http

Examples of org.apache.wicket.protocol.http.MockHttpServletRequest


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

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


  public void submit()
  {
    checkClosed();
    try
    {
      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
      WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
      servletRequest.setRequestToComponent(workingForm);

      if (servletRequest.hasUploadedFiles())
      {
        requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, workingForm
            .getMaxSize()));
      }
View Full Code Here

      }
    });

    // Setup the request. It should be a IMultipartWebRequest
    RequestCycle requestCycle = tester.createRequestCycle();
    MockHttpServletRequest servletRequest = tester.getServletRequest();
    servletRequest.setMethod("POST");
    servletRequest.setParameter("form2:hf:fs", "");
    servletRequest.setParameter("wicketState", "");
   
    File tmp = null;
    try {
      // Write out a large text file. We need to make this file reasonably sizable,
      // because things get handled using input streams, and we want to check to make
      // sure they're closed properly if we abort mid-request.
     
      // We create a temp file because we don't want to depend on a file we might not
      // know the path of (e.g. the big DTD this test used previously). This enables
      // us to run the test out of a JAR file if need be, and also with an unknown
      // running directory (e.g. when run from wicket-parent).
      tmp = new File(java.io.File.createTempFile(this.getClass().getName(), ".txt"));
      OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp));
      for (int i = 0; i < 1000; i++)
      {
        os.write("test test test test test\n".getBytes());
      }
      os.close();
   
      // Let's upload the dtd file. It's large enough to avoid being in memory.
      servletRequest.addFile("upload", tmp, "text/plain");
 
      requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, Bytes.MAX));

      // attach manually for the test
      field.attach();
View Full Code Here

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

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

  public void submit()
  {
    checkClosed();
    try
    {
      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();

      WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
      servletRequest.setRequestToComponent(workingForm);

      servletRequest.setUseMultiPartContentType(isMultiPart());
      baseWicketTester.processRequestCycle(requestCycle);
    }
    finally
    {
      closed = true;
View Full Code Here

    TextField input = (TextField)tester.getLastRenderedPage().get("border:name");
    assertEquals("", input.getDefaultModelObjectAsString());

    tester.setupRequestAndResponse();

    MockHttpServletRequest mockRequest = tester.getServletRequest();
    mockRequest.setRequestToComponent(form);
    mockRequest.setParameter(input.getInputName(), "jdo");

    tester.processRequestCycle();

    input = (TextField)tester.getLastRenderedPage().get("border:name");
    assertEquals("jdo", input.getDefaultModelObjectAsString());
View Full Code Here

  }

  private void requestHandlingOfResourceUrlWithEscapeStringInside()
  {
    final WebRequestCycle cycle = tester.setupRequestAndResponse();
    final MockHttpServletRequest request = tester.getServletRequest();
    request.setMethod("GET");
    request.setURL("http://localhost/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/" +
      expectedResourceUrl());
    tester.processRequestCycle(cycle);
    tester.assertNoErrorMessage();
    assertEquals("// ParentResourceTest.js", tester.getServletResponse().getDocument());
  }
View Full Code Here

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

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

  public void submit()
  {
    checkClosed();
    try
    {
      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
      WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
      servletRequest.setRequestToComponent(workingForm);

      if (servletRequest.hasUploadedFiles())
      {
        requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, workingForm
            .getMaxSize()));
      }
View Full Code Here

    TextField input = (TextField)tester.getLastRenderedPage().get("border:name");
    assertEquals("", input.getModelObjectAsString());

    tester.setupRequestAndResponse();

    MockHttpServletRequest mockRequest = tester.getServletRequest();
    mockRequest.setRequestToComponent(form);
    mockRequest.setParameter(input.getInputName(), "jdo");

    tester.processRequestCycle();

    input = (TextField)tester.getLastRenderedPage().get("border:name");
    assertEquals("jdo", input.getModelObjectAsString());
View Full Code Here

TOP

Related Classes of org.apache.wicket.protocol.http.MockHttpServletRequest

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.