Class XPathRegexAssert


  • public class XPathRegexAssert
    extends Object
    Example demonstrating how to use the XPath API of XMLUnit in conjunction with regular expressions (as provided by the java.util.regex package of JDK 1.4+).
    • Method Detail

      • assertXPathMatches

        public static void assertXPathMatches​(String message,
                                              String regex,
                                              String xpath,
                                              Document doc)
                                       throws XpathException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        message - assertion message
        regex - regular expression
        xpath - XPath expression
        doc - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
      • assertXPathMatches

        public static void assertXPathMatches​(String message,
                                              String regex,
                                              String xpath,
                                              String xml)
                                       throws XpathException,
                                              SAXException,
                                              IOException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        message - assertion message
        regex - regular expression
        xpath - XPath expression
        xml - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
        SAXException - if the parser says so
        IOException - on I/O errors
      • assertXPathMatches

        public static void assertXPathMatches​(String message,
                                              String regex,
                                              String xpath,
                                              Reader reader)
                                       throws XpathException,
                                              SAXException,
                                              IOException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        message - assertion message
        regex - regular expression
        xpath - XPath expression
        reader - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
        SAXException - if the parser says so
        IOException - on I/O errors
      • assertXPathMatches

        public static void assertXPathMatches​(String regex,
                                              String xpath,
                                              Document doc)
                                       throws XpathException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        regex - regular expression
        xpath - XPath expression
        doc - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
      • assertXPathMatches

        public static void assertXPathMatches​(String regex,
                                              String xpath,
                                              String xml)
                                       throws XpathException,
                                              SAXException,
                                              IOException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        regex - regular expression
        xpath - XPath expression
        xml - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
        SAXException - if the parser says so
        IOException - on I/O errors
      • assertXPathMatches

        public static void assertXPathMatches​(String regex,
                                              String xpath,
                                              Reader reader)
                                       throws XpathException,
                                              SAXException,
                                              IOException
        Asserts result of applying an XPath expression to a document matches a regular expression.
        Parameters:
        regex - regular expression
        xpath - XPath expression
        reader - document to apply XPath expression to
        Throws:
        XpathException - if XPath construction fails
        SAXException - if the parser says so
        IOException - on I/O errors