Sorry for the confusing sentence. 
I meant to say that i don`t know the answer, but i`d
like to use the opportunity and also ask a basic
question.

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 ??



 --- Leandro Melo <[EMAIL PROTECTED]>
escreveu: 
> 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();
> > 
> >         verifyForward( Constants.ERROR_FWD );
> >         verifyForward(
> > Constants.PRODUCTSELECTION_FWD );
> > 
> >         //verifyActionErrors(new String[]
> > {"error.nodefault.implementation" } );
> >         //verifyActionErrors(new String[] {
> > "error.noaction.specified"} );
> > 
> >         //NavigationBean navigationBean =
> > (NavigationBean)getSession().getAttribute(
> > "navigationBean" );
> >         //assertTrue( "NavigationBean is null",
> > navigationBean == null);
> >         verifyNoActionErrors();
> > 
> >     // JUnitDoclet end method productSelection
> >   }
> > 
> > 
> > 
> > 
> > 
> > And I get zero errors at all...
> > 
> 
=== message truncated === 


        
        
                
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! 
http://br.acesso.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to