XmlDom4JHelper { public static org.dom4j.Document convertToDom4JDoc( final org.w3c.dom.Document doc ) throws TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError, DocumentException { DOMSource source = new DOMSource( doc ); StreamResult result = new StreamResult( new StringWriter() ); TransformerFactory.newInstance().newTransformer().transform( source, result ); String theXML = result.getWriter().toString(); Document dom4jDoc = null; try { dom4jDoc = getDocFromString( theXML, null ); } catch ( XmlParseException e ) { throw new TransformerFactoryConfigurationError( e ); } return dom4jDoc; }  static Document getDocFromString( final String strXml, final EntityResolver resolver ); static Document getDocFromFile( final File file, final EntityResolver resolver ); static Document getDocFromStream( final InputStream inStream, final EntityResolver resolver ); static Document getDocFromStream( final InputStream inStream ); static final StringBuffer docToString( final org.w3c.dom.Document doc ); static String getXmlEncodedString( final String rawValue ); static void saveDom( final Document doc, final OutputStream outputStream,
                              String encoding ); static void saveDom( final Document doc, final OutputStream outputStream, String encoding,
      boolean suppressDeclaration ); static void saveDom( final Document doc, final OutputStream outputStream, String encoding,
      boolean suppressDeclaration, boolean prettyPrint ); static String getNodeText( final String xpath, final Node rootNode ); static long getNodeText( final String xpath, final Node rootNode, final long defaultValue ); static double getNodeText( final String xpath, final Node rootNode, final double defaultValue ); static String getNodeText( final String xpath, final Node rootNode, final String defaultValue ); static org.dom4j.Document convertToDom4JDoc( final org.w3c.dom.Document doc );  }
@Test ( expected = TransformerFactoryConfigurationError.class ) public void testConvertToDom4JDocTrowTransformerFactoryConfigurationErrorException() throws Exception { final org.w3c.dom.Document doc = mock( org.w3c.dom.Document.class ); XmlDom4JHelper.convertToDom4JDoc( doc ); }