Re: Help with Cactus StrutsTestCase

2004-08-27 Thread Leandro Melo
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:
> >>===
> >>
> >> >>input=".productSelection"
> >>name="productSelectionForm"
> >>parameter="action"
> >>scope="session"   
> >>   
> >>
> >>
> >>
>
>type="com.wf.bd.ice.creditapplication.CreditApplicationActions"
> >  
> >
> >>validate="true">
> >> >>path=".productSelection" redirect="true" />
> >> >>path=".business" redirect="true" />
> >> >>path=".productSelection" redirect="true" />
> >> >>path=".business" redirect="true" />
> >> >>path=".firstOwner" redirect="true" />
> >> >>path=".secondOwner" redirect="true" />
> >> >>path=".businessLine" redirect="true" />
> >> >>path=".businessCard" redirect="true" />
> >> >>path=".securedCard" redirect="true" />
> >> >>path=".equipExpress" redirect="true" />
> >> >>path=".noSecondOwner" redirect="true" />
> >> >>path=".noBusinessLine" redirect="true" />
> >> >>path=".noBusinessCard" redirect="true" />
> >> >>path=".noSecuredCard" redirect="true" />
> >> >>path=".noEquipExpress" redirect="true" />
> >> >>path=".acceptanceAgreement" redirect="true" />
> >>
> >>
> >>
> >>
> >>
> >>
> >>Here is the test method:
> >>==
> >>  public void testProductSelection() throws
> >>Exception {
> >>// JUnitDoclet begin method productSelection
> >>
> >>setRequestPathInfo( "/productS

Re: Help with Cactus StrutsTestCase

2004-08-27 Thread Duncan Mills
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:
===
   
   
   input=".productSelection"
   name="productSelectionForm"
   parameter="action"
   scope="session"   
  

   

type="com.wf.bd.ice.creditapplication.CreditApplicationActions"
 

   validate="true">
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   


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

---
   

Thanks...
Mick Knutson
525 Market Street, SF, CA  94103
(415) 222-1020
[EMAIL PROTECTED]
MAC A0103-223
 

---

   

-
 

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


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

-
To unsubscribe, e-mail: [E

Re: Help with Cactus StrutsTestCase

2004-08-26 Thread Bill Siggelkow
Mick, I don't think I have explicitly tested LookupDispatchAction under 
CactusStrutsTestCase but I see no reason why it shouldn't work --

Here are some suggestions:
- Check the log files, etc.
- Determine if you can test a conventional action (just dummy one up if 
you don't have one)
- Get out your trusty debugger.

[EMAIL PROTECTED] wrote:
Yes:

/**
 * This is the method that defines the different button text items in a hashMap
 * for the BaseLookupDispatchAction to use.
 *
 * TODO: Need to externalize this, so these are not hard coded.
 */
protected Map getKeyMethodMap()
{
log.info( "getKeyMethodMap..." );
Map map = new HashMap();
ResourceBundle methods = ResourceBundle.getBundle( 
Constants.LOOKUP_METHOD_MESSAGE_RESOURCES );
Enumeration keys = methods.getKeys();
while( keys.hasMoreElements() )
{
String key = ( String )keys.nextElement();
map.put( key, methods.getString( key ) );
}
return map;
}

-Original Message-
From: news [mailto:[EMAIL PROTECTED] Behalf Of Bill Siggelkow
Sent: Thursday, August 26, 2004 10:53 AM
To: [EMAIL PROTECTED]
Subject: Re: Help with Cactus StrutsTestCase
Is your LookupDispatchAction implementing getKeyMethodMap()?
[EMAIL PROTECTED] wrote:

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:
===
   
   
   input=".productSelection"
   name="productSelectionForm"
   parameter="action"
   scope="session"   
   type="com.wf.bd.ice.creditapplication.CreditApplicationActions" 
   validate="true">
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   



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[] {&qu

RE: Help with Cactus StrutsTestCase

2004-08-26 Thread Mick.Knutson
Yes:



/**
 * This is the method that defines the different button text items in a hashMap
 * for the BaseLookupDispatchAction to use.
 *
 * TODO: Need to externalize this, so these are not hard coded.
 */
protected Map getKeyMethodMap()
{
log.info( "getKeyMethodMap..." );

Map map = new HashMap();

ResourceBundle methods = ResourceBundle.getBundle( 
Constants.LOOKUP_METHOD_MESSAGE_RESOURCES );

Enumeration keys = methods.getKeys();

while( keys.hasMoreElements() )
{
String key = ( String )keys.nextElement();
map.put( key, methods.getString( key ) );
}

return map;
}



-Original Message-
From: news [mailto:[EMAIL PROTECTED] Behalf Of Bill Siggelkow
Sent: Thursday, August 26, 2004 10:53 AM
To: [EMAIL PROTECTED]
Subject: Re: Help with Cactus StrutsTestCase


Is your LookupDispatchAction implementing getKeyMethodMap()?


[EMAIL PROTECTED] wrote:

> 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:
> ===
> 
>  input=".productSelection"
> name="productSelectionForm"
> parameter="action"
> scope="session"   
> type="com.wf.bd.ice.creditapplication.CreditApplicationActions" 
> validate="true">
> 
> 
>  redirect="true" />
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 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&qu

Re: Help with Cactus StrutsTestCase

2004-08-26 Thread Bill Siggelkow
Is your LookupDispatchAction implementing getKeyMethodMap()?
[EMAIL PROTECTED] wrote:
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:
===


input=".productSelection"
name="productSelectionForm"
parameter="action"
scope="session"   
type="com.wf.bd.ice.creditapplication.CreditApplicationActions" 
validate="true">




















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

---
Thanks...
Mick Knutson
525 Market Street, SF, CA  94103
(415) 222-1020
[EMAIL PROTECTED]
MAC A0103-223
---

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


Re: Help with Cactus StrutsTestCase

2004-08-26 Thread Bill Siggelkow
Check out "Struts The Complete Reference" by James Holmes -- I hear the 
chapter on Testing absolutely ROCKS ;)

Bill Siggelkow
Leandro Melo wrote:
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 ??


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


RE: Help with Cactus StrutsTestCase

2004-08-26 Thread Mick.Knutson
I have a Delegate pattern layer that all actions communicate with. But this action in 
particular, does not need anything except to create a POJO and add it to session.



-Original Message-
From: Leandro Melo [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 26, 2004 9:23 AM
To: Struts Users Mailing List
Subject: Re: Help with Cactus StrutsTestCase


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:
> ===
> 
>  input=".productSelection"
> name="productSelectionForm"
> parameter="action"
> scope="session"   
>
>
type="com.wf.bd.ice.creditapplication.CreditApplicationActions"
> 
> validate="true">
>  path=".productSelection" redirect="true" />
>  path=".business" redirect="true" />
>  path=".productSelection" redirect="true" />
>  path=".business" redirect="true" />
>  path=".firstOwner" redirect="true" />
>  path=".secondOwner" redirect="true" />
>  path=".businessLine" redirect="true" />
>  path=".businessCard" redirect="true" />
>  path=".securedCard" redirect="true" />
>  path=".equipExpress" redirect="true" />
>  path=".noSecondOwner" redirect="true" />
>  path=".noBusinessLine" redirect="true" />
>  path=".noBusinessCard" redirect="true" />
>  path=".noSecuredCard" redirect="true" />
>  path=".noEquipExpress" redirect="true" />
>  path=".acceptanceAgreement

Re: Help with Cactus StrutsTestCase

2004-08-26 Thread Leandro Melo
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:
> > ===
> > 
> >  > input=".productSelection"
> > name="productSelectionForm"
> > parameter="action"
> > scope="session"   
> >
> >
>
type="com.wf.bd.ice.creditapplication.CreditApplicationActions"
> > 
> > validate="true">
> >  > path=".productSelection" redirect="true" />
> >  > path=".business" redirect="true" />
> >  > path=".productSelection" redirect="true" />
> >  > path=".business" redirect="true" />
> >  > path=".firstOwner" redirect="true" />
> >  > path=".secondOwner" redirect="true" />
> >  > path=".businessLine" redirect="true" />
> >  > path=".businessCard" redirect="true" />
> >  > path=".securedCard" redirect="true" />
> >  > path=".equipExpress" redirect="true" />
> >  > path=".noSecondOwner" redirect="true" />
> >  > path=".noBusinessLine" redirect="true" />
> >  > path=".noBusinessCard" redirect="true" />
> >  > path=".noSecuredCard" redirect="true" />
> >  > path=".noEquipExpress" redirect="true" />
> >  > path=".acceptanceAgreement" redirect="true" />
> > 
> > 
> > 
> > 
> > 
> > 
> > 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(
> > "businessSecu

Re: Help with Cactus StrutsTestCase

2004-08-26 Thread Leandro Melo
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:
> ===
> 
>  input=".productSelection"
> name="productSelectionForm"
> parameter="action"
> scope="session"   
>
>
type="com.wf.bd.ice.creditapplication.CreditApplicationActions"
> 
> validate="true">
>  path=".productSelection" redirect="true" />
>  path=".business" redirect="true" />
>  path=".productSelection" redirect="true" />
>  path=".business" redirect="true" />
>  path=".firstOwner" redirect="true" />
>  path=".secondOwner" redirect="true" />
>  path=".businessLine" redirect="true" />
>  path=".businessCard" redirect="true" />
>  path=".securedCard" redirect="true" />
>  path=".equipExpress" redirect="true" />
>  path=".noSecondOwner" redirect="true" />
>  path=".noBusinessLine" redirect="true" />
>  path=".noBusinessCard" redirect="true" />
>  path=".noSecuredCard" redirect="true" />
>  path=".noEquipExpress" redirect="true" />
>  path=".acceptanceAgreement" redirect="true" />
> 
> 
> 
> 
> 
> 
> 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
>