Re: Testing bad file uploads (solved it myself)

Martin Olsson <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
> How can I use httpunit to submit a form with a filename that does not 
> exist because in mozilla/msie users can type in some obscure invalid 
> filenames and my webpage has error handling for this and I want to make 
> sure that this error handling is working as intended.


Whee, I just managed to solve the problem myself. It's not _exactly_ 
what I had in mind but it gets the job done. Here is the solution, if 
anyone else runs into this problem:


	WebForm createUserForm = ...
	createUserForm.setParameter("form_username", username);
	createUserForm.setParameter("form_password", password);
	createUserForm.setParameter("form_password_again", password);
		
	UploadFileSpec[] uploadFileSpec = new UploadFileSpec[1];
	InputStream stream = new ByteArrayInputStream(new byte[0]);
	uploadFileSpec[0] =
		new UploadFileSpec("invalid.txt", stream, "text/xml");		
	createUserForm.setParameter("form_user_image", uploadFileSpec);

	... submit form here ...



regards,
martin


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.