• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Export file unit test case for struts2 action

 
Arun Ak
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic