You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Jean-Baptiste Quenot (JIRA)" <ji...@apache.org> on 2007/08/21 17:15:32 UTC

[jira] Updated: (WICKET-728) WicketTester could not handle Multipart form without upload

     [ https://issues.apache.org/jira/browse/WICKET-728?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jean-Baptiste Quenot updated WICKET-728:
----------------------------------------

    Fix Version/s: 1.3.0-beta4

Looks reasonable to do for the next release

> WicketTester could not handle Multipart form without upload
> -----------------------------------------------------------
>
>                 Key: WICKET-728
>                 URL: https://issues.apache.org/jira/browse/WICKET-728
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 1.3.0-beta2
>         Environment: linux 2.6 jdk6
>            Reporter: Ingram Chen
>             Fix For: 1.3.0-beta4
>
>         Attachments: upload-patch.txt
>
>
> When testing the form that contains FileUploadField without upload, wicketTester throw exception 
> with message: "ServletRequest does not contain multipart content"
> // ex:
> public class FormTesterTest extends WicketTestCase
> {
> 	/**
> 	 * Test that formTester deal with Multipart form correctly when no actual
> 	 * upload
> 	 */
> 	public void testSubmitWithoutUploadFile()
> 	{
> 		tester.startPage(MockFormFileUploadPage.class);
> 		MockFormFileUploadPage page = (MockFormFileUploadPage)tester.getLastRenderedPage();
> 		Session.get().setLocale(Locale.US);
> 		FormTester formTester = tester.newFormTester("form");
> 		// without file upload
> 		formTester.submit();
> 		assertNull(page.getFileUpload());
> 		tester.assertErrorMessages(new String[] { "Field 'file' is required." });
> 	}
> }
> The cause is that Form contains FileUploadField is considered as multipart. But MockHttpServletRequest only generate Multipart contentType and contentLength when there is any upload file added via formTester.setFile(...). Thus without any file upload while testing, MultipartServletWebRequest throw exception.
> To solve this, I try to introduce a flag useMultiPartContentType in MockHttpServletRequest, so FormTester can change MockHttpServletRequest to generate correct contentType.
> attachment is patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.