Thanks Janne! I wasn't readily aware of this option (think I need to look closely at what other gifts are already in Stripes params :-)

stripesParams.put( "ActionBeanContext.Class","com.thinglink.site.util.web.TLActionBeanContext" );

BTW I'm curious... with your setup below your "util" package is a sub-package of "Extension.packages"... does that mean that the above "ActionBeanContext.class" param will override any possible ActionBeanContext context subclass found when Stripes scans "Extension.packages"?

i.e. say you had defined the following classes (1st one being Test and the other being main non-Test):
       com.thinglink.site.util.web.TLActionBeanContextTest
       com.thinglink.site.util.web.TLActionBeanContext

And you had your setup below which specifically included:
stripesParams.put( "ActionBeanContext.Class","com.thinglink.site.util.web.TLActionBeanContextTest" );
       ...
       stripesParams.put( "Extension.Packages","com.thinglink.site" );

Would Stripes favor TLActionBeanContextTest over TLActionBeanContext for the ActionBeanContext???

I would assume it would the former but am curious if you OR anyone else already knows... .

--Nikolaos



Janne Jalkanen wrote:

I'm using something like this to set up Stripes (JUnit 4, then use standard MockRoundtrip()). You should be able to replace the ActionBeanContext here
with whatever you like.

    @BeforeClass
    public static void mockUp()
    {
        MockServletContext context = new MockServletContext("test");

        // Add the Stripes Filter
        Map<String,String> stripesParams = new HashMap<String,String>();
        stripesParams.put( "ActionResolver.Packages", "com.thinglink" );
stripesParams.put( "ActionResolver.Class","com.thinglink.site.util.web.WebInfNameBasedActionResolver" ); stripesParams.put( "ActionBeanContext.Class","com.thinglink.site.util.web.TLActionBeanContext" ); stripesParams.put( "ExceptionHandler.Class","com.thinglink.site.util.web.TLExceptionHandler" );
        stripesParams.put( "Extension.Packages","com.thinglink.site" );
        stripesParams.put( "LocalePicker.Locales","en,fi" );

context.addFilter(StripesFilter.class, "StripesFilter", stripesParams);

        // Add the Stripes Dispatcher
context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);

        m_context = context;
    }

/Janne

On Jan 25, 2011, at 07:05 , 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
------------------------------------------------------------------------------
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

Reply via email to