aspose file tools*
The moose likes Struts and the fly likes Export file unit test case for struts2 action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Export file unit test case for struts2 action" Watch "Export file unit test case for struts2 action" New topic
Author

Export file unit test case for struts2 action

Arun Ak
Greenhorn

Joined: Jun 21, 2009
Posts: 21
Hi All,

I had written struts2 action class which export pdf file. it works perfectly fine, now I want to write down Junit test 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
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!


OCJP 6 (93%)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Export file unit test case for struts2 action