|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| package nu.xom.tests; |
|
23 |
| |
|
24 |
| import junit.framework.ComparisonFailure; |
|
25 |
| import junit.framework.TestCase; |
|
26 |
| import nu.xom.Attribute; |
|
27 |
| import nu.xom.Comment; |
|
28 |
| import nu.xom.DocType; |
|
29 |
| import nu.xom.Document; |
|
30 |
| import nu.xom.Element; |
|
31 |
| import nu.xom.Namespace; |
|
32 |
| import nu.xom.Node; |
|
33 |
| import nu.xom.ProcessingInstruction; |
|
34 |
| import nu.xom.Text; |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| public class XOMTestCase extends TestCase { |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
1388
| public XOMTestCase(String name) {
|
|
55 |
1388
| super(name);
|
|
56 |
| } |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
4
| public static void assertEquals(Text expected, Text actual) {
|
|
73 |
4
| assertEquals(null, expected, actual);
|
|
74 |
| } |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
33994
| public static void assertEquals(
|
|
94 |
| String message, Text expected, Text actual) { |
|
95 |
| |
|
96 |
1
| if (actual == expected) return;
|
|
97 |
33993
| nullCheck(message, expected, actual);
|
|
98 |
| |
|
99 |
33991
| assertEquals(message, expected.getValue(), actual.getValue());
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
125656
| private static void nullCheck(String message, Node expected, Node actual) {
|
|
104 |
| |
|
105 |
125656
| if (expected == null) {
|
|
106 |
1
| throw new ComparisonFailure(message, null, actual.toXML());
|
|
107 |
| } |
|
108 |
125655
| else if (actual == null) {
|
|
109 |
2
| throw new ComparisonFailure(message, expected.toXML(), null);
|
|
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 |
10
| public static void assertEquals(
|
|
138 |
| Attribute expected, Attribute actual) { |
|
139 |
10
| assertEquals(null, expected, actual);
|
|
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 |
11213
| public static void assertEquals(
|
|
168 |
| String message, Attribute expected, Attribute actual) { |
|
169 |
| |
|
170 |
8
| if (actual == expected) return;
|
|
171 |
11205
| nullCheck(message, expected, actual);
|
|
172 |
| |
|
173 |
11205
| String value1 = expected.getValue();
|
|
174 |
11205
| String value2 = actual.getValue();
|
|
175 |
11205
| if ("xml:base".equals(expected.getQualifiedName())) {
|
|
176 |
| |
|
177 |
73
| if (value1.equals(value2)) return;
|
|
178 |
29
| if (value1.startsWith("../")) {
|
|
179 |
27
| assertTrue(message, value2.endsWith(value1.substring(2)));
|
|
180 |
| } |
|
181 |
| else { |
|
182 |
2
| assertTrue(message,
|
|
183 |
| value1.endsWith('/' + value2) || value2.endsWith('/' + value1)); |
|
184 |
| } |
|
185 |
| } |
|
186 |
| else { |
|
187 |
11103
| assertEquals(message, value1, value2);
|
|
188 |
11103
| assertEquals(message, expected.getLocalName(), actual.getLocalName());
|
|
189 |
11103
| assertEquals(message,
|
|
190 |
| expected.getQualifiedName(), actual.getQualifiedName() |
|
191 |
| ); |
|
192 |
11103
| assertEquals(message,
|
|
193 |
| expected.getNamespaceURI(), actual.getNamespaceURI() |
|
194 |
| ); |
|
195 |
| } |
|
196 |
| |
|
197 |
| } |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
| |
|
216 |
11
| public static void assertEquals(DocType expected, DocType actual) {
|
|
217 |
11
| assertEquals(null, expected, actual);
|
|
218 |
| } |
|
219 |
| |
|
220 |
| |
|
221 |
| |
|
222 |
| |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
| |
|
235 |
| |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
| |
|
240 |
587
| public static void assertEquals(
|
|
241 |
| String message, DocType expected, DocType actual) { |
|
242 |
| |
|
243 |
11
| if (actual == expected) return;
|
|
244 |
576
| nullCheck(message, expected, actual);
|
|
245 |
| |
|
246 |
576
| assertEquals(message,
|
|
247 |
| expected.getPublicID(), |
|
248 |
| actual.getPublicID() |
|
249 |
| ); |
|
250 |
576
| assertEquals(message,
|
|
251 |
| expected.getSystemID(), |
|
252 |
| actual.getSystemID() |
|
253 |
| ); |
|
254 |
576
| assertEquals(message,
|
|
255 |
| expected.getRootElementName(), |
|
256 |
| actual.getRootElementName() |
|
257 |
| ); |
|
258 |
| } |
|
259 |
| |
|
260 |
| |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
| |
|
266 |
| |
|
267 |
| |
|
268 |
| |
|
269 |
| |
|
270 |
| |
|
271 |
| |
|
272 |
| |
|
273 |
| |
|
274 |
| |
|
275 |
| |
|
276 |
| |
|
277 |
31
| public static void assertEquals(
|
|
278 |
| Element expected, Element actual) { |
|
279 |
31
| assertEquals(null, expected, actual);
|
|
280 |
| |
|
281 |
| } |
|
282 |
| |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| |
|
288 |
| |
|
289 |
| |
|
290 |
| |
|
291 |
| |
|
292 |
| |
|
293 |
| |
|
294 |
| |
|
295 |
| |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
| |
|
300 |
| |
|
301 |
| |
|
302 |
21019
| public static void assertEquals(String message,
|
|
303 |
| Element expected, Element actual) { |
|
304 |
| |
|
305 |
19
| if (actual == expected) return;
|
|
306 |
21000
| nullCheck(message, expected, actual);
|
|
307 |
| |
|
308 |
21000
| assertEquals(message,
|
|
309 |
| expected.getLocalName(), |
|
310 |
| actual.getLocalName() |
|
311 |
| ); |
|
312 |
20999
| assertEquals(message,
|
|
313 |
| expected.getNamespacePrefix(), |
|
314 |
| actual.getNamespacePrefix() |
|
315 |
| ); |
|
316 |
20999
| assertEquals(message,
|
|
317 |
| expected.getNamespaceURI(), |
|
318 |
| actual.getNamespaceURI() |
|
319 |
| ); |
|
320 |
| |
|
321 |
20999
| assertEquals(message,
|
|
322 |
| expected.getAttributeCount(), |
|
323 |
| actual.getAttributeCount() |
|
324 |
| ); |
|
325 |
| |
|
326 |
20999
| for (int i = 0; i < expected.getAttributeCount(); i++ ) {
|
|
327 |
11201
| Attribute att1 = expected.getAttribute(i);
|
|
328 |
11201
| Attribute att2
|
|
329 |
| = actual.getAttribute( |
|
330 |
| att1.getLocalName(), |
|
331 |
| att1.getNamespaceURI() |
|
332 |
| ); |
|
333 |
11201
| assertNotNull(message, att2);
|
|
334 |
11201
| assertEquals(message, att1, att2);
|
|
335 |
| } |
|
336 |
| |
|
337 |
| |
|
338 |
| |
|
339 |
| |
|
340 |
| |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
20999
| for (int i = 0;
|
|
345 |
42178
| i < expected.getNamespaceDeclarationCount();
|
|
346 |
| i++ ) { |
|
347 |
21179
| String prefix1 = expected.getNamespacePrefix(i);
|
|
348 |
21179
| String uri1 = expected.getNamespaceURI(prefix1);
|
|
349 |
21179
| assertNotNull(message, actual.getNamespaceURI(prefix1));
|
|
350 |
21179
| assertEquals(message,
|
|
351 |
| uri1, actual.getNamespaceURI(prefix1) |
|
352 |
| ); |
|
353 |
| } |
|
354 |
20999
| for (int i = 0;
|
|
355 |
42153
| i < actual.getNamespaceDeclarationCount();
|
|
356 |
| i++ ) { |
|
357 |
21154
| String prefix1 = actual.getNamespacePrefix(i);
|
|
358 |
21154
| String uri1 = actual.getNamespaceURI(prefix1);
|
|
359 |
21154
| assertNotNull(message, expected.getNamespaceURI(prefix1));
|
|
360 |
21154
| assertEquals(message,
|
|
361 |
| uri1, expected.getNamespaceURI(prefix1) |
|
362 |
| ); |
|
363 |
| } |
|
364 |
| |
|
365 |
20999
| compareChildren(message, expected, actual);
|
|
366 |
| |
|
367 |
| } |
|
368 |
| |
|
369 |
| |
|
370 |
41998
| private static boolean hasAdjacentTextNodes(Element element) {
|
|
371 |
| |
|
372 |
41998
| boolean previousWasText = false;
|
|
373 |
41998
| int count = element.getChildCount();
|
|
374 |
41998
| for (int i = 0; i < count; i++) {
|
|
375 |
152424
| Node child = element.getChild(i);
|
|
376 |
152424
| if (child instanceof Text) {
|
|
377 |
46
| if (previousWasText) return true;
|
|
378 |
67963
| else previousWasText = true;
|
|
379 |
| } |
|
380 |
| else { |
|
381 |
84415
| previousWasText = false;
|
|
382 |
| } |
|
383 |
| } |
|
384 |
41952
| return false;
|
|
385 |
| |
|
386 |
| } |
|
387 |
| |
|
388 |
| |
|
389 |
20999
| private static void compareChildren(String message, Element expected, Element actual) {
|
|
390 |
| |
|
391 |
20999
| Element expectedCopy = expected;
|
|
392 |
20999
| Element actualCopy = actual;
|
|
393 |
20999
| if (hasAdjacentTextNodes(expected)) {
|
|
394 |
3
| expectedCopy = combineTextNodes(expected);
|
|
395 |
| } |
|
396 |
20999
| if (hasAdjacentTextNodes(actual)) {
|
|
397 |
43
| actualCopy = combineTextNodes(actual);
|
|
398 |
| } |
|
399 |
| |
|
400 |
20999
| int count = expectedCopy.getChildCount();
|
|
401 |
20999
| assertEquals(message, count, actualCopy.getChildCount());
|
|
402 |
20997
| int nonTextNodes = count;
|
|
403 |
20997
| for (int i = 0; i < count; i++) {
|
|
404 |
54456
| Node child1 = expectedCopy.getChild(i);
|
|
405 |
| |
|
406 |
| |
|
407 |
54456
| if (child1 instanceof Text) {
|
|
408 |
33989
| nonTextNodes--;
|
|
409 |
33989
| Node child2 = actualCopy.getChild(i);
|
|
410 |
33989
| assertEquals(message, child1, child2);
|
|
411 |
| } |
|
412 |
| } |
|
413 |
| |
|
414 |
| |
|
415 |
| |
|
416 |
20997
| for (int i = 0; i < nonTextNodes; i++) {
|
|
417 |
20467
| Node expectedChild = getNonTextNode(expected, i);
|
|
418 |
20467
| Node actualChild = getNonTextNode(actual, i);
|
|
419 |
20467
| assertEquals(message, expectedChild, actualChild);
|
|
420 |
| } |
|
421 |
| |
|
422 |
| } |
|
423 |
| |
|
424 |
| |
|
425 |
40934
| private static Node getNonTextNode(Element element, int index) {
|
|
426 |
| |
|
427 |
40934
| int nonTextCount = 0;
|
|
428 |
40934
| int count = element.getChildCount();
|
|
429 |
265409
| for (int i = 0; i < count; i++) {
|
|
430 |
265409
| Node child = element.getChild(i);
|
|
431 |
265409
| if (! (child instanceof Text) ) {
|
|
432 |
40934
| if (nonTextCount == index) return child;
|
|
433 |
98146
| nonTextCount++;
|
|
434 |
| } |
|
435 |
| } |
|
436 |
0
| throw new RuntimeException(
|
|
437 |
| "Bug in XOMTestCase: this statement should not be reachable"); |
|
438 |
| |
|
439 |
| } |
|
440 |
| |
|
441 |
| |
|
442 |
| |
|
443 |
| |
|
444 |
| |
|
445 |
46
| private static Element combineTextNodes(Element element) {
|
|
446 |
| |
|
447 |
46
| Element stub = new Element("a");
|
|
448 |
46
| Comment stubc = new Comment("c");
|
|
449 |
46
| StringBuffer sb = new StringBuffer();
|
|
450 |
46
| int count = element.getChildCount();
|
|
451 |
46
| for (int i = 0; i < count; i++) {
|
|
452 |
100
| Node child = element.getChild(i);
|
|
453 |
100
| if (child instanceof Text) {
|
|
454 |
73
| sb.setLength(0);
|
|
455 |
73
| do {
|
|
456 |
153
| sb.append(child.getValue());
|
|
457 |
153
| i++;
|
|
458 |
153
| if (i == count) {
|
|
459 |
46
| break;
|
|
460 |
| } |
|
461 |
107
| child = element.getChild(i);
|
|
462 |
107
| } while (child instanceof Text);
|
|
463 |
73
| i--;
|
|
464 |
73
| stub.appendChild(sb.toString());
|
|
465 |
| } |
|
466 |
| else { |
|
467 |
27
| stub.appendChild(stubc.copy());
|
|
468 |
| } |
|
469 |
| } |
|
470 |
46
| return stub;
|
|
471 |
| |
|
472 |
| } |
|
473 |
| |
|
474 |
| |
|
475 |
| |
|
476 |
| |
|
477 |
| |
|
478 |
| |
|
479 |
| |
|
480 |
| |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
| |
|
486 |
| |
|
487 |
| |
|
488 |
197
| public static void assertEquals(
|
|
489 |
| Document expected, Document actual) { |
|
490 |
197
| assertEquals(null, expected, actual);
|
|
491 |
| } |
|
492 |
| |
|
493 |
| |
|
494 |
| |
|
495 |
| |
|
496 |
| |
|
497 |
| |
|
498 |
| |
|
499 |
| |
|
500 |
| |
|
501 |
| |
|
502 |
| |
|
503 |
| |
|
504 |
| |
|
505 |
| |
|
506 |
| |
|
507 |
| |
|
508 |
| |
|
509 |
1006
| public static void assertEquals(
|
|
510 |
| String message, Document expected, Document actual) { |
|
511 |
| |
|
512 |
2
| if (actual == expected) return;
|
|
513 |
1004
| nullCheck(message, expected, actual);
|
|
514 |
| |
|
515 |
1004
| assertEquals(message,
|
|
516 |
| expected.getChildCount(), |
|
517 |
| actual.getChildCount() |
|
518 |
| ); |
|
519 |
1002
| for (int i = 0; i < actual.getChildCount(); i++) {
|
|
520 |
1957
| Node child1 = expected.getChild(i);
|
|
521 |
1957
| Node child2 = actual.getChild(i);
|
|
522 |
1957
| assertEquals(message, child1, child2);
|
|
523 |
| } |
|
524 |
| |
|
525 |
| } |
|
526 |
| |
|
527 |
| |
|
528 |
| |
|
529 |
| |
|
530 |
| |
|
531 |
| |
|
532 |
| |
|
533 |
| |
|
534 |
| |
|
535 |
| |
|
536 |
| |
|
537 |
| |
|
538 |
| |
|
539 |
| |
|
540 |
| |
|
541 |
| |
|
542 |
1
| public static void assertEquals(Comment expected, Comment actual) {
|
|
543 |
1
| assertEquals(null, expected, actual);
|
|
544 |
| } |
|
545 |
| |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
| |
|
550 |
| |
|
551 |
| |
|
552 |
| |
|
553 |
| |
|
554 |
| |
|
555 |
| |
|
556 |
| |
|
557 |
| |
|
558 |
| |
|
559 |
| |
|
560 |
| |
|
561 |
| |
|
562 |
| |
|
563 |
1065
| public static void assertEquals(
|
|
564 |
| String message, Comment expected, Comment actual) { |
|
565 |
| |
|
566 |
1
| if (actual == expected) return;
|
|
567 |
1064
| nullCheck(message, expected, actual);
|
|
568 |
1064
| assertEquals(message, expected.getValue(), actual.getValue());
|
|
569 |
| |
|
570 |
| } |
|
571 |
| |
|
572 |
| |
|
573 |
| |
|
574 |
| |
|
575 |
| |
|
576 |
| |
|
577 |
| |
|
578 |
| |
|
579 |
| |
|
580 |
| |
|
581 |
| |
|
582 |
| |
|
583 |
| |
|
584 |
| |
|
585 |
| |
|
586 |
| |
|
587 |
| |
|
588 |
2
| public static void assertEquals(ProcessingInstruction expected,
|
|
589 |
| ProcessingInstruction actual) { |
|
590 |
2
| assertEquals(null, expected, actual);
|
|
591 |
| } |
|
592 |
| |
|
593 |
| |
|
594 |
| |
|
595 |
| |
|
596 |
| |
|
597 |
| |
|
598 |
| |
|
599 |
| |
|
600 |
| |
|
601 |
| |
|
602 |
| |
|
603 |
| |
|
604 |
| |
|
605 |
| |
|
606 |
| |
|
607 |
| |
|
608 |
| |
|
609 |
| |
|
610 |
| |
|
611 |
| |
|
612 |
| |
|
613 |
96
| public static void assertEquals(String message,
|
|
614 |
| ProcessingInstruction expected, |
|
615 |
| ProcessingInstruction actual) { |
|
616 |
| |
|
617 |
1
| if (actual == expected) return;
|
|
618 |
95
| nullCheck(message, expected, actual);
|
|
619 |
| |
|
620 |
95
| assertEquals(message, expected.getValue(), actual.getValue());
|
|
621 |
95
| assertEquals(message, expected.getTarget(), actual.getTarget());
|
|
622 |
| |
|
623 |
| } |
|
624 |
| |
|
625 |
| |
|
626 |
| |
|
627 |
| |
|
628 |
| |
|
629 |
| |
|
630 |
| |
|
631 |
| |
|
632 |
| |
|
633 |
| |
|
634 |
| |
|
635 |
| |
|
636 |
| |
|
637 |
| |
|
638 |
| |
|
639 |
| |
|
640 |
| |
|
641 |
| |
|
642 |
1
| public static void assertEquals(String message,
|
|
643 |
| Namespace expected, Namespace actual) { |
|
644 |
| |
|
645 |
0
| if (actual == expected) return;
|
|
646 |
1
| nullCheck(message, expected, actual);
|
|
647 |
| |
|
648 |
1
| assertEquals(message, expected.getValue(), actual.getValue());
|
|
649 |
1
| assertEquals(message, expected.getPrefix(), actual.getPrefix());
|
|
650 |
| |
|
651 |
| } |
|
652 |
| |
|
653 |
| |
|
654 |
| |
|
655 |
| |
|
656 |
| |
|
657 |
| |
|
658 |
| |
|
659 |
| |
|
660 |
| |
|
661 |
| |
|
662 |
| |
|
663 |
| |
|
664 |
| |
|
665 |
| |
|
666 |
| |
|
667 |
| |
|
668 |
| |
|
669 |
| |
|
670 |
208
| public static void assertEquals(Node expected, Node actual) {
|
|
671 |
208
| assertEquals(null, expected, actual);
|
|
672 |
| } |
|
673 |
| |
|
674 |
| |
|
675 |
| |
|
676 |
| |
|
677 |
| |
|
678 |
| |
|
679 |
| |
|
680 |
| |
|
681 |
| |
|
682 |
| |
|
683 |
| |
|
684 |
| |
|
685 |
| |
|
686 |
| |
|
687 |
| |
|
688 |
| |
|
689 |
| |
|
690 |
| |
|
691 |
| |
|
692 |
56896
| public static void assertEquals(
|
|
693 |
| String message, Node expected, Node actual) { |
|
694 |
| |
|
695 |
178
| if (actual == expected) return;
|
|
696 |
56718
| nullCheck(message, expected, actual);
|
|
697 |
| |
|
698 |
56717
| try {
|
|
699 |
56717
| if (expected instanceof Document) {
|
|
700 |
1
| assertEquals(message, (Document) expected, (Document) actual);
|
|
701 |
| } |
|
702 |
56716
| else if (expected instanceof Element) {
|
|
703 |
20987
| assertEquals(message, (Element) expected, (Element) actual);
|
|
704 |
| } |
|
705 |
35729
| else if (expected instanceof Text) {
|
|
706 |
33991
| assertEquals(message, (Text) expected, (Text) actual);
|
|
707 |
| } |
|
708 |
1738
| else if (expected instanceof DocType) {
|
|
709 |
576
| assertEquals(message,
|
|
710 |
| (DocType) expected, |
|
711 |
| (DocType) actual |
|
712 |
| ); |
|
713 |
| } |
|
714 |
1162
| else if (expected instanceof Comment) {
|
|
715 |
1064
| assertEquals(message,
|
|
716 |
| (Comment) expected, |
|
717 |
| (Comment) actual |
|
718 |
| ); |
|
719 |
| } |
|
720 |
98
| else if (expected instanceof ProcessingInstruction) {
|
|
721 |
94
| assertEquals(message,
|
|
722 |
| (ProcessingInstruction) expected, |
|
723 |
| (ProcessingInstruction) actual |
|
724 |
| ); |
|
725 |
| } |
|
726 |
4
| else if (expected instanceof Attribute) {
|
|
727 |
3
| assertEquals(message,
|
|
728 |
| (Attribute) expected, |
|
729 |
| (Attribute) actual |
|
730 |
| ); |
|
731 |
| } |
|
732 |
1
| else if (expected instanceof Namespace) {
|
|
733 |
1
| assertEquals(message,
|
|
734 |
| (Namespace) expected, |
|
735 |
| (Namespace) actual |
|
736 |
| ); |
|
737 |
| } |
|
738 |
| else { |
|
739 |
0
| throw new IllegalArgumentException(
|
|
740 |
| "Unexpected node type " |
|
741 |
| + expected.getClass().getName() |
|
742 |
| ); |
|
743 |
| } |
|
744 |
| } |
|
745 |
| catch (ClassCastException ex) { |
|
746 |
2
| throw new ComparisonFailure(message
|
|
747 |
| + "; Mismatched node types: " |
|
748 |
| + expected.getClass().getName() + " != " |
|
749 |
| + actual.getClass().getName(), |
|
750 |
| expected.toXML(), actual.toXML()); |
|
751 |
| } |
|
752 |
| |
|
753 |
| } |
|
754 |
| |
|
755 |
| |
|
756 |
| } |