diff options
author | Christian W. Damus | 2013-04-09 14:41:33 +0000 |
---|---|---|
committer | Christian W. Damus | 2013-04-10 19:26:48 +0000 |
commit | 9daf293d879938eb8555ee53689d6b9a5955ddcb (patch) | |
tree | 281b1208668ef7d57a0c15ae5c2d2dec226fd9c8 | |
parent | bf7ea53f7b718195a08432cdca2f6b910d512334 (diff) | |
download | cdo-9daf293d879938eb8555ee53689d6b9a5955ddcb.tar.gz cdo-9daf293d879938eb8555ee53689d6b9a5955ddcb.tar.xz cdo-9daf293d879938eb8555ee53689d6b9a5955ddcb.zip |
[400236] [Legacy] ClassCastException on CDOLegacyWrapper when native reference legacy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400236
Update test case to ensure clear separation of native and legacy models.
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400236_Test.java | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400236_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400236_Test.java index 3faf7a0d08..94818b4077 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400236_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400236_Test.java @@ -7,21 +7,31 @@ * * Contributors: * Esteban Dugueperoux - initial API and implementation + * Christian W. Damus (CEA) - adapted to ensure clear separation of native and legacy models */ package org.eclipse.emf.cdo.tests.bugzilla; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.tests.model3.Model3Factory; -import org.eclipse.emf.cdo.tests.model3.NodeA; +import org.eclipse.emf.cdo.tests.config.IModelConfig; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires; +import org.eclipse.emf.cdo.tests.model6.CanReferenceLegacy; import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EcoreFactory; + +import java.util.Arrays; + /** * @author Esteban Dugueperoux */ +// don't execute in legacy configs because it's a native/legacy interaction problem +@Requires(IModelConfig.CAPABILITY_NATIVE) public class Bugzilla_400236_Test extends AbstractCDOTest { + public void testCommit() throws Exception { @@ -30,16 +40,20 @@ public class Bugzilla_400236_Test extends AbstractCDOTest CDOResource resourceA = transaction.createResource(getResourcePath("test1")); CDOResource resourceB = transaction.createResource(getResourcePath("test2")); - NodeA nodeA1 = Model3Factory.eINSTANCE.createNodeA(); // Use native object! - nodeA1.setName("nodeA1"); + CanReferenceLegacy ref1 = getModel6Factory().createCanReferenceLegacy(); + EAnnotation annot1 = EcoreFactory.eINSTANCE.createEAnnotation(); // legacy object + annot1.setSource("annot1"); + ref1.setSingleContainment(annot1); + EAnnotation annot2 = EcoreFactory.eINSTANCE.createEAnnotation(); // legacy object + annot2.setSource("annot2"); + ref1.getMultipleContainment().add(annot2); - NodeA nodeA2 = getModel3Factory().createNodeA(); - nodeA2.setName("nodeA2"); + CanReferenceLegacy ref2 = getModel6Factory().createCanReferenceLegacy(); + ref2.setSingleReference(annot1); + ref2.getMultipleReference().add(annot2); - nodeA1.getOtherNodes().add(nodeA2); - - resourceA.getContents().add(nodeA1); - resourceB.getContents().add(nodeA2); + resourceA.getContents().add(ref1); + resourceB.getContents().add(ref2); transaction.commit(); session.close(); @@ -47,19 +61,23 @@ public class Bugzilla_400236_Test extends AbstractCDOTest transaction = session.openTransaction(); resourceA = transaction.getResource(getResourcePath("test1")); resourceB = transaction.getResource(getResourcePath("test2")); - nodeA1 = (NodeA)resourceA.getContents().get(0); - nodeA2 = (NodeA)resourceB.getContents().get(0); + ref1 = (CanReferenceLegacy)resourceA.getContents().get(0); + ref2 = (CanReferenceLegacy)resourceB.getContents().get(0); + + annot1 = transaction.getObject(annot1); + annot2 = transaction.getObject(annot2); - NodeA nodeA3 = Model3Factory.eINSTANCE.createNodeA(); // Use native object! - nodeA3.setName("nodeA3"); + EAnnotation annot3 = EcoreFactory.eINSTANCE.createEAnnotation(); + annot3.setSource("annot3"); - NodeA nodeA4 = getModel3Factory().createNodeA(); - nodeA4.setName("nodeA4"); + ref1.getMultipleContainment().add(annot3); - nodeA2.getChildren().add(nodeA4); - nodeA3.getOtherNodes().add(nodeA4); - nodeA1.getChildren().add(nodeA3); + ref2.getMultipleReference().add(annot3); - nodeA4 = nodeA3.getOtherNodes().get(0); + assertSame(annot1, ref2.getSingleReference()); + assertSame(ref1.getSingleContainment(), ref2.getSingleReference()); + assertEquals(Arrays.asList(annot2, annot3), ref2.getMultipleReference()); + assertEquals(ref1.getMultipleContainment(), ref2.getMultipleReference()); } + } |