1
|
|
package junit.extensions.xml.elements;
|
2
|
|
|
3
|
|
import org.w3c.dom.Element;
|
4
|
|
import junit.extensions.xml.IXMLTestCase;
|
5
|
|
import junit.extensions.xml.XMLException;
|
6
|
|
import junit.framework.TestCase;
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
public class AbstractAssertTagHandlerT extends TestCase {
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
|
|
22
|
|
|
23
|
|
|
24
|
|
private class ImplAssertTagHandler extends AbstractAssertTagHandler {
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
12
|
public ImplAssertTagHandler(final Element element, final IXMLTestCase tc) {
|
31
|
12
|
super(element, tc);
|
32
|
|
}
|
33
|
|
|
34
|
|
|
35
|
|
|
36
|
|
|
37
|
0
|
public void processElement() {
|
38
|
|
}
|
39
|
|
}
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|
|
44
|
|
private AbstractAssertTagHandler m_abstractAssertTagHandler = null;
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
private ElementFixture m_fixture;
|
49
|
|
|
50
|
|
|
51
|
|
|
52
|
|
|
53
|
|
|
54
|
12
|
protected void setUp() throws Exception {
|
55
|
12
|
super.setUp();
|
56
|
12
|
m_fixture = new ElementFixture(this);
|
57
|
12
|
m_fixture.setUp();
|
58
|
|
}
|
59
|
|
|
60
|
|
|
61
|
|
|
62
|
|
|
63
|
|
|
64
|
12
|
protected void tearDown() throws Exception {
|
65
|
12
|
m_abstractAssertTagHandler = null;
|
66
|
12
|
m_fixture.tearDown();
|
67
|
12
|
m_fixture = null;
|
68
|
|
|
69
|
12
|
super.tearDown();
|
70
|
|
}
|
71
|
|
|
72
|
|
|
73
|
|
|
74
|
|
|
75
|
|
|
76
|
1
|
public void testCheckActualID() throws XMLException {
|
77
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
78
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
79
|
|
"actualrefid", "abc"
|
80
|
|
});
|
81
|
|
|
82
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
83
|
1
|
m_abstractAssertTagHandler.checkActual();
|
84
|
|
}
|
85
|
|
|
86
|
|
|
87
|
|
|
88
|
|
|
89
|
|
|
90
|
1
|
public void testCheckActualObj() throws XMLException {
|
91
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
92
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
93
|
|
"actualobj", "abc"
|
94
|
|
});
|
95
|
|
|
96
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
97
|
1
|
m_abstractAssertTagHandler.checkActual();
|
98
|
|
}
|
99
|
|
|
100
|
|
|
101
|
|
|
102
|
|
|
103
|
|
|
104
|
1
|
public void testCheckActualException() throws XMLException {
|
105
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
106
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
107
|
|
});
|
108
|
|
|
109
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
110
|
|
|
111
|
1
|
XMLException exception = null;
|
112
|
1
|
try {
|
113
|
1
|
m_abstractAssertTagHandler.checkActual();
|
114
|
|
} catch (XMLException ex) {
|
115
|
1
|
exception = ex;
|
116
|
|
}
|
117
|
|
|
118
|
1
|
assertNotNull("Exception was not thrown", exception);
|
119
|
1
|
assertSame(e, exception.getElement());
|
120
|
|
}
|
121
|
|
|
122
|
|
|
123
|
|
|
124
|
|
|
125
|
|
|
126
|
1
|
public void testCheckExpectedID() throws XMLException {
|
127
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
128
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
129
|
|
"expectedrefid", "data"
|
130
|
|
});
|
131
|
|
|
132
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
133
|
1
|
m_abstractAssertTagHandler.checkExpected();
|
134
|
|
}
|
135
|
|
|
136
|
|
|
137
|
|
|
138
|
|
|
139
|
|
|
140
|
1
|
public void testCheckExpectedObj() throws XMLException {
|
141
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
142
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
143
|
|
"expectedobj", "data"
|
144
|
|
});
|
145
|
|
|
146
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
147
|
1
|
m_abstractAssertTagHandler.checkExpected();
|
148
|
|
}
|
149
|
|
|
150
|
|
|
151
|
|
|
152
|
|
|
153
|
|
|
154
|
1
|
public void testCheckExpectedException() throws XMLException {
|
155
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
156
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
157
|
|
});
|
158
|
|
|
159
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
160
|
1
|
XMLException exception = null;
|
161
|
1
|
try {
|
162
|
1
|
m_abstractAssertTagHandler.checkExpected();
|
163
|
|
} catch (XMLException ex) {
|
164
|
1
|
exception = ex;
|
165
|
|
}
|
166
|
1
|
assertNotNull("Exception not thrown", exception);
|
167
|
1
|
assertSame(e, exception.getElement());
|
168
|
|
}
|
169
|
|
|
170
|
|
|
171
|
|
|
172
|
|
|
173
|
1
|
public void testGetActualID() {
|
174
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
175
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
176
|
|
"actualrefid", "data"
|
177
|
|
});
|
178
|
|
|
179
|
1
|
tc.addProperty("data", "abc");
|
180
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
181
|
1
|
Object expectedReturn = "abc";
|
182
|
1
|
Object actualReturn = m_abstractAssertTagHandler.getActualObject();
|
183
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
184
|
|
}
|
185
|
|
|
186
|
|
|
187
|
|
|
188
|
|
|
189
|
1
|
public void testGetActualObject() {
|
190
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
191
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
192
|
|
"actualobj", "abc"
|
193
|
|
});
|
194
|
|
|
195
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
196
|
1
|
Object expectedReturn = "abc";
|
197
|
1
|
Object actualReturn = m_abstractAssertTagHandler.getActualObject();
|
198
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
199
|
|
}
|
200
|
|
|
201
|
|
|
202
|
|
|
203
|
|
|
204
|
1
|
public void testGetExpectedObject() {
|
205
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
206
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
207
|
|
"expectedobj", "abc"
|
208
|
|
});
|
209
|
|
|
210
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
211
|
1
|
Object expectedReturn = "abc";
|
212
|
1
|
Object actualReturn = m_abstractAssertTagHandler.getExpectedObject();
|
213
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
214
|
|
}
|
215
|
|
|
216
|
|
|
217
|
|
|
218
|
|
|
219
|
1
|
public void testGetExpectedID() {
|
220
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
221
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
222
|
|
"expectedrefid", "data"
|
223
|
|
|
224
|
|
});
|
225
|
|
|
226
|
1
|
tc.addProperty("data", "abc");
|
227
|
|
|
228
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
229
|
1
|
Object expectedReturn = "abc";
|
230
|
1
|
Object actualReturn = m_abstractAssertTagHandler.getExpectedObject();
|
231
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
232
|
|
}
|
233
|
|
|
234
|
|
|
235
|
|
|
236
|
|
|
237
|
1
|
public void testGetMessage() {
|
238
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
239
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
240
|
|
"message", "abc"
|
241
|
|
|
242
|
|
});
|
243
|
|
|
244
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
245
|
1
|
String expectedReturn = "abc";
|
246
|
1
|
String actualReturn = m_abstractAssertTagHandler.getMessage();
|
247
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
248
|
|
}
|
249
|
|
|
250
|
|
|
251
|
|
|
252
|
|
|
253
|
1
|
public void testGetRefId() {
|
254
|
1
|
IXMLTestCase tc = m_fixture.getTestCase();
|
255
|
1
|
Element e = m_fixture.newElement("impltest", new String[] {
|
256
|
|
"refid", "abc"
|
257
|
|
});
|
258
|
|
|
259
|
1
|
m_abstractAssertTagHandler = new ImplAssertTagHandler(e, tc);
|
260
|
1
|
String expectedReturn = "abc";
|
261
|
1
|
String actualReturn = m_abstractAssertTagHandler.getRefId();
|
262
|
1
|
assertEquals("return value", expectedReturn, actualReturn);
|
263
|
|
}
|
264
|
|
|
265
|
|
}
|
266
|
|
|