[weld-dev] CDI TCK: InvocationContextTest:testGetTarget

Marius Bogoevici marius.bogoevici at gmail.com
Fri Jan 7 16:01:21 EST 2011


On 2011-01-07, at 1:13 PM, Scott Ferguson wrote:

> Marius Bogoevici wrote:
>> On 2011-01-07, at 12:17 PM, Scott Ferguson wrote:
>> 
>>  
>>> Marius Bogoevici wrote:
>>>    
>>>> I don't see a particular issue with the test. The rules on what business method invocations are and aren't should make it clear that invocations on the instance acquired via getTarget() are intercepted, or, for that matter, decorated.  Those are *not* business method invocations (in the same way as calls to 'this' are not business method invocations).
>>>>      
>>> That behavior is not defined by any specification, unless you can find the section and cite it.
>>>    
>> 
>> Section 7.2 of the CDI specification.   
> 
> Then there needs to be an explicit test for that behavior. Not an implicit one buried in another test.

I agree with you here, but this wasn't the original point that has been raised - which was that the tests assume a particular implementation strategy and are therefore incorrect.

The particular possibility of multiple reasons for failure opens the discussion on improving the granularity of the test harness and, yes, it would be better to have a separate test for self/getTarget() invocations. As a side note, I believe that the TCK may consider that the implementation under test is compliant as a whole, and combine multiple functionalities in a single test. So the assumption in this case would be that the behaviour of getTarget().getId() is correct - and assuming that does not necessarily mean that it performs implicit (or hidden) tests - it's just exercising a normal functionality of the framework.

The salient point of my initial comment was that the expectation for invocations on an instance obtained via getTarget() to be neither intercepted nor decorated (as they are not business method calls) is correct with respect to the specification. With that in mind, the test by itself is not defective as initially stated, since any correct implementation will be able to pass it. Furthermore, I don't see a reason to change the test in order to accommodate implementations that use subclassing but allow for interception on this/getTarget()-acquired instances. In fact, such a change would allow for a faulty implementation (i.e. one that does not observe the self/getTarget() invocation and interception rules) to pass the TCK.


> 
> -- Scott
>>  
>>> -- Scott
>>> 
>>>    
>>>> Weld implements interception/decoration via subclassing and observes this exact rule (invocations on this and instances acquired by getTarget() are not intercepted/decorated).
>>>> 
>>>> Also, this has been previously discussed here (a couple of links from an older weld-dev thread)
>>>> http://lists.jboss.org/pipermail/weld-dev/2010-May/002517.html
>>>> http://lists.jboss.org/pipermail/weld-dev/2010-May/002519.html
>>>> 
>>>> On 2011-01-06, at 12:34 PM, Scott Ferguson wrote:
>>>> 
>>>>      
>>>>> Jozef Hartinger wrote:
>>>>>        
>>>>>> Could you file a CDITCK issue and assign it to me? Thanks.
>>>>>> 
>>>>>>          
>>>>> Thanks Jozef,
>>>>> 
>>>>> It's at https://issues.jboss.org/browse/CDITCK-203.
>>>>> 
>>>>> I'm pretty sure I don't have permission to assign you tasks, though. :)
>>>>> 
>>>>> -- Scott
>>>>> 
>>>>>        
>>>>>> On 01/06/2011 03:24 AM, Scott Ferguson wrote:
>>>>>>          
>>>>>>> This test has a implementation-dependency on how interception is
>>>>>>> implemented (requires proxy implementation), but the proxy
>>>>>>> implementation is not mandated by the spec (and the EJB spec has always
>>>>>>> allowed both implementation methods.)
>>>>>>> 
>>>>>>> The test calls SimpleBean.getId(), which is intercepted by Interceptor1.
>>>>>>> 
>>>>>>> Interceptor1's aroundInvoke calls target.getId(), which is a circular
>>>>>>> reference for extension and only works for proxy-based interception:
>>>>>>> 
>>>>>>> class SimpleBean {
>>>>>>>  @Interceptors(Interceptor1.class)
>>>>>>>  public int getId()
>>>>>>>  {
>>>>>>>     return id;
>>>>>>>  }
>>>>>>>  ...
>>>>>>> }
>>>>>>> 
>>>>>>> class Interceptor1 {
>>>>>>>  @AroundInvoke
>>>>>>>  public Object aroundInvoke(InvocationContext ctx) throws Exception
>>>>>>>  {
>>>>>>>     SimpleBean target = (SimpleBean) ctx.getTarget();
>>>>>>>     int id1 = target.getId();
>>>>>>>     ...
>>>>>>>   }
>>>>>>> }
>>>>>>> 
>>>>>>> The only change needed to the test is to create a SimpleBean.getBareId()
>>>>>>> which is not an intercepted method.
>>>>>>> 
>>>>>>> (Or, if the spec is re-interpreted to require a proxy implementation,
>>>>>>> there should be an explicit test for it, not an implicit dependency like
>>>>>>> this test.)
>>>>>>> 
>>>>>>> -- Scott
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> weld-dev mailing list
>>>>>>> weld-dev at lists.jboss.org <mailto:weld-dev at lists.jboss.org>
>>>>>>> https://lists.jboss.org/mailman/listinfo/weld-dev
>>>>>>>            
>>>>>> 
>>>>>>          
>>>>> _______________________________________________
>>>>> weld-dev mailing list
>>>>> weld-dev at lists.jboss.org <mailto:weld-dev at lists.jboss.org>
>>>>> https://lists.jboss.org/mailman/listinfo/weld-dev
>>>>>        
>> 
>> 
>> 
>> 
>>  
> 




More information about the weld-dev mailing list