Partially solved... obvious that if MyActionBeanContext interacts with session then one can set directly on MockHttpSession e.g.
request.getSession().setAttribute(MyActionBeanContext.SESSION_USER, user); However, still curious on how to replace MyActionBeanContext with a test one... Perhaps as I setup my own Stripes extensions packages path in a Test Fixture I could prefix the paths with a package specifically for testing. Q: Does Stripes use classes it finds in the Stripes extensions packages path in first come first serve basis? i.e. if we have say 6 classes in our extensions package which includes MyActionBeanContext... if I prefix the extensions path with the package that has MyActionBeanContextTest... will Stripes happily only pick up and use MyActionBeanContextTest and ignore MyActionBeanContext which is found in a later package path segment??? --Nikolaos Nikolaos Giannopoulos wrote: > Hi, > > We have a typical superclass for our ActionBeans: > > public abstract class BaseActionBean implements ActionBean { > ... > protected MyActionBeanContext context; > public final MyActionBeanContext getContext() { return context; } > public final void setContext(ActionBeanContext context) { > this.context = (MyActionBeanContext) context; > } > > Now, when we write our TestNG tests we do: > ... > MockRoundtrip trip = new MockRoundtrip(context, "/share/add/0/-/", > new MockHttpSession(context)); > MockHttpServletRequest request = trip.getRequest(); > trip.execute(); > > And everything works great... except I would like to set some values > on the ActionBean that Stripes finds and instantiates however it is > unclear how I would access the ActionBean context as trip.execute() > creates the ActionBean, sets the default context, and processes the > event handler. We obviously would need to set values on the > ActionBeanContext AFTER bean creation BUT BEFORE event handler is > processed e.g. set the logged in user on the ActionBeanContext. > > Also it would be nice at times to replace the ActionBeanContext with a > test version as depicted in the Stripes Best Practices. > > Sure its trivial if you don't care about UrlBinding to simply create > the appropriate bean, set the custom context and pass it to > MockRoundTrip however that bypasses an important stage that we need to > test and that is incoming localized / canonical urls (in essence we > are doing more end-to-end tests for our action beans i.e. start with > this URL and after execution end up with these messages, errors, and > destination URL). > > Has anyone done this before? If not, anyone up to the challenge on > how to solve this? > > Thanks, > > --Nikolaos > ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users