X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxml%2FXmlUtils.java;fp=support%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxml%2FXmlUtils.java;h=3888e6f77ba2d3cce1652e95e57cf929a9497cc8;hb=c26b5bc555baf98bc92797050adfafb67678f6e8;hp=4aea6bfa74f831dab110fc2b5be28849b3419b10;hpb=8e04c66858057fc46473eaadbab0a2b4f1aae22f;p=utils diff --git a/support/general/src/test/java/org/wamblee/xml/XmlUtils.java b/support/general/src/test/java/org/wamblee/xml/XmlUtils.java index 4aea6bfa..3888e6f7 100644 --- a/support/general/src/test/java/org/wamblee/xml/XmlUtils.java +++ b/support/general/src/test/java/org/wamblee/xml/XmlUtils.java @@ -26,7 +26,10 @@ import junit.framework.TestCase; import org.dom4j.Attribute; import org.dom4j.Document; +import org.dom4j.DocumentException; import org.dom4j.Element; +import org.dom4j.io.DOMReader; +import org.dom4j.io.DOMWriter; /** * XML test support utilities. @@ -53,8 +56,7 @@ public final class XmlUtils { */ public static void assertEquals(String aMsg, org.w3c.dom.Document aExpected, org.w3c.dom.Document aActual) { - assertEquals(aMsg, DomUtils.convert(aExpected), DomUtils - .convert(aActual)); + assertEquals(aMsg, convert(aExpected), convert(aActual)); } /** @@ -168,4 +170,31 @@ public final class XmlUtils { return aAttribute1.getName().compareTo(aAttribute2.getName()); } } + + /** + * Converts a dom4j document into a w3c DOM document. + * + * @param aDocument + * Document to convert. + * + * @return W3C DOM document. + * + */ + public static org.w3c.dom.Document convert(org.dom4j.Document aDocument) + throws DocumentException { + return new DOMWriter().write(aDocument); + } + + /** + * Converts a W3C DOM document into a dom4j document. + * + * @param aDocument + * Document to convert. + * + * @return Dom4j document. + */ + public static org.dom4j.Document convert(org.w3c.dom.Document aDocument) { + return new DOMReader().read(aDocument); + } + }