Package | Description |
---|---|
org.springframework.test.web.client |
Contains client-side REST testing support.
|
org.springframework.test.web.client.match |
Contains built-in
RequestMatcher
implementations. |
Modifier and Type | Interface and Description |
---|---|
interface |
RequestExpectation
An extension of
ResponseActions that also implements
RequestMatcher and ResponseCreator |
Modifier and Type | Class and Description |
---|---|
class |
DefaultRequestExpectation
Default implementation of
RequestExpectation that simply delegates
to the request matchers and the response creator it contains. |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<RequestMatcher> |
DefaultRequestExpectation.getRequestMatchers() |
Modifier and Type | Method and Description |
---|---|
ResponseActions |
DefaultRequestExpectation.andExpect(RequestMatcher requestMatcher) |
ResponseActions |
ResponseActions.andExpect(RequestMatcher requestMatcher)
Add a request expectation.
|
ResponseActions |
MockRestServiceServer.expect(ExpectedCount count,
RequestMatcher matcher)
An alternative to
MockRestServiceServer.expect(RequestMatcher) that also indicates how
many times the request is expected to be executed. |
ResponseActions |
MockRestServiceServer.expect(RequestMatcher matcher)
Set up an expectation for a single HTTP request.
|
ResponseActions |
RequestExpectationManager.expectRequest(ExpectedCount count,
RequestMatcher requestMatcher)
Set up a new request expectation.
|
ResponseActions |
AbstractRequestExpectationManager.expectRequest(ExpectedCount count,
RequestMatcher matcher) |
Constructor and Description |
---|
DefaultRequestExpectation(ExpectedCount expectedCount,
RequestMatcher requestMatcher)
Create a new request expectation that should be called a number of times
as indicated by
RequestCount . |
Modifier and Type | Method and Description |
---|---|
static RequestMatcher |
MockRestRequestMatchers.anything()
Match to any request.
|
<T> RequestMatcher |
XpathRequestMatchers.booleanValue(java.lang.Boolean value)
Apply the XPath and assert the boolean value found.
|
RequestMatcher |
ContentRequestMatchers.bytes(byte[] expectedContent)
Compare the body of the request to the given byte array.
|
RequestMatcher |
ContentRequestMatchers.contentType(MediaType expectedContentType)
Assert the request content type as a
MediaType . |
RequestMatcher |
ContentRequestMatchers.contentType(java.lang.String expectedContentType)
Assert the request content type as a String.
|
RequestMatcher |
ContentRequestMatchers.contentTypeCompatibleWith(MediaType contentType)
Assert the request content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
RequestMatcher |
ContentRequestMatchers.contentTypeCompatibleWith(java.lang.String contentType)
Assert the request content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
RequestMatcher |
JsonPathRequestMatchers.doesNotExist()
Evaluate the JSON path expression against the request content and
assert that a value does not exist at the given path.
|
<T> RequestMatcher |
XpathRequestMatchers.doesNotExist()
Assert that content does not exist at the given XPath.
|
RequestMatcher |
JsonPathRequestMatchers.doesNotHaveJsonPath()
Evaluate the JSON path expression against the supplied
content
and assert that a value, including null values, does not exist
at the given path. |
RequestMatcher |
JsonPathRequestMatchers.exists()
Evaluate the JSON path expression against the request content and
assert that a non-null value exists at the given path.
|
<T> RequestMatcher |
XpathRequestMatchers.exists()
Assert that content exists at the given XPath.
|
RequestMatcher |
ContentRequestMatchers.formData(MultiValueMap<java.lang.String,java.lang.String> expectedContent)
Parse the body as form data and compare to the given
MultiValueMap . |
RequestMatcher |
JsonPathRequestMatchers.hasJsonPath()
Evaluate the JSON path expression against the response content
and assert that a value, possibly
null , exists. |
static RequestMatcher |
MockRestRequestMatchers.header(java.lang.String name,
Matcher<? super java.lang.String>... matchers)
Assert request header values with the given Hamcrest matcher(s).
|
static RequestMatcher |
MockRestRequestMatchers.header(java.lang.String name,
java.lang.String... expectedValues)
Assert request header values.
|
RequestMatcher |
JsonPathRequestMatchers.isArray()
Evaluate the JSON path expression against the request content and
assert that the result is an array.
|
RequestMatcher |
JsonPathRequestMatchers.isBoolean()
Evaluate the JSON path expression against the request content and
assert that the result is a
Boolean . |
RequestMatcher |
JsonPathRequestMatchers.isEmpty()
Evaluate the JSON path expression against the request content and
assert that an empty value exists at the given path.
|
RequestMatcher |
JsonPathRequestMatchers.isMap()
Evaluate the JSON path expression against the request content and
assert that the result is a
Map . |
RequestMatcher |
JsonPathRequestMatchers.isNotEmpty()
Evaluate the JSON path expression against the request content and
assert that a non-empty value exists at the given path.
|
RequestMatcher |
JsonPathRequestMatchers.isNumber()
Evaluate the JSON path expression against the request content and
assert that the result is a
Number . |
RequestMatcher |
JsonPathRequestMatchers.isString()
Evaluate the JSON path expression against the request content and
assert that the result is a
String . |
RequestMatcher |
ContentRequestMatchers.json(java.lang.String expectedJsonContent)
Parse the expected and actual strings as JSON and assert the two
are "similar" - i.e.
|
RequestMatcher |
ContentRequestMatchers.json(java.lang.String expectedJsonContent,
boolean strict)
Parse the request body and the given string as JSON and assert the two
are "similar" - i.e.
|
static <T> RequestMatcher |
MockRestRequestMatchers.jsonPath(java.lang.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 RequestMatcher |
MockRestRequestMatchers.method(HttpMethod method)
Assert the
HttpMethod of the request. |
RequestMatcher |
ContentRequestMatchers.node(Matcher<? super org.w3c.dom.Node> matcher)
Parse the request content as
Node and apply the given Matcher . |
<T> RequestMatcher |
XpathRequestMatchers.node(Matcher<? super org.w3c.dom.Node> matcher)
Apply the XPath and assert it with the given
Matcher<Node> . |
<T> RequestMatcher |
XpathRequestMatchers.nodeCount(int expectedCount)
Apply the XPath and assert the number of nodes found.
|
<T> RequestMatcher |
XpathRequestMatchers.nodeCount(Matcher<java.lang.Integer> matcher)
Apply the XPath and assert the number of nodes found with the given
Matcher<Integer> . |
RequestMatcher |
XpathRequestMatchers.number(java.lang.Double value)
Apply the XPath and assert the number of nodes found.
|
<T> RequestMatcher |
XpathRequestMatchers.number(Matcher<? super java.lang.Double> matcher)
Apply the XPath and assert the number found with the given matcher.
|
static RequestMatcher |
MockRestRequestMatchers.queryParam(java.lang.String name,
Matcher<? super java.lang.String>... matchers)
Assert request query parameter values with the given Hamcrest matcher(s).
|
static RequestMatcher |
MockRestRequestMatchers.queryParam(java.lang.String name,
java.lang.String... expectedValues)
Assert request query parameter values.
|
static RequestMatcher |
MockRestRequestMatchers.requestTo(Matcher<java.lang.String> matcher)
Assert the request URI string with the given Hamcrest matcher.
|
static RequestMatcher |
MockRestRequestMatchers.requestTo(java.lang.String expectedUri)
Assert the request URI matches the given string.
|
static RequestMatcher |
MockRestRequestMatchers.requestTo(java.net.URI uri)
Expect a request to the given URI.
|
static RequestMatcher |
MockRestRequestMatchers.requestToUriTemplate(java.lang.String expectedUri,
java.lang.Object... uriVars)
Variant of
MockRestRequestMatchers.requestTo(URI) that prepares the URI from a URI
template plus optional variables via UriComponentsBuilder
including encoding. |
RequestMatcher |
ContentRequestMatchers.source(Matcher<? super javax.xml.transform.Source> matcher)
Parse the request content as
DOMSource and apply the given Matcher . |
RequestMatcher |
ContentRequestMatchers.string(Matcher<? super java.lang.String> matcher)
Get the body of the request as a UTF-8 string and appply the given
Matcher . |
<T> RequestMatcher |
XpathRequestMatchers.string(Matcher<? super java.lang.String> matcher)
Apply the XPath and assert the String content found with the given matcher.
|
RequestMatcher |
XpathRequestMatchers.string(java.lang.String value)
Apply the XPath and assert the String content found.
|
RequestMatcher |
ContentRequestMatchers.string(java.lang.String expectedContent)
Get the body of the request as a UTF-8 string and compare it to the given String.
|
<T> RequestMatcher |
JsonPathRequestMatchers.value(Matcher<T> matcher)
Evaluate the JSON path expression against the request content and
assert the resulting value with the given Hamcrest
Matcher . |
<T> RequestMatcher |
JsonPathRequestMatchers.value(Matcher<T> matcher,
java.lang.Class<T> targetType)
An overloaded variant of
JsonPathRequestMatchers.value(Matcher) that also accepts a
target type for the resulting value that the matcher can work reliably
against. |
RequestMatcher |
JsonPathRequestMatchers.value(java.lang.Object expectedValue)
Evaluate the JSON path expression against the request content and
assert that the result is equal to the supplied value.
|
RequestMatcher |
ContentRequestMatchers.xml(java.lang.String expectedXmlContent)
Parse the request body and the given String as XML and assert that the
two are "similar" - i.e.
|