Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 : StrutsTestCase and SessionAware action

 
Ville Korhonen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'am trying to test sessionAware action with strutstestcase but I get NullPointerException while trying to insert stuff into the session. It seems that interceptor inserts null into the action's session. Has someone solved the problem or is there some kind of work around?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not enough information to help--is there a session map?
 
Ville Korhonen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this helps. Struts core and struts-junit-plugin are version 2.1.8.1

Example login action class:


Test class for action class. First test passes but second one throws nullpointerexception in session.put("foo", "bar"); -line.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that running through the action proxy execute simulates an entire request?
 
Ville Korhonen
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solutions from dicital sanctum. I was lazy and thought that execute method would do everything for me Thanks for help.
Here is the code if someone else needs it
 
Soheil Tayari
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude that's exactly what I was looking for.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic