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: > =============================== > <!-- 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... > > > > > --- > >>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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]