Class XpathResultMatchers
java.lang.Object
org.springframework.test.web.servlet.result.XpathResultMatchers
Factory for assertions on the response content using XPath expressions.
An instance of this class is typically accessed via
MockMvcResultMatchers.xpath(java.lang.String, java.lang.Object...)
.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbooleanValue
(Boolean value) Evaluate the XPath and assert theBoolean
value found.Evaluate the XPath and assert that content doesn't exist.exists()
Evaluate the XPath and assert that content exists.nodeCount
(int expectedCount) Evaluate the XPath and assert the number of nodes found.Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher
.Evaluate the XPath and assert theDouble
value found.Apply the XPath and assert theString
value found.
-
Constructor Details
-
XpathResultMatchers
protected XpathResultMatchers(String expression, @Nullable Map<String, String> namespaces, Object... args) throws XPathExpressionExceptionProtected constructor, not for direct instantiation. UseMockMvcResultMatchers.xpath(String, Object...)
orMockMvcResultMatchers.xpath(String, Map, Object...)
.- Parameters:
expression
- the XPath expressionnamespaces
- the XML namespaces referenced in the XPath expression, ornull
args
- arguments to parameterize the XPath expression with using the formatting specifiers defined inString.format(String, Object...)
- Throws:
XPathExpressionException
-
-
Method Details
-
node
-
nodeList
- Since:
- 5.2.2
-
exists
Evaluate the XPath and assert that content exists. -
doesNotExist
Evaluate the XPath and assert that content doesn't exist. -
nodeCount
Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher
. -
nodeCount
Evaluate the XPath and assert the number of nodes found. -
string
-
string
Apply the XPath and assert theString
value found. -
number
-
number
Evaluate the XPath and assert theDouble
value found. -
booleanValue
Evaluate the XPath and assert theBoolean
value found.
-