Class XpathRequestMatchers
java.lang.Object
org.springframework.test.web.client.match.XpathRequestMatchers
Factory methods for request content
RequestMatcher
implementations
that use an XPath expression.
An instance of this class is typically accessed via
MockRestRequestMatchers.xpath(String, Object...)
or
MockRestRequestMatchers.xpath(String, Map, Object...)
.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbooleanValue
(Boolean value) Apply the XPath and assert the boolean value found.Assert that content does not exist at the given XPath.exists()
Assert that content exists at the given XPath.Apply the XPath and assert it with the givenMatcher<Node>
.nodeCount
(int expectedCount) Apply the XPath and assert the number of nodes found.Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>
.Apply the XPath and assert the number value found.Apply the XPath and assert the number found with the given matcher.Apply the XPath and assert the String content found.Apply the XPath and assert the String content found with the given matcher.
-
Constructor Details
-
XpathRequestMatchers
protected XpathRequestMatchers(String expression, @Nullable Map<String, String> namespaces, Object... args) throws XPathExpressionExceptionClass constructor, not for direct instantiation.Use
MockRestRequestMatchers.xpath(String, Object...)
orMockRestRequestMatchers.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
- if expression compilation failed
-
-
Method Details
-
node
Apply the XPath and assert it with the givenMatcher<Node>
. -
exists
Assert that content exists at the given XPath. -
doesNotExist
Assert that content does not exist at the given XPath. -
nodeCount
Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>
. -
nodeCount
Apply the XPath and assert the number of nodes found. -
string
Apply the XPath and assert the String content found with the given matcher. -
string
Apply the XPath and assert the String content found. -
number
Apply the XPath and assert the number found with the given matcher. -
number
Apply the XPath and assert the number value found. -
booleanValue
Apply the XPath and assert the boolean value found.
-