The full article is here: http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
I think the author's explanations cover a lot. The comments and the subsequent conversations are of value too. On Mon, Jul 20, 2009 at 7:33 PM, Martin Gainty<mgai...@hotmail.com> wrote: > > can you show the code to obtain proxy? > could you post the URL for article? > > > > Merci > Martin Gainty > ______________________________________________ > Note de déni et de confidentialité > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le > destinataire prévu, nous te demandons avec bonté que pour satisfaire informez > l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci > est interdite. Ce message sert à l'information seulement et n'aura pas > n'importe quel effet légalement obligatoire. Étant donné que les email > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter > aucune responsabilité pour le contenu fourni. > > > > > >> Date: Mon, 20 Jul 2009 19:07:09 -0500 >> Subject: Re: unit testing Struts2 application (with Spring and Hibernate) >> From: dimi....@gmail.com >> To: user@struts.apache.org >> >> 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.rafi...@utoronto.ca> wrote: >> > On Today at 4:32pm, DC=>Dimitrios Christodoulakis <dimi....@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.rafi...@utoronto.ca> >> > >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> > For additional commands, e-mail: user-h...@struts.apache.org >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> > > _________________________________________________________________ > Windows Live™ Hotmail®: Celebrate the moment with your favorite sports pics. > Check it out. > http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_photos_072009&cat=sports --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org