1
|
|
package junit.extensions.xml.elements;
|
2
|
|
|
3
|
|
import java.awt.Point;
|
4
|
|
|
5
|
|
import org.w3c.dom.Element;
|
6
|
|
import junit.extensions.xml.IXMLTestCase;
|
7
|
|
import junit.extensions.xml.XMLException;
|
8
|
|
import junit.framework.AssertionFailedError;
|
9
|
|
import junit.framework.TestCase;
|
10
|
|
import junit.extensions.xml.XMLTagResourceBundle;
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
public class AssertNotEqualsTagHandlerT
|
20
|
|
extends TestCase {
|
21
|
|
|
22
|
|
|
23
|
|
|
24
|
|
private AssertNotEqualsTagHandler m_tagHandler = null;
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
|
private ElementFixture m_fixture;
|
29
|
|
|
30
|
|
|
31
|
|
|
32
|
|
|
33
|
|
|
34
|
11
|
protected void setUp() throws Exception {
|
35
|
11
|
super.setUp();
|
36
|
11
|
m_fixture = new ElementFixture(this);
|
37
|
11
|
m_fixture.setUp();
|
38
|
|
}
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|
|
44
|
11
|
protected void tearDown() throws Exception {
|
45
|
11
|
m_tagHandler = null;
|
46
|
11
|
m_fixture.tearDown();
|
47
|
|
|
48
|
11
|
m_fixture = null;
|
49
|
11
|
super.tearDown();
|
50
|
|
}
|
51
|
|
|
52
|
|
|
53
|
|
|
54
|
|
|
55
|
|
|
56
|
1
|
public void testAssertNotEqualsTagHandler() throws XMLException {
|
57
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
58
|
|
"actualrefid", "data1",
|
59
|
|
"expectedrefid", "data2"});
|
60
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
61
|
1
|
testCase.addProperty("data1", "abc");
|
62
|
1
|
testCase.addProperty("data2", "def");
|
63
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
64
|
|
|
65
|
1
|
m_tagHandler.processElement();
|
66
|
|
}
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
|
|
72
|
1
|
public void testAssertNotEqualsTagHandler4() throws XMLException {
|
73
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
74
|
|
"actualrefid", "data1",
|
75
|
|
"expectedrefid", "data2"});
|
76
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
77
|
1
|
testCase.addProperty("data1", new Point(1, 1));
|
78
|
1
|
testCase.addProperty("data2", new Point(1, 2));
|
79
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
80
|
|
|
81
|
1
|
m_tagHandler.processElement();
|
82
|
|
}
|
83
|
|
|
84
|
|
|
85
|
|
|
86
|
|
|
87
|
|
|
88
|
1
|
public void testAssertNotEqualsTagHandler2() throws XMLException {
|
89
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
90
|
|
"actualobj", "abc",
|
91
|
|
"expectedrefid", "data2"});
|
92
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
93
|
1
|
testCase.addProperty("data2", "def");
|
94
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
95
|
|
|
96
|
1
|
m_tagHandler.processElement();
|
97
|
|
}
|
98
|
|
|
99
|
|
|
100
|
|
|
101
|
|
|
102
|
|
|
103
|
1
|
public void testAssertNotEqualsTagHandler3() throws XMLException {
|
104
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
105
|
|
"actualobj", "abc",
|
106
|
|
"expectedobj", "def"});
|
107
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
108
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
109
|
|
|
110
|
1
|
m_tagHandler.processElement();
|
111
|
|
}
|
112
|
|
|
113
|
|
|
114
|
|
|
115
|
|
|
116
|
|
|
117
|
1
|
public void testAssertNotEqualsTagHandlerFail() throws XMLException {
|
118
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
119
|
|
"message", "FAIL",
|
120
|
|
"actualobj", "abc",
|
121
|
|
"expectedobj", "abc"});
|
122
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
123
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
124
|
|
|
125
|
1
|
AssertionFailedError err = null;
|
126
|
1
|
try {
|
127
|
1
|
m_tagHandler.processElement();
|
128
|
|
} catch (AssertionFailedError afe) {
|
129
|
1
|
err = afe;
|
130
|
|
}
|
131
|
|
|
132
|
1
|
String exp = "junit.framework.AssertionFailedError: FAIL";
|
133
|
1
|
assertNotNull("Exception not thrown", err);
|
134
|
1
|
String act = err.toString();
|
135
|
1
|
assertEquals("Validate error text", exp, act);
|
136
|
|
}
|
137
|
|
|
138
|
|
|
139
|
|
|
140
|
|
|
141
|
|
|
142
|
1
|
public void testAssertNotEqualsTagHandlerFail2() throws XMLException {
|
143
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
144
|
|
"message", "FAIL",
|
145
|
|
"actualrefid", "data1",
|
146
|
|
"expectedobj", "abc"});
|
147
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
148
|
1
|
testCase.addProperty("data1", "abc");
|
149
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
150
|
|
|
151
|
1
|
AssertionFailedError err = null;
|
152
|
1
|
try {
|
153
|
1
|
m_tagHandler.processElement();
|
154
|
|
} catch (AssertionFailedError afe) {
|
155
|
1
|
err = afe;
|
156
|
|
}
|
157
|
|
|
158
|
1
|
String exp = "junit.framework.AssertionFailedError: FAIL";
|
159
|
1
|
assertNotNull("Exception not thrown", err);
|
160
|
1
|
assertEquals("Validate error text", exp, err.toString());
|
161
|
|
}
|
162
|
|
|
163
|
|
|
164
|
|
|
165
|
|
|
166
|
|
|
167
|
1
|
public void testAssertNotEqualsTagHandlerFail3() throws XMLException {
|
168
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
169
|
|
"message", "FAIL",
|
170
|
|
"actualrefid", "data1",
|
171
|
|
"expectedrefid", "data2"});
|
172
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
173
|
1
|
testCase.addProperty("data1", "abc");
|
174
|
1
|
testCase.addProperty("data2", "abc");
|
175
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
176
|
|
|
177
|
1
|
AssertionFailedError err = null;
|
178
|
1
|
try {
|
179
|
1
|
m_tagHandler.processElement();
|
180
|
|
} catch (AssertionFailedError afe) {
|
181
|
1
|
err = afe;
|
182
|
|
}
|
183
|
|
|
184
|
1
|
String exp = "junit.framework.AssertionFailedError: FAIL";
|
185
|
1
|
assertNotNull("Exception not thrown", err);
|
186
|
1
|
assertEquals("Validate error text", exp, err.toString());
|
187
|
|
|
188
|
|
}
|
189
|
|
|
190
|
|
|
191
|
|
|
192
|
|
|
193
|
|
|
194
|
1
|
public void testAssertNotEqualsTagHandlerFail4() throws XMLException {
|
195
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
196
|
|
"actualrefid", "data1",
|
197
|
|
"expectedrefid", "data2"});
|
198
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
199
|
1
|
testCase.addProperty("data1", new Point(1, 1));
|
200
|
1
|
testCase.addProperty("data2", new Point(1, 1));
|
201
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
202
|
|
|
203
|
1
|
AssertionFailedError err = null;
|
204
|
1
|
try {
|
205
|
1
|
m_tagHandler.processElement();
|
206
|
|
} catch (AssertionFailedError afe) {
|
207
|
1
|
err = afe;
|
208
|
|
}
|
209
|
|
|
210
|
1
|
String exp = "junit.framework.AssertionFailedError";
|
211
|
1
|
assertNotNull("Exception not thrown", err);
|
212
|
1
|
String act = err.toString();
|
213
|
1
|
assertEquals("Validate error text", exp, act);
|
214
|
|
}
|
215
|
|
|
216
|
|
|
217
|
|
|
218
|
|
|
219
|
|
|
220
|
1
|
public void testAssertNotEqualsTagHandlerNull1() throws XMLException {
|
221
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
222
|
|
"actualrefid", "data1",
|
223
|
|
"expectedrefid", "data2"});
|
224
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
225
|
1
|
testCase.addProperty("data1", null);
|
226
|
1
|
testCase.addProperty("data2", "ABC");
|
227
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
228
|
|
|
229
|
1
|
m_tagHandler.processElement();
|
230
|
|
}
|
231
|
|
|
232
|
|
|
233
|
|
|
234
|
|
|
235
|
|
|
236
|
1
|
public void testAssertNotEqualsTagHandlerNull2() throws XMLException {
|
237
|
1
|
Element element = m_fixture.newElement("assertequals", new String[] {
|
238
|
|
"actualrefid", "data1",
|
239
|
|
"expectedrefid", "data2"});
|
240
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
241
|
1
|
testCase.addProperty("data1", "ABC");
|
242
|
1
|
testCase.addProperty("data2", null);
|
243
|
1
|
m_tagHandler = new AssertNotEqualsTagHandler(element, testCase);
|
244
|
1
|
m_tagHandler.processElement();
|
245
|
|
}
|
246
|
|
|
247
|
|
|
248
|
|
|
249
|
|
|
250
|
1
|
public void testLookup() {
|
251
|
1
|
Element element = m_fixture.newElement("assertnotequals", new String[] {
|
252
|
|
"actualrefid", "data1",
|
253
|
|
"expectedrefid", "data2"});
|
254
|
1
|
IXMLTestCase testCase = m_fixture.getTestCase();
|
255
|
1
|
Object o = XMLTagResourceBundle.getTagHandler(element, testCase, "assertnotequals");
|
256
|
1
|
assertNotNull(o);
|
257
|
|
}
|
258
|
|
|
259
|
|
}
|
260
|
|
|