class XPathAssert {

    public static void assertEquals(final Document document,
            final String expression, final String expected)
                    throws XPathExpressionException {
        final XPathFactory xpathFactory = XPathFactory.newInstance();
        final XPath xpath = xpathFactory.newXPath();
        final Document doc;
        if (document instanceof XmlDocument) {
            final XmlDocument xmldocument = (XmlDocument) document;
            doc = xmldocument.getDocument();
        } else {
            doc = document;
        }
        final String actual = (String) xpath.evaluate(expression,
                doc, XPathConstants.STRING);
        Assert.assertEquals(expected, actual);
    }

    private  XPathAssert();

}