2
|
1 |
/**
|
|
2 |
* <copyright>
|
|
3 |
* </copyright>
|
|
4 |
*
|
|
5 |
* $Id$
|
|
6 |
*/
|
|
7 |
package com.nokia.sdt.emf.dm.tests;
|
|
8 |
|
|
9 |
import com.nokia.sdt.emf.dm.DmFactory;
|
|
10 |
import com.nokia.sdt.emf.dm.INode;
|
|
11 |
|
|
12 |
import com.nokia.sdt.emf.dm.*;
|
|
13 |
import com.nokia.sdt.emf.dm.impl.ValidatingEObjectContainmentEList;
|
|
14 |
|
|
15 |
import org.eclipse.emf.common.notify.Notification;
|
|
16 |
import org.eclipse.emf.common.notify.impl.AdapterImpl;
|
|
17 |
import org.eclipse.emf.common.util.EList;
|
|
18 |
|
|
19 |
import junit.framework.TestCase;
|
|
20 |
import junit.textui.TestRunner;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* <!-- begin-user-doc -->
|
|
24 |
* A test case for the model object '<em><b>INode</b></em>'.
|
|
25 |
* <!-- end-user-doc -->
|
|
26 |
* @generated
|
|
27 |
*/
|
|
28 |
public class INodeTest extends TestCase {
|
|
29 |
/**
|
|
30 |
* The fixture for this INode test case.
|
|
31 |
* <!-- begin-user-doc -->
|
|
32 |
* <!-- end-user-doc -->
|
|
33 |
* @generated
|
|
34 |
*/
|
|
35 |
protected INode fixture = null;
|
|
36 |
|
|
37 |
/**
|
|
38 |
* <!-- begin-user-doc -->
|
|
39 |
* <!-- end-user-doc -->
|
|
40 |
* @generated
|
|
41 |
*/
|
|
42 |
public static void main(String[] args) {
|
|
43 |
TestRunner.run(INodeTest.class);
|
|
44 |
}
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Constructs a new INode test case with the given name.
|
|
48 |
* <!-- begin-user-doc -->
|
|
49 |
* <!-- end-user-doc -->
|
|
50 |
* @generated
|
|
51 |
*/
|
|
52 |
public INodeTest(String name) {
|
|
53 |
super(name);
|
|
54 |
}
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Sets the fixture for this INode test case.
|
|
58 |
* <!-- begin-user-doc -->
|
|
59 |
* <!-- end-user-doc -->
|
|
60 |
* @generated
|
|
61 |
*/
|
|
62 |
protected void setFixture(INode fixture) {
|
|
63 |
this.fixture = fixture;
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Returns the fixture for this INode test case.
|
|
68 |
* <!-- begin-user-doc -->
|
|
69 |
* <!-- end-user-doc -->
|
|
70 |
* @generated
|
|
71 |
*/
|
|
72 |
private INode getFixture() {
|
|
73 |
return fixture;
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* <!-- begin-user-doc -->
|
|
78 |
* <!-- end-user-doc -->
|
|
79 |
* @see junit.framework.TestCase#setUp()
|
|
80 |
* @generated
|
|
81 |
*/
|
|
82 |
protected void setUp() throws Exception {
|
|
83 |
setFixture(DmFactory.eINSTANCE.createINode());
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* <!-- begin-user-doc -->
|
|
88 |
* <!-- end-user-doc -->
|
|
89 |
* @see junit.framework.TestCase#tearDown()
|
|
90 |
* @generated
|
|
91 |
*/
|
|
92 |
protected void tearDown() throws Exception {
|
|
93 |
setFixture(null);
|
|
94 |
}
|
|
95 |
|
|
96 |
class TestListener extends AdapterImpl {
|
|
97 |
|
|
98 |
int changeCount;
|
|
99 |
|
|
100 |
public void notifyChanged(Notification msg) {
|
|
101 |
++changeCount;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
public void testGetChildrenList() {
|
|
106 |
INode node = getFixture();
|
|
107 |
EList children = node.getChildren();
|
|
108 |
assertTrue(children instanceof ValidatingEObjectContainmentEList);
|
|
109 |
}
|
|
110 |
|
|
111 |
public void testNoFireOnGet() {
|
|
112 |
// regression test that getting a property does not fire a property changed event
|
|
113 |
INode node = getFixture();
|
|
114 |
|
|
115 |
StringValue value = new StringValue(StringValue.LITERAL, "foo");
|
|
116 |
node.getProperties().set("name", value);
|
|
117 |
|
|
118 |
TestListener listener = new TestListener();
|
|
119 |
node.eAdapters().add(listener);
|
|
120 |
|
|
121 |
Object value2 = node.getProperties().get("name");
|
|
122 |
assertEquals(value, value2);
|
|
123 |
assertTrue(listener.changeCount == 0);
|
|
124 |
}
|
|
125 |
|
|
126 |
} //INodeTest
|