Hi David,
There is a WebRequest.setUserData(InputStream) for this. For example
(extracted from the TestHttpRequest.java file in the Cactus servlet
sample application):
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");
}
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());
}
-Vincent
> -----Original Message-----
> From: Karr, David [mailto:[EMAIL PROTECTED]
> Sent: 18 December 2003 18:18
> To: [EMAIL PROTECTED]
> Subject: Servlet code reads InputStream instead of reading parameters,
how
> do I set data in stream?
>
> Most of the servlets I've built Cactus tests for were reading either
GET
> or POST parameters. It was obvious how to set the parameters in the
> test that are read in the servlet. I'm now trying to write a test for
a
> servlet that just reads the inputstream of the request. I don't see
how
> in the WebRequest or HttpServletRequestWrapper classes how I wrote a
> string to the stream that will be read in the InputStream.
>
> I'm using Cactus-13-1.4.1. I'm not ready to upgrade to 1.5 (unless,
of
> course, I can't do this in 1.4.1).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]