• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to test Action class having session object in struts2 Application

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am developing an application using struts2 ,iBatis and JUnit testing tool . I am able to test Service class and dao class using JMock i.e by mocking the nonessential classes but in Action I've used session objects. how do I mock these session objects??


Please help me. If possible then please give me the code abstract of testing Action Class.


 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Spring, you can use spring-mock.jar. It has Mock HttpRequest, HttpResponse and HttpSession objects.

Else, if you want to go with a plain vanilla approach, create a mock HttpSession yourself.

Here is a sample code I had used before using spring-mock:



Hope this helps.
 
Shweta Baranwal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sunil.

But in my application I am not using Spring even I don't know Spring . I am using Struts2. Can you please help me in testing Action Class having Session attribute . How do I mock session ?
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic