Community
Participate
Working Groups
Build Identifier: I20110613-1736 + This was first reported in the forum : http://www.eclipse.org/forums/index.php/m/687581/#msg_687581 + The issue is that the return value here is different from the expected return value (codeElement) as asserted by the test case. + This was tested using CDO 4.0 Reproducible: Always Steps to Reproduce: 1. Download latest eclipse build (3.7) 2. Install EMF and CDO SDK from (latest from indigo update site) 3. Setup a project where the ecore model attached code could be generated (kdm-1.0.ecore), generate model code 4. Setup and run the unit test provided with the bug report 5. The unit test asserts that the feature retrieved using eContainingFeature is the same when retrieved from the EObject and from the CDO Revision, here the test fails with Comparison failure : org.junit.ComparisonFailure: expected:<[codeElement]> but was:<[module]>. Given the definition provided by Eike in the previous forum entry, my understanding is that this test should pass.
Created attachment 198648 [details] Unit Test showing the assertion failure
Created attachment 198649 [details] Ecore Model Used in test to reproduce the issue
After a while I was able to run your test and reproduce your failure. This failure is caused by wrong usage of the containingFeatureId. The correct interpretation can be found in BasicEObjectImpl.eContainingFeature() and I've rewritten your code to: EStructuralFeature feature = containingFeatureId <= InternalEObject.EOPPOSITE_FEATURE_BASE ? container.getEClass().getEStructuralFeature(InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureId) : ((EReference)revision.getEClass().getEStructuralFeature(containingFeatureId)).getEOpposite(); With this code the test passes. If you want to know why exactly EMF stores/interprets this value in this particular way you may want to ask Ed (either cc him here or ask in the newsgroup).
Created attachment 199007 [details] test v2 This is a passing version that also has some other enhancements that you may want to study by comparing to your original version.
It seems close to what I suspected but did not go trough the code in BasicEObjectImpl, which clarifies things a lot. Thanks for reply and worthful comments. Cheers,
You're welcome. I've also added respective JavaDoc to CDORevisionData.getContainingFeatureID() to make it harder to run into this trap in the future ;-)
Closing.