类 XpathRequestMatchers
- java.lang.Object
- org.springframework.test.web.client.match.XpathRequestMatchers
public class XpathRequestMatchers extends Object
Factory methods for request contentRequestMatcher
implementations that use an XPath expression.An instance of this class is typically accessed via
MockRestRequestMatchers.xpath(String, Object...)
orMockRestRequestMatchers.xpath(String, Map, Object...)
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Sam Brannen
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 RequestMatcher
booleanValue(Boolean value)
Apply the XPath and assert the boolean value found.RequestMatcher
doesNotExist()
Assert that content does not exist at the given XPath.RequestMatcher
exists()
Assert that content exists at the given XPath.RequestMatcher
node(Matcher<? super Node> matcher)
Apply the XPath and assert it with the givenMatcher<Node>
.RequestMatcher
nodeCount(int expectedCount)
Apply the XPath and assert the number of nodes found.RequestMatcher
nodeCount(Matcher<Integer> matcher)
Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>
.RequestMatcher
number(Double value)
Apply the XPath and assert the number value found.RequestMatcher
number(Matcher<? super Double> matcher)
Apply the XPath and assert the number found with the given matcher.RequestMatcher
string(String content)
Apply the XPath and assert the String content found.RequestMatcher
string(Matcher<? super String> matcher)
Apply the XPath and assert the String content found with the given matcher.
构造器详细资料
XpathRequestMatchers
protected XpathRequestMatchers(String expression, @Nullable Map<String,String> namespaces, Object... args) throws XPathExpressionException
Class constructor, not for direct instantiation.Use
MockRestRequestMatchers.xpath(String, Object...)
orMockRestRequestMatchers.xpath(String, Map, Object...)
.- 参数:
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...)
- 抛出:
XPathExpressionException
- if expression compilation failed
方法详细资料
node
public RequestMatcher node(Matcher<? super Node> matcher)
Apply the XPath and assert it with the givenMatcher<Node>
.
exists
public RequestMatcher exists()
Assert that content exists at the given XPath.
doesNotExist
public RequestMatcher doesNotExist()
Assert that content does not exist at the given XPath.
nodeCount
public RequestMatcher nodeCount(Matcher<Integer> matcher)
Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>
.
nodeCount
public RequestMatcher nodeCount(int expectedCount)
Apply the XPath and assert the number of nodes found.
string
public RequestMatcher string(Matcher<? super String> matcher)
Apply the XPath and assert the String content found with the given matcher.
string
public RequestMatcher string(String content)
Apply the XPath and assert the String content found.
number
public RequestMatcher number(Matcher<? super Double> matcher)
Apply the XPath and assert the number found with the given matcher.
number
public RequestMatcher number(Double value)
Apply the XPath and assert the number value found.
booleanValue
public RequestMatcher booleanValue(Boolean value)
Apply the XPath and assert the boolean value found.