类 XpathExpectationsHelper


  • public class XpathExpectationsHelper
    extends Object
    A helper class for applying assertions via XPath expressions.
    从以下版本开始:
    3.2
    作者:
    Rossen Stoyanchev
    • 方法详细资料

      • parseXmlByteArray

        protected Document parseXmlByteArray​(byte[] xml,
                                             String encoding)
                                      throws Exception
        Parse the given XML content to a Document.
        参数:
        xml - the content to parse
        encoding - optional content encoding, if provided as metadata (e.g. in HTTP headers)
        返回:
        the parsed document
        抛出:
        Exception
      • exists

        public void exists​(byte[] content,
                           String encoding)
                    throws Exception
        Apply the XPath expression and assert the resulting content exists.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • doesNotExist

        public void doesNotExist​(byte[] content,
                                 String encoding)
                          throws Exception
        Apply the XPath expression and assert the resulting content does not exist.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertNodeCount

        public void assertNodeCount​(byte[] content,
                                    String encoding,
                                    Matcher<Integer> matcher)
                             throws Exception
        Apply the XPath expression and assert the resulting content with the given Hamcrest matcher.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertNodeCount

        public void assertNodeCount​(byte[] content,
                                    String encoding,
                                    int expectedCount)
                             throws Exception
        Apply the XPath expression and assert the resulting content as an integer.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertString

        public void assertString​(byte[] content,
                                 String encoding,
                                 Matcher<? super String> matcher)
                          throws Exception
        Apply the XPath expression and assert the resulting content with the given Hamcrest matcher.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertString

        public void assertString​(byte[] content,
                                 String encoding,
                                 String expectedValue)
                          throws Exception
        Apply the XPath expression and assert the resulting content as a String.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertNumber

        public void assertNumber​(byte[] content,
                                 String encoding,
                                 Matcher<? super Double> matcher)
                          throws Exception
        Apply the XPath expression and assert the resulting content with the given Hamcrest matcher.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertNumber

        public void assertNumber​(byte[] content,
                                 String encoding,
                                 Double expectedValue)
                          throws Exception
        Apply the XPath expression and assert the resulting content as a Double.
        抛出:
        Exception - if content parsing or expression evaluation fails
      • assertBoolean

        public void assertBoolean​(byte[] content,
                                  String encoding,
                                  boolean expectedValue)
                           throws Exception
        Apply the XPath expression and assert the resulting content as a Boolean.
        抛出:
        Exception - if content parsing or expression evaluation fails