(no commit message)
[utils] / support / general / src / test / java / org / wamblee / xml / XmlUtils.java
index 4aea6bfa74f831dab110fc2b5be28849b3419b10..3888e6f77ba2d3cce1652e95e57cf929a9497cc8 100644 (file)
@@ -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);
+    }
+    
 }