File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 2 : StrutsTestCase and SessionAware action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 : StrutsTestCase and SessionAware action" Watch "Struts 2 : StrutsTestCase and SessionAware action" New topic
Author

Struts 2 : StrutsTestCase and SessionAware action

Ville Korhonen
Greenhorn

Joined: Jun 03, 2010
Posts: 3
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

Joined: Sep 29, 2008
Posts: 12617

Not enough information to help--is there a session map?
Ville Korhonen
Greenhorn

Joined: Jun 03, 2010
Posts: 3
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

Joined: Sep 29, 2008
Posts: 12617

Are you sure that running through the action proxy execute simulates an entire request?
Ville Korhonen
Greenhorn

Joined: Jun 03, 2010
Posts: 3
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

Joined: Apr 04, 2008
Posts: 29
Thanks dude that's exactly what I was looking for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 : StrutsTestCase and SessionAware action