I had written struts2 action class which export pdf file. it works perfectly fine, now I want to write down Junittest case for this action class.Can any one know how to write unit test case for this action class.
my action
thanks,
Arun
Lorand Komaromi
Ranch Hand
Joined: Oct 08, 2009
Posts: 276
posted
0
Pass in an HttpServletResponse implementation that provides an output stream and saves the content-type and other headers, call your action method then verify your object!
Personally, I'm not sure I'd test it this way. I'd test the file generation, but I don't think I'd test the application container--at least not with a unit test.
Also, I would have used the "stream" result type, and avoided all the complicated testing to begin with.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Export file unit test case for struts2 action