public class HeaderAssertions extends Object
WebTestClient.ResponseSpec.expectHeader()
Modifier and Type | Method and Description |
---|---|
WebTestClient.ResponseSpec |
cacheControl(CacheControl cacheControl)
Expect a "Cache-Control" header with the given value.
|
WebTestClient.ResponseSpec |
contentDisposition(ContentDisposition contentDisposition)
Expect a "Content-Disposition" header with the given value.
|
WebTestClient.ResponseSpec |
contentLength(long contentLength)
Expect a "Content-Length" header with the given value.
|
WebTestClient.ResponseSpec |
contentType(MediaType mediaType)
Expect a "Content-Type" header with the given value.
|
WebTestClient.ResponseSpec |
contentType(String mediaType)
Expect a "Content-Type" header with the given value.
|
WebTestClient.ResponseSpec |
contentTypeCompatibleWith(MediaType mediaType)
Expect a "Content-Type" header compatible with the given value.
|
WebTestClient.ResponseSpec |
contentTypeCompatibleWith(String mediaType)
Expect a "Content-Type" header compatible with the given value.
|
WebTestClient.ResponseSpec |
doesNotExist(String name)
Expect that the header with the given name is not present.
|
WebTestClient.ResponseSpec |
exists(String name)
Expect that the header with the given name is present.
|
WebTestClient.ResponseSpec |
expires(long expires)
Expect an "Expires" header with the given value.
|
WebTestClient.ResponseSpec |
lastModified(long lastModified)
Expect a "Last-Modified" header with the given value.
|
WebTestClient.ResponseSpec |
location(String location)
Expect a "Location" header with the given value.
|
WebTestClient.ResponseSpec |
value(String name,
Consumer<String> consumer)
Consume the first value of the named response header.
|
WebTestClient.ResponseSpec |
value(String name,
Matcher<? super String> matcher)
Assert the first value of the response header with a Hamcrest
Matcher . |
WebTestClient.ResponseSpec |
valueEquals(String headerName,
long value)
Expect a header with the given name to match the given long value.
|
WebTestClient.ResponseSpec |
valueEquals(String headerName,
String... values)
Expect a header with the given name to match the specified values.
|
WebTestClient.ResponseSpec |
valueEqualsDate(String headerName,
long value)
Expect a header with the given name to match the specified long value
parsed into a date using the preferred date format described in RFC 7231.
|
WebTestClient.ResponseSpec |
valueMatches(String name,
String pattern)
Match the first value of the response header with a regex.
|
WebTestClient.ResponseSpec |
values(String name,
Consumer<List<String>> consumer)
Consume all values of the named response header.
|
WebTestClient.ResponseSpec |
values(String name,
Matcher<? super Iterable<String>> matcher)
Assert all values of the response header with a Hamcrest
Matcher . |
WebTestClient.ResponseSpec |
valuesMatch(String name,
String... patterns)
Match all values of the response header with the given regex
patterns which are applied to the values of the header in the
same order.
|
public WebTestClient.ResponseSpec valueEquals(String headerName, String... values)
public WebTestClient.ResponseSpec valueEquals(String headerName, long value)
public WebTestClient.ResponseSpec valueEqualsDate(String headerName, long value)
An AssertionError
is thrown if the response does not contain
the specified header, or if the supplied value
does not match the
primary header value.
public WebTestClient.ResponseSpec valueMatches(String name, String pattern)
name
- the header namepattern
- the regex patternpublic WebTestClient.ResponseSpec valuesMatch(String name, String... patterns)
name
- the header namepatterns
- one or more regex patterns, one per expected valuepublic WebTestClient.ResponseSpec value(String name, Matcher<? super String> matcher)
Matcher
.name
- the header namematcher
- the matcher to usepublic WebTestClient.ResponseSpec values(String name, Matcher<? super Iterable<String>> matcher)
Matcher
.name
- the header namematcher
- the matcher to usepublic WebTestClient.ResponseSpec value(String name, Consumer<String> consumer)
name
- the header nameconsumer
- the consumer to usepublic WebTestClient.ResponseSpec values(String name, Consumer<List<String>> consumer)
name
- the header nameconsumer
- the consumer to usepublic WebTestClient.ResponseSpec exists(String name)
public WebTestClient.ResponseSpec doesNotExist(String name)
public WebTestClient.ResponseSpec cacheControl(CacheControl cacheControl)
public WebTestClient.ResponseSpec contentDisposition(ContentDisposition contentDisposition)
public WebTestClient.ResponseSpec contentLength(long contentLength)
public WebTestClient.ResponseSpec contentType(MediaType mediaType)
public WebTestClient.ResponseSpec contentType(String mediaType)
public WebTestClient.ResponseSpec contentTypeCompatibleWith(MediaType mediaType)
public WebTestClient.ResponseSpec contentTypeCompatibleWith(String mediaType)
public WebTestClient.ResponseSpec expires(long expires)
public WebTestClient.ResponseSpec lastModified(long lastModified)
public WebTestClient.ResponseSpec location(String location)