Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e6ed88f42be4f2258330727d761971ba1cf6dc19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/***************************************************************************
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/
package org.eclipse.emf.cdo.tests.model1;


import testmodel1.EmptyNode;
import testmodel1.EmptyRefNode;
import testmodel1.TreeNode;


/**
 * attributes in super class returned by server, ignored by client.
 * 
 * The issue occurs when an object is loaded that has no attributes.
 * All the attributes are in the super class.
 * 
 * When the object is loaded the server transmits all of the attributes,
 * which include the super class attributes. The client side ignored the
 * attributes and mis-interpreted the message containing the attributes as
 * the next object. From this point on nothing will work...
 * 
 * So, it looks like the client and server don't match here.
 * 
 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=154389
 */
public class Bugzilla154389Test extends AbstractModel1Test
{
  public void testEmptyRoot() throws Exception
  {
    final String RESOURCE = "/test/res";
    final String ROOT = "root";
    final boolean BOOLEAN_VALUE = true;
    final int INT_VALUE = 12345;

    { // Execution
      TreeNode root = createEmpty(ROOT);
      root.setBooleanFeature(BOOLEAN_VALUE);
      root.setIntFeature(INT_VALUE);
      saveRoot(root, RESOURCE);
    }

    { // Verification
      TreeNode root = (TreeNode) loadRoot(RESOURCE);
      assertNode(ROOT, root);
      assertEquals(BOOLEAN_VALUE, root.isBooleanFeature());
      assertEquals(INT_VALUE, root.getIntFeature());
    }
  }

  public void testEmptyChild() throws Exception
  {
    final String RESOURCE = "/test/res";
    final String ROOT = "root";
    final String CHILD = "child";
    final boolean BOOLEAN_VALUE = true;
    final int INT_VALUE = 12345;

    { // Execution
      TreeNode root = createEmpty(ROOT);
      EmptyNode child = createEmpty(CHILD, root);
      child.setBooleanFeature(BOOLEAN_VALUE);
      child.setIntFeature(INT_VALUE);
      saveRoot(root, RESOURCE);
    }

    { // Verification
      TreeNode root = (TreeNode) loadRoot(RESOURCE);
      assertNode(ROOT, root);

      TreeNode child = findChild(CHILD, root);
      assertEquals(BOOLEAN_VALUE, child.isBooleanFeature());
      assertEquals(INT_VALUE, child.getIntFeature());
    }
  }

  public void testEmptyViaRef() 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);
      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);
    }

    { // 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());
      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());
    }
  }
}

Back to the top