> -----Original Message-----
> From: Gunnar Ole Skogen [mailto:[EMAIL PROTECTED]]
> Sent: 04 February 2002 14:14
> To: [EMAIL PROTECTED]
> Subject: WebRequest / multipart/form-data
>
> My html client uses DHTML to create Form <input type="file"> elements
(,
> with the forms ENCTYPE="multipart/form-data" ) for uploading 0..n
files to
> a
> server,
> Am I right that there currently is no way to use Cactus/HttpUnit to
test
> this ?
>
no in Cactus 1.2 but it is already implemented in cactus 1.3 (you can
grab a nightly build from the web site).
Here is the way to use it :
/**
* Verify that we can send arbitrary data in the request body.
*
* @param theRequest the request object that serves to initialize
the
* HTTP connection to the server redirector.
*/
public void beginSendUserData(WebRequest theRequest)
{
ByteArrayInputStream bais = new ByteArrayInputStream(
"<data>some data to send in the body</data>".getBytes());
theRequest.setUserData(bais);
theRequest.setContentType("text/xml");
}
/**
* Verify that we can send arbitrary data in the request body.
*/
public void testSendUserData() throws Exception
{
String buffer;
StringBuffer body = new StringBuffer();
BufferedReader reader = request.getReader();
while ((buffer = reader.readLine()) != null) {
body.append(buffer);
}
assertEquals("<data>some data to send in the body</data>",
body.toString());
assertEquals("text/xml", request.getContentType());
}
> I know I can get a HttpUnit WebRequest from a HttpUnit's WebForm, but
> Cactus
> does not offer to use HttpUnit's WebRequest objects alternativly to
> Cactus's WebRequest objects like it does with the WebResponse object-
(
> and
> neither does HttpUnit's WebForm provide a way to add form elements
> specifying their type).
>
> If I am not totally mistaken in the above: Could someone roughly
scetch
> what
> I need to do in order to extend Cactus ( and / or eventually HttpUnit)
to
> provide this functionality ?
> See in "Release Changes": Newly added "WebRequest.setContentType"
method
> will enable "multipart/form-data" and that other preparations
(structural
> (?)) for sendig files have been made....
> + Maybe smart if WebRequest could take String of html code and/or
> HttpServletRequest directly ( as in a constructor ) in the future ..?
>
Is the above answering your needs ?
-Vincent
> Thanks
>
>
>
> --
> To unsubscribe, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>