writing test case for struts action?

View: New views
3 Messages — Rating Filter:   Alert me  

writing test case for struts action?

by Sushil Dodake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
i am trying to write a test case for a struts action call.
in the action call i am trying to send a file on the response output stream.
when i get the output stream using response.getOutputstream i get a object of ServletOurtputStream.
which is a abstract class..
 i then write a byte stream on the output stream and fluch it to close
i am confused as to how to write a test case.
can sombody help me here?
any example?
 
regards,
 
Sush

Parent Message unknown Re: writing test case for struts action?

by Stephen Smith-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you considered mocking the HttpServletResponse and asserting that an output
stream is retrieved from it?

On Tue 16/09/08 06:21 , "Sushil Dodake" sushil.dodake@... sent:
> Hi All, i am trying to write a test case for a struts action call. in
> the action call i am trying to send a file on the response output
> stream. when i get the output stream using response.getOutputstream i
> get a object of ServletOurtputStream. which is a abstract class..  i
> then write a byte stream on the output stream and fluch it to close
> i am confused as to how to write a test case. can sombody help me
> here? any example?   regards,   Sush
>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: writing test case for struts action?

by Steve Freeman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1. Buy some of the TDD books. There are quite a few good ones out there.

2. In your case, create a concrete subclass of the ServletOutputStream  
that writes to a StringBuffer and compare the result at the end of the  
test. Once you're used to that, we can consider what to do next.

S.

On 16 Sep 2008, at 05:21, Sushil Dodake wrote:

> Hi All,
> i am trying to write a test case for a struts action call.
> in the action call i am trying to send a file on the response output  
> stream.
> when i get the output stream using response.getOutputstream i get a  
> object
> of ServletOurtputStream.
> which is a abstract class..
> i then write a byte stream on the output stream and fluch it to close
> i am confused as to how to write a test case.
> can sombody help me here?
> any example?
>
> regards,
>
> Sush

Steve Freeman
Winner of the Agile Alliance Gordon Pask award 2006

http://www.m3p.co.uk

M3P Limited.
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 03689627



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


LightInTheBox - Buy quality products at wholesale price!