struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Haroon Rafique <>
Subject Re: unit testing Struts2 application (with Spring and Hibernate)
Date Mon, 20 Jul 2009 22:02:50 GMT
On Today at 4:32pm, DC=>Dimitrios Christodoulakis <> wrote:

DC> Thanks Haroon for the handy advice. That seems to do the trick as far 
DC> as the session object is concerned. The test passes now.

Glad it worked out.

DC> Would it be easy for someone to extend your code to include actions 
DC> that implement the -aware interfaces? If I wanted to take a shot at 
DC> that, is there a particular point you would suggest I start with?

Did you add that code in your Test class? I was actually suggesting that 
you modify the code inside BaseStrutsTestCase. So, I would recommend 
adding a private static HashMap variable called sessionMap in 
BaseStrutsTestCase. And then in the createAction method, issue the 

Hope that helps.

The only other fringe case that I have dealth with in our code, is when we 
have actions that implement Preparable and are used with a 
ParamsPrepareParams interceptor. I created a method to allow action 
parameters to be set.

  * Sets the action parameters 
  * @param parameters Parameters to set 
protected void setActionParameters(Map<String, String> 
parameters) { 

Then inside my Action Test class, I can issue:

Haroon Rafique

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message