1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformers.xml;
12
13 import org.mule.tck.AbstractTransformerTestCase;
14
15 import org.custommonkey.xmlunit.XMLUnit;
16 import org.w3c.dom.Document;
17
18
19
20
21 public abstract class AbstractXmlTransformerTestCase extends AbstractTransformerTestCase
22 {
23
24 protected AbstractXmlTransformerTestCase()
25 {
26 super();
27 XMLUnit.setIgnoreWhitespace(true);
28 }
29
30
31 public boolean compareResults(Object expected, Object result)
32 {
33 if (expected instanceof Document && result instanceof Document)
34 {
35 return XMLUnit.compareXML((Document)expected, (Document)result).similar();
36 }
37 else if (expected instanceof String && result instanceof String)
38 {
39 try
40 {
41 String expectedString = this.normalizeString((String)expected);
42 String resultString = this.normalizeString((String)result);
43 return XMLUnit.compareXML(expectedString, resultString).similar();
44 }
45 catch (Exception ex)
46 {
47 return false;
48 }
49 }
50
51
52 return super.compareResults(expected, result);
53 }
54
55 }