Yes but with EJBContainerRule you don't have any "context" so you
can't "RunAs" out of the box. You can define your own SecurityService
(as property) and use a thread local to set it. But I didn't go this
way cause it can break easily tests with custom security services or
based on security environment
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-10-31 17:09 GMT+01:00 Xavier Dury <[email protected]>:
> Nice!
>
> It works fine with ApplicationComposerRule but not with EJBContainerRule (the 
> ThreadContext is null).
>
> Xavier
>
> ----------------------------------------
>> From: [email protected]
>> Date: Fri, 31 Oct 2014 16:11:08 +0100
>> Subject: Re: EJBContainerRule and @RunTestAs
>> To: [email protected]
>>
>> Hello
>>
>> sorry for the delay:
>> https://git-wip-us.apache.org/repos/asf/tomee/?p=tomee.git;a=blob;f=container/openejb-core/src/test/java/org/apache/openejb/testing/RunAsRuleTest.java;h=deb838c4d95be85b5b3d299ac3c4f5b311816027;hb=5cede8c77a6336bd24ecea65f61e87d71ecbec66
>>
>> If needed we can backport to 1.7.x
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2014-10-30 12:50 GMT+01:00 Xavier Dury <[email protected]>:
>>> Hi,
>>>
>>> While using EJBContainerRule, I have seen no easy way (~ @Run(Test)As) to 
>>> invoke my EJBs with a particular user/role in my tests.
>>>
>>> There is already an InjectRule and a TransactionRule so would it be 
>>> possible to add some kind of Run(Test)AsRule as well?
>>>
>>> Thanks,
>>>
>>> Xavier
>

Reply via email to