Wicket
  1. Wicket
  2. WICKET-5346

Support MultiFileUploadField in FormTester

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.12.0, 7.0.0-M1
    • Component/s: None
    • Labels:
      None

      Description

      Currently FormTester contains the 'setFile' method. I want to be able to use the WicketTester / FormTester to test multifileuploads.

      FormTester would be even better that it is now if there is a setFiles() method for MultiFileUploadField.

      1. multiuploadtest.zip
        24 kB
        Rob Audenaerde

        Activity

        Hide
        Martin Grigorov added a comment -

        Can you provide a quickstart application with a failing unit test that we can play with ?
        I think what you need should be already possible by calling FormTester#setFile() several times, because it uses org.apache.wicket.protocol.http.mock.MockHttpServletRequest#addFile() internally that properly 'adds' the file.

        Show
        Martin Grigorov added a comment - Can you provide a quickstart application with a failing unit test that we can play with ? I think what you need should be already possible by calling FormTester#setFile() several times, because it uses org.apache.wicket.protocol.http.mock.MockHttpServletRequest#addFile() internally that properly 'adds' the file.
        Hide
        Rob Audenaerde added a comment - - edited

        It currently explicitly checks the FormComponent to be a FileUploadField. MultiFileUpload does not extend this. See the setFile method

        	if (formComponent instanceof FileUploadField == false)
        		{
        			fail("'" + formComponentId + "' is not " +
        				"a FileUploadField. You can only attach a file to form " +
        				"component of this type.");
        		}
        
        Show
        Rob Audenaerde added a comment - - edited It currently explicitly checks the FormComponent to be a FileUploadField. MultiFileUpload does not extend this. See the setFile method if (formComponent instanceof FileUploadField == false ) { fail( "'" + formComponentId + "' is not " + "a FileUploadField. You can only attach a file to form " + "component of this type." ); }
        Hide
        Rob Audenaerde added a comment -

        The failing test

        Show
        Rob Audenaerde added a comment - The failing test

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Rob Audenaerde
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development