类 MockRestRequestMatchers
- java.lang.Object
- org.springframework.test.web.client.match.MockRestRequestMatchers
public abstract class MockRestRequestMatchers extends Object
Static factory methods forRequestMatcherclasses. Typically used to provide input forMockRestServiceServer.expect(RequestMatcher).Eclipse Users
Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".
- 从以下版本开始:
- 3.2
- 作者:
- Craig Walls, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 MockRestRequestMatchers()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static RequestMatcheranything()Match to any request.static ContentRequestMatcherscontent()Access to request body matchers.static RequestMatcherheader(String name, String... expectedValues)Assert request header values.static RequestMatcherheader(String name, Matcher<? super String>... matchers)Assert request header values with the given Hamcrest matcher.static JsonPathRequestMatchersjsonPath(String expression, Object... args)Access to request body matchers using a JsonPath expression to inspect a specific subset of the body.static <T> RequestMatcherjsonPath(String expression, Matcher<T> matcher)Access to request body matchers using a JsonPath expression to inspect a specific subset of the body and a Hamcrest match for asserting the value found at the JSON path.static RequestMatchermethod(HttpMethod method)Assert theHttpMethodof the request.static RequestMatcherqueryParam(String name, String... expectedValues)Assert request query parameter values.static RequestMatcherqueryParam(String name, Matcher<? super String>... matchers)Assert request query parameter values with the given Hamcrest matcher.static RequestMatcherrequestTo(String expectedUri)Assert the request URI string.static RequestMatcherrequestTo(URI uri)Expect a request to the given URI.static RequestMatcherrequestTo(Matcher<String> matcher)Assert the request URI string with the given matcher.static XpathRequestMatchersxpath(String expression, Object... args)Access to request body matchers using an XPath to inspect a specific subset of the body.static XpathRequestMatchersxpath(String expression, Map<String,String> namespaces, Object... args)Access to response body matchers using an XPath to inspect a specific subset of the body.
构造器详细资料
MockRestRequestMatchers
public MockRestRequestMatchers()
方法详细资料
anything
public static RequestMatcher anything()
Match to any request.
method
public static RequestMatcher method(HttpMethod method)
Assert theHttpMethodof the request.- 参数:
method- the HTTP method- 返回:
- the request matcher
requestTo
public static RequestMatcher requestTo(Matcher<String> matcher)
Assert the request URI string with the given matcher.- 参数:
matcher- String matcher for the expected URI- 返回:
- the request matcher
requestTo
public static RequestMatcher requestTo(String expectedUri)
Assert the request URI string.- 参数:
expectedUri- the expected URI- 返回:
- the request matcher
requestTo
public static RequestMatcher requestTo(URI uri)
Expect a request to the given URI.- 参数:
uri- the expected URI- 返回:
- the request matcher
queryParam
@SafeVarargs public static RequestMatcher queryParam(String name, Matcher<? super String>... matchers)
Assert request query parameter values with the given Hamcrest matcher.
queryParam
public static RequestMatcher queryParam(String name, String... expectedValues)
Assert request query parameter values.
header
@SafeVarargs public static RequestMatcher header(String name, Matcher<? super String>... matchers)
Assert request header values with the given Hamcrest matcher.
header
public static RequestMatcher header(String name, String... expectedValues)
Assert request header values.
content
public static ContentRequestMatchers content()
Access to request body matchers.
jsonPath
public static JsonPathRequestMatchers jsonPath(String expression, Object... args)
Access to request body matchers using a JsonPath expression to inspect a specific subset of the body. The JSON path expression can be a parameterized string using formatting specifiers as defined inString.format(String, Object...).- 参数:
expression- the JSON path optionally parameterized with argumentsargs- arguments to parameterize the JSON path expression with
jsonPath
public static <T> RequestMatcher jsonPath(String expression, Matcher<T> matcher)
Access to request body matchers using a JsonPath expression to inspect a specific subset of the body and a Hamcrest match for asserting the value found at the JSON path.- 参数:
expression- the JSON path expressionmatcher- a matcher for the value expected at the JSON path
xpath
public static XpathRequestMatchers xpath(String expression, Object... args) throws XPathExpressionException
Access to request body matchers using an XPath to inspect a specific subset of the body. The XPath expression can be a parameterized string using formatting specifiers as defined inString.format(String, Object...).- 参数:
expression- the XPath optionally parameterized with argumentsargs- arguments to parameterize the XPath expression with- 抛出:
XPathExpressionException
xpath
public static XpathRequestMatchers xpath(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
Access to response body matchers using an XPath to inspect a specific subset of the body. The XPath expression can be a parameterized string using formatting specifiers as defined inString.format(String, Object...).- 参数:
expression- the XPath optionally parameterized with argumentsnamespaces- namespaces referenced in the XPath expressionargs- arguments to parameterize the XPath expression with- 抛出:
XPathExpressionException