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 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.
|
RequestMatcher |
XpathRequestMatchers.booleanValue(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(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(String contentType)
Assert the request content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
RequestMatcher |
XpathRequestMatchers.doesNotExist()
Assert that content does not exist at the given XPath.
|
RequestMatcher |
JsonPathRequestMatchers.doesNotExist()
Evaluate the JSON path expression against the request content and
assert that a value does not exist at the given path.
|
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 |
XpathRequestMatchers.exists()
Assert that content exists at the given XPath.
|
RequestMatcher |
JsonPathRequestMatchers.exists()
Evaluate the JSON path expression against the request content and
assert that a non-null value exists at the given path.
|
RequestMatcher |
ContentRequestMatchers.formData(MultiValueMap<String,String> expected)
Parse the body as form data and compare to the given
MultiValueMap . |
RequestMatcher |
ContentRequestMatchers.formDataContains(Map<String,String> expected)
Variant of
ContentRequestMatchers.formData(MultiValueMap) that matches the given subset
of expected form parameters. |
RequestMatcher |
JsonPathRequestMatchers.hasJsonPath()
Evaluate the JSON path expression against the response content
and assert that a value, possibly
null , exists. |
static RequestMatcher |
MockRestRequestMatchers.header(String name,
Matcher<? super String>... matchers)
Assert request header values with the given Hamcrest matcher(s).
|
static RequestMatcher |
MockRestRequestMatchers.header(String name,
String... expectedValues)
Assert request header values.
|
static RequestMatcher |
MockRestRequestMatchers.headerDoesNotExist(String name)
Assert that the given request header does not exist.
|
static RequestMatcher |
MockRestRequestMatchers.headerList(String name,
Matcher<? super List<String>> matcher)
Assert request header values with the given Hamcrest matcher, matching on
the entire
List of 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(String expectedJsonContent)
Parse the expected and actual strings as JSON and assert the two
are "similar" - i.e.
|
RequestMatcher |
ContentRequestMatchers.json(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(String expression,
Matcher<? super 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.multipartData(MultiValueMap<String,?> expectedMap)
Parse the body as multipart data and assert it contains exactly the
values from the given
MultiValueMap . |
RequestMatcher |
ContentRequestMatchers.multipartDataContains(Map<String,?> expectedMap)
Variant of
ContentRequestMatchers.multipartData(MultiValueMap) that does the same but
only for a subset of the actual values. |
RequestMatcher |
XpathRequestMatchers.node(Matcher<? super Node> matcher)
Apply the XPath and assert it with the given
Matcher<Node> . |
RequestMatcher |
ContentRequestMatchers.node(Matcher<? super Node> matcher)
|
RequestMatcher |
XpathRequestMatchers.nodeCount(int expectedCount)
Apply the XPath and assert the number of nodes found.
|
RequestMatcher |
XpathRequestMatchers.nodeCount(Matcher<? super Integer> matcher)
Apply the XPath and assert the number of nodes found with the given
Matcher<Integer> . |
RequestMatcher |
XpathRequestMatchers.number(Double value)
Apply the XPath and assert the number value found.
|
RequestMatcher |
XpathRequestMatchers.number(Matcher<? super Double> matcher)
Apply the XPath and assert the number found with the given matcher.
|
static RequestMatcher |
MockRestRequestMatchers.queryParam(String name,
Matcher<? super String>... matchers)
Assert request query parameter values with the given Hamcrest matcher(s).
|
static RequestMatcher |
MockRestRequestMatchers.queryParam(String name,
String... expectedValues)
Assert request query parameter values.
|
static RequestMatcher |
MockRestRequestMatchers.queryParamList(String name,
Matcher<? super List<String>> matcher)
Assert request query parameter values with the given Hamcrest matcher,
matching on the entire
List of values. |
static RequestMatcher |
MockRestRequestMatchers.requestTo(Matcher<? super String> matcher)
Assert the request URI string with the given Hamcrest matcher.
|
static RequestMatcher |
MockRestRequestMatchers.requestTo(String expectedUri)
Assert the request URI matches the given string.
|
static RequestMatcher |
MockRestRequestMatchers.requestTo(URI uri)
Expect a request to the given URI.
|
static RequestMatcher |
MockRestRequestMatchers.requestToUriTemplate(String expectedUri,
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 Source> matcher)
|
RequestMatcher |
XpathRequestMatchers.string(Matcher<? super String> matcher)
Apply the XPath and assert the String content found with the given matcher.
|
RequestMatcher |
ContentRequestMatchers.string(Matcher<? super String> matcher)
Get the body of the request as a UTF-8 string and apply the given
Matcher . |
RequestMatcher |
XpathRequestMatchers.string(String content)
Apply the XPath and assert the String content found.
|
RequestMatcher |
ContentRequestMatchers.string(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<? super 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<? super T> matcher,
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(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(String expectedXmlContent)
Parse the request body and the given String as XML and assert that the
two are "similar" - i.e.
|