Thanks Duncan, i`ll check it out!
--- Duncan Mills <[EMAIL PROTECTED]> escreveu: > Leandro - a good article has just been published on > the Oracle > Technology Network on using JUnit, Cactus and > StrutsTestCase - the setup > portions relate to setting up these up with > JDeveloper, but the basic > flow and tutorial portions provide a good kickstart > even if you use > another IDE - check it out: > http://www.oracle.com/technology/pub/articles/server_side_unit_tests.html > > Regards > > Duncan Mills > http://www.groundside.com/blog > > > > Leandro Melo wrote: > > >Doesn`t know the answer, where can i find a good > >tutorial do test struts applications? > >Is it true that for good testing the actions must > >delegate their work to POJOs ?? > > > > > > > > --- [EMAIL PROTECTED] escreveu: > > > > > >>I am trying to write test cases for my Struts app, > >>but can't seem to figure it out. > >>I have used the examples, but I don't seem to get > >>the correct outcome when I run them. > >> > >>I am using LookupDispatchAction's exclusively. > >> > >>So here is the method I am testing: > >>========================== > >> public void productSelectionAction( > >>ActionMapping mapping > >> , > ActionForm > >>form > >> , > >>HttpServletRequest request > >> , > >>HttpServletResponse response ) { > >> log.info( "Process > CreditApplicationActions > >>productSelectionAction(...)" ); > >> > >> NavigationBean navigationBean = ( > >>NavigationBean )request.getSession().getAttribute( > >>"navigationBean" ); > >> if( navigationBean == null ) { > >> navigationBean = new NavigationBean(); > >> } > >> > >> if( Constants.TRUE.equals( > >>request.getParameter( Constants.BUS_LINE_SELECTED > ) > >>) ) { > >> navigationBean.setHasBusinessLine( > true > >>); > >> } else { > >> request.getSession().setAttribute( > >>"businessLineForm", null ); > >> navigationBean.setHasBusinessLine( > false > >>); > >> } > >> > >> if( Constants.TRUE.equals( > >>request.getParameter( Constants.BUS_CARD_SELECTED > ) > >>) ) { > >> navigationBean.setHasBusinessCard( > true > >>); > >> } else { > >> request.getSession().setAttribute( > >>"businessCardForm", null ); > >> navigationBean.setHasBusinessCard( > false > >>); > >> } > >> > >> if( Constants.TRUE.equals( > >>request.getParameter( > >>Constants.BUS_SEC_CARD_SELECTED ) ) ) { > >> navigationBean.setHasSecuredCard( true > >>); > >> } else { > >> request.getSession().setAttribute( > >>"securedCardForm", null ); > >> navigationBean.setHasSecuredCard( > false > >>); > >> } > >> > >> if( Constants.TRUE.equals( > >>request.getParameter( > >>Constants.EQUIP_EXPRESS_SELECTED ) ) ) { > >> navigationBean.setHasEquipExpress( > true > >>); > >> } else { > >> request.getSession().setAttribute( > >>"equipExpressForm", null ); > >> navigationBean.setHasEquipExpress( > false > >>); > >> } > >> > >> request.getSession().setAttribute( > >>"navigationBean", navigationBean ); > >> }; > >> > >> > >> > >> > >>Here is the action in the struts-config.xml: > >>=============================== > >> <!-- Product selection action --> > >> <action path="/productSelection" > >> input=".productSelection" > >> name="productSelectionForm" > >> parameter="action" > >> scope="session" > >> > >> > >> > >> > >type="com.wf.bd.ice.creditapplication.CreditApplicationActions" > > > > > >> validate="true"> > >> <forward name="error" > >>path=".productSelection" redirect="true" /> > >> <forward name="continue" > >>path=".business" redirect="true" /> > >> <forward name="productSelection" > >>path=".productSelection" redirect="true" /> > >> <forward name="business" > >>path=".business" redirect="true" /> > >> <forward name="firstOwner" > >>path=".firstOwner" redirect="true" /> > >> <forward name="secondOwner" > >>path=".secondOwner" redirect="true" /> > >> <forward name="businessLine" > >>path=".businessLine" redirect="true" /> > >> <forward name="businessCard" > >>path=".businessCard" redirect="true" /> > >> <forward name="securedCard" > >>path=".securedCard" redirect="true" /> > >> <forward name="equipExpress" > >>path=".equipExpress" redirect="true" /> > >> <forward name="noSecondOwner" > >>path=".noSecondOwner" redirect="true" /> > >> <forward name="noBusinessLine" > >>path=".noBusinessLine" redirect="true" /> > >> <forward name="noBusinessCard" > >>path=".noBusinessCard" redirect="true" /> > >> <forward name="noSecuredCard" > >>path=".noSecuredCard" redirect="true" /> > >> <forward name="noEquipExpress" > >>path=".noEquipExpress" redirect="true" /> > >> <forward name="conclude" > >>path=".acceptanceAgreement" redirect="true" /> > >> </action> > >> > >> > >> > >> > >> > >>Here is the test method: > >>================== > >> public void testProductSelection() throws > >>Exception { > >> // JUnitDoclet begin method productSelection > >> > >> setRequestPathInfo( "/productSelection" ); > >> > >> addRequestParameter( "action", "nextPage" > ); > >> > >> addRequestParameter( > "businessLineSelected", > >>"true" ); > >> addRequestParameter( > "businessCardSelected", > >>"true" ); > >> addRequestParameter( > >>"businessSecuredCardSelected", "true" ); > >> addRequestParameter( > >>"equipmentExpressSelected", "true" ); > >> > >> actionPerform(); > >> > === message truncated === __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]