类 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
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResultMatcherbooleanValue(Boolean value)Evaluate the XPath and assert theBooleanvalue found.ResultMatcherdoesNotExist()Evaluate the XPath and assert that content doesn't exist.ResultMatcherexists()Evaluate the XPath and assert that content exists.ResultMatchernode(Matcher<? super Node> matcher)ResultMatchernodeCount(int expectedCount)Evaluate the XPath and assert the number of nodes found.ResultMatchernodeCount(Matcher<Integer> matcher)Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher.ResultMatchernumber(Double expectedValue)Evaluate the XPath and assert theDoublevalue found.ResultMatchernumber(Matcher<? super Double> matcher)ResultMatcherstring(String expectedValue)Apply the XPath and assert theStringvalue found.ResultMatcherstring(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, ornullargs- 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 theStringvalue found.
number
public ResultMatcher number(Matcher<? super Double> matcher)
number
public ResultMatcher number(Double expectedValue)
Evaluate the XPath and assert theDoublevalue found.
booleanValue
public ResultMatcher booleanValue(Boolean value)
Evaluate the XPath and assert theBooleanvalue found.