Hi Jeremie,
On May 9, 2012, at 12:10 PM, Jeremie BOUSQUET wrote:
  Hi,
 Sorry about that ... You're right my "nabble-ized" mails seem to be
 viewable correctly only from nabble ... :/
 I put back here my initial request :
 Seems I did not understand everything about how to write unit tests ...
 Here's my problem : I want to test a class MA, a component, that has the
 following code (excerpt) :
    @Inject
    private Execution execution;
    @Override
    public void initialize() throws InitializationException
    {
        try {
            ExecutionContext context = execution.getContext();
            ...
    }
 My test class MATest contains :
    @MockingRequirement
    private MA ma;
    /**
     * @see org.xwiki.test.AbstractMockingComponentTestCase#configure()
     */
    @Override
    public void configure() throws Exception
    {
        try { 
You shouldn't have a try/catch since you're no testing this
             final Execution execution =
 getComponentManager().lookup(Execution.class);
            Mockery context = new Mockery();
            context.checking(new Expectations()
            {
                {
                    oneOf(execution).getContext();
                }
            });
 Here I'm looking up the Execution in order to set expectations on it for
 the initialize to pass. 
BTW don't forget to add a will(returnValue(…))
  Problem is that I'm still getting this at test
execution :
 java.lang.AssertionError: unexpected invocation: execution.getContext()
 It seems that my initialize() method is called at lookup(), so how could I
 set-up the expectations before they're actually exercised ? : 
By setting the expectations in configure(). Here's the javadoc for it:
    /**
     * Provides a hook so that users of this class can perform configuration before the
component is looked up. This
     * allows for example the ability to set expectations on mocked components used in
Initializable.initialize()
     * methods.
     */
    public void configure() throws Exception
    {
        // Do nothing by default, this method is supposed to be overridden if needed.
    }
I've now documented it at the class level.
Thanks
-Vincent
  at
org.xwiki.component.ma.internal.MA.initialize(MA.java:165) ~[classes/:na]
    at
org.xwiki.component.embed.InitializableLifecycleHandler.handle(InitializableLifecycleHandler.java:39)
 [xwiki-commons-component-default-3.5.jar:na]
    at
org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:295)
 [xwiki-commons-component-default-3.5.jar:na]
    at
org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:358)
 [xwiki-commons-component-default-3.5.jar:na]
    at
org.xwiki.component.embed.EmbeddableComponentManager.getComponentInstance(EmbeddableComponentManager.java:324)
 [xwiki-commons-component-default-3.5.jar:na]
    at
org.xwiki.component.embed.EmbeddableComponentManager.lookup(EmbeddableComponentManager.java:147)
 [xwiki-commons-component-default-3.5.jar:na]
 Thanks for help,
 Jeremie
 2012/5/4 Eduard Moraru <enygma2002(a)gmail.com>
> Hi Jerem,
>
> Are you using 
nabble.com directly to send/reply to mails? If that is the
> case, then maybe you can configure it to include the mail thread.
>
> Also, in this particular mail that you have sent, the code is not visible.
> I see on nabble that you`ve used a different font or some special
> formatting that did not make it trough to the mailing list.
>
> If possible, please use a standard mail client, gmail or at least configure
> nabble(or whatever you`re using) to behave like one :)
>
> It will improve your response rate for future mails ;)
>
> Thanks,
> Eduard
>
> On Thu, May 3, 2012 at 4:05 PM, Vincent Massol <vincent(a)massol.net> wrote:
>
>>
>> On May 3, 2012, at 2:45 PM, jerem wrote:
>>
>>> Hello community,
>>>
>>> No idea on this problem ?
>>
>> What problem? I can't see any in your mail…
>>
>> Thanks
>> -Vincent
>>
>> PS: I already asked you in the past to not remove initial mail context
>> when you reply as otherwise it's impossible to follow you.
>>
>>> I'm pretty sure it's stupid but I'm stuck ...
>>> Teasing Motivation argument : it will soon slow down my progress on the
>> mail
>>> archive applicaiton ... ;)
>>>
>>> Thanks,
>>> Jeremie