From 54136e4fa8ea5039f0f42fcc933e993abfb1d576 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Sun, 20 Aug 2006 09:44:44 +0000 Subject: [154389] attributes in super class returned by server, ignored by client https://bugs.eclipse.org/bugs/show_bug.cgi?id=154389 --- .../emf/cdo/tests/model1/AbstractModel1Test.java | 15 +++ .../eclipse/emf/cdo/tests/model1/BasicTest.java | 14 +- .../emf/cdo/tests/model1/Bugzilla154389Test.java | 65 ++++++++- .../src/testmodel1/EmptyRefNode.java | 47 +++++++ .../src/testmodel1/impl/EmptyRefNodeImpl.java | 145 +++++++++++++++++++++ 5 files changed, 276 insertions(+), 10 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/testmodel1/EmptyRefNode.java create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/testmodel1/impl/EmptyRefNodeImpl.java (limited to 'plugins/org.eclipse.emf.cdo.tests/src') diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java index f77756482d..45fd503093 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AbstractModel1Test.java @@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.springframework.jdbc.core.JdbcTemplate; import testmodel1.EmptyNode; +import testmodel1.EmptyRefNode; import testmodel1.ExtendedNode; import testmodel1.TestModel1Factory; import testmodel1.TreeNode; @@ -154,6 +155,19 @@ public abstract class AbstractModel1Test extends AbstractTopologyTest return node; } + protected EmptyRefNode createEmptyRef(String name) + { + return createEmptyRef(name, null); + } + + protected EmptyRefNode createEmptyRef(String name, TreeNode parent) + { + EmptyRefNode node = TestModel1Factory.eINSTANCE.createEmptyRefNode(); + node.setStringFeature(name); + node.setParent(parent); + return node; + } + protected TreeNode findChild(String name, TreeNode parent) { return findNode(name, parent.getChildren()); @@ -194,6 +208,7 @@ public abstract class AbstractModel1Test extends AbstractTopologyTest super.wipeDatabase(jdbc); dropTable(jdbc, "TREE_NODE"); dropTable(jdbc, "EMPTY_NODE"); + dropTable(jdbc, "EMPTY_REF_NODE"); dropTable(jdbc, "EXTENDED_NODE"); } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java index f105f1a222..123bb4306c 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/BasicTest.java @@ -66,7 +66,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testXRefAlreadyLoaded() throws Exception + public void testRefAlreadyLoaded() throws Exception { final String RESOURCE = "/test/res"; final String ROOT = "root"; @@ -91,7 +91,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testXRefNotYetLoaded() throws Exception + public void testRefNotYetLoaded() throws Exception { final String RESOURCE = "/test/res"; final String ROOT = "root"; @@ -148,7 +148,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testGetResourceWithXRef() throws Exception + public void testGetResourceWithRef() throws Exception { final String RESOURCE = "/test/res"; final String ROOT = "root"; @@ -171,7 +171,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testInterResourceXRef1() throws Exception + public void testInterResourceRef1() throws Exception { final String RESOURCE1 = "/test/res1"; final String RESOURCE2 = "/test/res2"; @@ -198,7 +198,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testInterResourceXRef2() throws Exception + public void testInterResourceRef2() throws Exception { final String RESOURCE1 = "/test/res1"; final String RESOURCE2 = "/test/res2"; @@ -227,7 +227,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testInterResourceXRef3() throws Exception + public void testInterResourceRef3() throws Exception { final String RESOURCE1 = "/test/res1"; final String RESOURCE2 = "/test/res2"; @@ -301,7 +301,7 @@ public class BasicTest extends AbstractModel1Test } } - public void testGetContainerWithXRef() throws Exception + public void testGetContainerWithRef() throws Exception { final String RESOURCE = "/test/res"; final String ROOT = "root"; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla154389Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla154389Test.java index d8358bbd06..03e4b939e1 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla154389Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/Bugzilla154389Test.java @@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.tests.model1; import testmodel1.EmptyNode; +import testmodel1.EmptyRefNode; import testmodel1.TreeNode; @@ -82,7 +83,7 @@ public class Bugzilla154389Test extends AbstractModel1Test } } - public void testEmptyXRef() throws Exception + public void testEmptyViaRef() throws Exception { final String RESOURCE = "/test/res"; final String ROOT = "root"; @@ -97,8 +98,41 @@ public class Bugzilla154389Test extends AbstractModel1Test TreeNode b = createEmpty(CHILD_B, root); b.setBooleanFeature(BOOLEAN_VALUE); b.setIntFeature(INT_VALUE); + a.getReferences().add(b); + saveRoot(root, RESOURCE); + } + + { // Verification + TreeNode root = (TreeNode) loadRoot(RESOURCE); + assertNode(ROOT, root); + TreeNode a = (TreeNode) root.getChildren().get(0); + assertNode(CHILD_A, a); + + TreeNode b = (TreeNode) a.getReferences().get(0); + assertNode(CHILD_B, b); + assertEquals(BOOLEAN_VALUE, b.isBooleanFeature()); + assertEquals(INT_VALUE, b.getIntFeature()); + } + } + + public void testEmptyViaRefWithRef() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final String CHILD_A = "a"; + final String CHILD_B = "b"; + final boolean BOOLEAN_VALUE = true; + final int INT_VALUE = 12345; + + { // Execution + TreeNode root = createNode(ROOT); + TreeNode a = createNode(CHILD_A, root); + TreeNode b = createEmpty(CHILD_B, root); + b.setBooleanFeature(BOOLEAN_VALUE); + b.setIntFeature(INT_VALUE); a.getReferences().add(b); + b.getReferences().add(a); saveRoot(root, RESOURCE); } @@ -106,13 +140,38 @@ public class Bugzilla154389Test extends AbstractModel1Test TreeNode root = (TreeNode) loadRoot(RESOURCE); assertNode(ROOT, root); - TreeNode a = (TreeNode )root.getChildren().get(0); + TreeNode a = (TreeNode) root.getChildren().get(0); assertNode(CHILD_A, a); - + TreeNode b = (TreeNode) a.getReferences().get(0); assertNode(CHILD_B, b); assertEquals(BOOLEAN_VALUE, b.isBooleanFeature()); assertEquals(INT_VALUE, b.getIntFeature()); + assertEquals(CHILD_A, ((TreeNode) b.getReferences().get(0)).getStringFeature()); + } + } + + public void testEmptyRefRoot() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final boolean BOOLEAN_VALUE = true; + final int INT_VALUE = 12345; + + { // Execution + EmptyRefNode root = createEmptyRef(ROOT); + root.setBooleanFeature(BOOLEAN_VALUE); + root.setIntFeature(INT_VALUE); + root.getMoreReferences().add(root); + saveRoot(root, RESOURCE); + } + + { // Verification + EmptyRefNode root = (EmptyRefNode) loadRoot(RESOURCE); + assertNode(ROOT, root); + assertEquals(BOOLEAN_VALUE, root.isBooleanFeature()); + assertEquals(INT_VALUE, root.getIntFeature()); + assertEquals(ROOT, ((TreeNode) root.getMoreReferences().get(0)).getStringFeature()); } } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/EmptyRefNode.java b/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/EmptyRefNode.java new file mode 100644 index 0000000000..76938f1b82 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/EmptyRefNode.java @@ -0,0 +1,47 @@ +/** + * + * + * + * $Id$ + */ +package testmodel1; + + +import org.eclipse.emf.common.util.EList; + + +/** + * + * A representation of the model object 'Empty Ref Node'. + * + * + *

+ * The following features are supported: + *

+ *

+ * + * @see testmodel1.TestModel1Package#getEmptyRefNode() + * @model + * @generated + */ +public interface EmptyRefNode extends TreeNode +{ + /** + * Returns the value of the 'More References' reference list. + * The list contents are of type {@link testmodel1.TreeNode}. + * + *

+ * If the meaning of the 'More References' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'More References' reference list. + * @see testmodel1.TestModel1Package#getEmptyRefNode_MoreReferences() + * @model type="testmodel1.TreeNode" + * @generated + */ + EList getMoreReferences(); + +} // EmptyRefNode \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/impl/EmptyRefNodeImpl.java b/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/impl/EmptyRefNodeImpl.java new file mode 100644 index 0000000000..6d6c6c5118 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/testmodel1/impl/EmptyRefNodeImpl.java @@ -0,0 +1,145 @@ +/** + * + * + * + * $Id$ + */ +package testmodel1.impl; + + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +import testmodel1.EmptyRefNode; +import testmodel1.TestModel1Package; +import testmodel1.TreeNode; + +import java.util.Collection; + + +/** + * + * An implementation of the model object 'Empty Ref Node'. + * + *

+ * The following features are implemented: + *

+ *

+ * + * @generated + */ +public class EmptyRefNodeImpl extends TreeNodeImpl implements EmptyRefNode +{ + /** + * The cached value of the '{@link #getMoreReferences() More References}' reference list. + * + * + * @see #getMoreReferences() + * @generated + * @ordered + */ + protected EList moreReferences = null; + + /** + * + * + * @generated + */ + protected EmptyRefNodeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return TestModel1Package.Literals.EMPTY_REF_NODE; + } + + /** + * + * + * @generated + */ + public EList getMoreReferences() + { + cdoLoad(); + if (moreReferences == null) + { + moreReferences = new EObjectResolvingEList(TreeNode.class, this, + TestModel1Package.EMPTY_REF_NODE__MORE_REFERENCES); + } + return moreReferences; + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case TestModel1Package.EMPTY_REF_NODE__MORE_REFERENCES: + return getMoreReferences(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case TestModel1Package.EMPTY_REF_NODE__MORE_REFERENCES: + getMoreReferences().clear(); + getMoreReferences().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case TestModel1Package.EMPTY_REF_NODE__MORE_REFERENCES: + getMoreReferences().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case TestModel1Package.EMPTY_REF_NODE__MORE_REFERENCES: + return moreReferences != null && !moreReferences.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //EmptyRefNodeImpl \ No newline at end of file -- cgit v1.2.3