类 XpathResultMatchers
- java.lang.Object
- org.springframework.test.web.servlet.result.XpathResultMatchers
public class XpathResultMatchers extends Object
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...)
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResultMatcher
booleanValue(Boolean value)
Evaluate the XPath and assert theBoolean
value found.ResultMatcher
doesNotExist()
Evaluate the XPath and assert that content doesn't exist.ResultMatcher
exists()
Evaluate the XPath and assert that content exists.ResultMatcher
node(Matcher<? super Node> matcher)
ResultMatcher
nodeCount(int expectedCount)
Evaluate the XPath and assert the number of nodes found.ResultMatcher
nodeCount(Matcher<Integer> matcher)
Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher
.ResultMatcher
number(Double expectedValue)
Evaluate the XPath and assert theDouble
value found.ResultMatcher
number(Matcher<? super Double> matcher)
ResultMatcher
string(String expectedValue)
Apply the XPath and assert theString
value found.ResultMatcher
string(Matcher<? super String> matcher)
构造器详细资料
XpathResultMatchers
protected XpathResultMatchers(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
Protected constructor, not for direct instantiation. UseMockMvcResultMatchers.xpath(String, Object...)
orMockMvcResultMatchers.xpath(String, Map, Object...)
.- 参数:
expression
- the XPath expressionnamespaces
- 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
方法详细资料
node
public ResultMatcher node(Matcher<? super Node> matcher)
exists
public ResultMatcher exists()
Evaluate the XPath and assert that content exists.
doesNotExist
public ResultMatcher doesNotExist()
Evaluate the XPath and assert that content doesn't exist.
nodeCount
public ResultMatcher nodeCount(Matcher<Integer> matcher)
Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher
.
nodeCount
public ResultMatcher nodeCount(int expectedCount)
Evaluate the XPath and assert the number of nodes found.
string
public ResultMatcher string(Matcher<? super String> matcher)
string
public ResultMatcher string(String expectedValue)
Apply the XPath and assert theString
value found.
number
public ResultMatcher number(Matcher<? super Double> matcher)
number
public ResultMatcher number(Double expectedValue)
Evaluate the XPath and assert theDouble
value found.
booleanValue
public ResultMatcher booleanValue(Boolean value)
Evaluate the XPath and assert theBoolean
value found.