Cool, thanks a lot
On Tue, Feb 12, 2013 at 10:07 AM, Remi VANKEISBELCK <r...@rvkb.com> wrote:
> Yep, I think so.
>
> I've never done exactly what you want but I've had my share of Stripes
> Interceptors :)
>
> So I'd say that you just need a custom Interceptor in your tests that
> performs the "injection" of some mock collaborators in your ActionBeans.
>
> There are many ways to implement it but that's the idea : the interceptor
> gets called even when you use MockRoundtrip, this is for sure. So just add
> the interceptor to the list of Stripes extension pkgs for your test, and
> let it create and assign your mock objects to your ActionBeans.
>
> Look at how it's done for Spring :
>
> http://grepcode.com/file/repo1.maven.org/maven2/net.sourceforge.stripes/stripes/1.5.5/net/sourceforge/stripes/integration/spring/SpringInterceptor.java
>
> Cheers
>
> Remi
>
>
>
> Le 12 févr. 2013 à 18:53, Dan Kaplan a écrit :
>
> Ah, cool. I was on IRC and in the convo we came to the same conclusion.
> So is "extending" the MockRoundtrip an unnecessary step?
>
>
> On Tue, Feb 12, 2013 at 12:43 AM, Remi VANKEISBELCK <r...@rvkb.com> wrote:
>
>> Hi,
>>
>> Apparently the guy uses an Interceptor for his tests.
>>
>> I think that's what you want too. Write a Stripes Interceptor that
>> performs the "injection" as you want, and only register this one for your
>> unit tests. You don't have to stub anything IMO.
>>
>> Btw that's what @SpringBean does: it's based on Interception as well.
>>
>> Cheers
>>
>> Remi
>>
>>
>> Le 11 févr. 2013 à 21:36, Dan Kaplan a écrit :
>>
>> BTW, half the answer seems to be in this post:
>> http://planetjava.org/java-stripes-user/2007-02/msg00155.html
>>
>> But the problem is he doesn't show us/me how to override the
>> MockRoundtrip. I can't figure out how
>> his ActionBeanInitialization.initialize(T actionBeanInstance) gets called.
>>
>>
>> On Mon, Feb 11, 2013 at 12:34 PM, Dan Kaplan <d...@mirthcorp.com> wrote:
>>
>>> That's making the assumption that stubbing the InitialContext will solve
>>> all my dependency injection needs. But if my actionbean has a field in it
>>> that is like:
>>>
>>> private PojoWithBusinessLogic bean = new PojoWithBusinessLogic();
>>>
>>> Stubbing the InitialContext won't let me DI this bean.
>>>
>>>
>>> On Mon, Feb 11, 2013 at 12:18 PM, Jocke Eriksson
>>> <jockeeriks...@msn.com>wrote:
>>>
>>>> Just mock the initial context factory.
>>>>
>>>>
>>>> see
>>>> http://stackoverflow.com/questions/10045466/how-to-fake-initialcontext-with-default-constructor
>>>> .
>>>>
>>>> ------------------------------
>>>> Date: Mon, 11 Feb 2013 10:18:05 -0800
>>>> From: d...@mirthcorp.com
>>>> To: stripes-users@lists.sourceforge.net
>>>> Subject: [Stripes-users] Using dependency injection on action beans
>>>> when I use MockRoundtrip
>>>>
>>>>
>>>> I read about using the MockRoundtrip here:
>>>> http://www.stripesframework.org/display/stripes/Unit+Testing
>>>>
>>>> The problem I have is a few of my ActionBean's fields are EJBs that get
>>>> populated from the app server. How can I use dependency injection on the
>>>> action bean's fields?
>>>>
>>>> mockRoundtrip = new MockRoundtrip(context, AnActionBean.class);
>>>> mockRoundtrip.execute("event"); //I don't see a place to use DI
>>>>
>>>> When I call execute here, it gives me a bunch of errors because the
>>>> EJBs couldn't get created. That's fine, but I don't see a way to implement
>>>> these EJB interfaces as mock classes when I use the MockRoundtrip.
>>>>
>>>> --
>>>> Thanks,
>>>> Dan
>>>>
>>>> CONFIDENTIALITY NOTICE: The information contained in this electronic
>>>> transmission may be confidential. If you are not an intended recipient, be
>>>> aware that any disclosure, copying, distribution or use of the information
>>>> contained in this transmission is prohibited and may be unlawful. If you
>>>> have received this transmission in error, please notify us by email reply
>>>> and then erase it from your computer system.
>>>> ------------------------------------------------------------------------------
>>>> Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall
>>>> before the end March 2013 and get the hardware for free! Learn more.
>>>> http://p.sf.net/sfu/sophos-d2d-feb
>>>> _______________________________________________ Stripes-users mailing
>>>> list Stripes-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Free Next-Gen Firewall Hardware Offer
>>>> Buy your Sophos next-gen firewall before the end March 2013
>>>> and get the hardware for free! Learn more.
>>>> http://p.sf.net/sfu/sophos-d2d-feb
>>>> _______________________________________________
>>>> Stripes-users mailing list
>>>> Stripes-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>>
>>>>
>>>
>>>
>>> --
>>> Thanks,
>>> Dan
>>>
>>
>>
>>
>> --
>> Thanks,
>> Dan
>>
>> CONFIDENTIALITY NOTICE: The information contained in this electronic
>> transmission may be confidential. If you are not an intended recipient, be
>> aware that any disclosure, copying, distribution or use of the information
>> contained in this transmission is prohibited and may be unlawful. If you
>> have received this transmission in error, please notify us by email reply
>> and then erase it from your computer system.
>> ------------------------------------------------------------------------------
>> Free Next-Gen Firewall Hardware Offer
>> Buy your Sophos next-gen firewall before the end March 2013
>> and get the hardware for free! Learn more.
>>
>> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Free Next-Gen Firewall Hardware Offer
>> Buy your Sophos next-gen firewall before the end March 2013
>> and get the hardware for free! Learn more.
>> http://p.sf.net/sfu/sophos-d2d-feb
>> _______________________________________________
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> --
> Thanks,
> Dan
>
> CONFIDENTIALITY NOTICE: The information contained in this electronic
> transmission may be confidential. If you are not an intended recipient, be
> aware that any disclosure, copying, distribution or use of the information
> contained in this transmission is prohibited and may be unlawful. If you
> have received this transmission in error, please notify us by email reply
> and then erase it from your computer system.
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
>
> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
Thanks,
Dan
--
CONFIDENTIALITY NOTICE: The information contained in this electronic
transmission may be confidential. If you are not an intended recipient, be
aware that any disclosure, copying, distribution or use of the information
contained in this transmission is prohibited and may be unlawful. If you
have received this transmission in error, please notify us by email reply
and then erase it from your computer system.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users