struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dimitrios Christodoulakis <dimi....@gmail.com>
Subject Re: unit testing Struts2 application (with Spring and Hibernate)
Date Tue, 21 Jul 2009 00:07:09 GMT
Thanks for clarifying Haroon,

Actually the additions you are mentioning sum up the original testing
code pretty well. Like I said,  from an educational point of view, I
think one can learn a lot about the framework itself by studying that
article and the comments. Thanks for the "preparable" bit too.

As other folks here mentioned, it depends on the testing requirements
of the project when it comes which test strategy to take, or which
tool to use. As a learner, I found it very useful to experiment with
that code.

I haven't tried Selenium yet, but I would be interested to see how it
catches the same errors in the same test cases.

On Mon, Jul 20, 2009 at 5:02 PM, Haroon
Rafique<haroon.rafique@utoronto.ca> wrote:
> On Today at 4:32pm, DC=>Dimitrios Christodoulakis <dimi.chr@gmail.com> 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.
> DC>
>
> Glad it worked out.
>
> DC>
> 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?
> DC>
>
> 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
> statement:
>    proxy.getInvocation().getInvocationContext().setSession(sessionMap);
>
> 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) {
>   proxy.getInvocation().getInvocationContext().
>           setParameters(parameters);
> }
>
> Then inside my Action Test class, I can issue:
>  proxy.setActionParameters(...);
> before:
>  proxy.execute();
>
> Cheers,
> --
> Haroon Rafique
> <haroon.rafique@utoronto.ca>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message