Class HeaderAssertions
java.lang.Object
org.springframework.test.web.reactive.server.HeaderAssertions
Assertions on headers of the response.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel, Sam Brannen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncacheControl
(CacheControl cacheControl) Expect a "Cache-Control" header with the given value.contentDisposition
(ContentDisposition contentDisposition) Expect a "Content-Disposition" header with the given value.contentLength
(long contentLength) Expect a "Content-Length" header with the given value.contentType
(String mediaType) Expect a "Content-Type" header with the given value.contentType
(MediaType mediaType) Expect a "Content-Type" header with the given value.contentTypeCompatibleWith
(String mediaType) Expect a "Content-Type" header compatible with the given value.contentTypeCompatibleWith
(MediaType mediaType) Expect a "Content-Type" header compatible with the given value.doesNotExist
(String name) Expect that the header with the given name is not present.Expect that the header with the given name is present.expires
(long expires) Expect an "Expires" header with the given value.lastModified
(long lastModified) Expect a "Last-Modified" header with the given value.Expect a "Location" header with the given value.Consume the first value of the named response header.Assert the first value of the response header with a HamcrestMatcher
.valueEquals
(String headerName, long value) Expect a header with the given name to match the given long value.valueEquals
(String headerName, String... values) Expect a header with the given name to match the specified values.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.valueMatches
(String name, String pattern) Match the first value of the response header with a regex.Consume all values of the named response header.Assert all values of the response header with a HamcrestMatcher
.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.
-
Method Details
-
valueEquals
Expect a header with the given name to match the specified values. -
valueEquals
Expect a header with the given name to match the given long value.- Since:
- 5.3
-
valueEqualsDate
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.An
AssertionError
is thrown if the response does not contain the specified header, or if the suppliedvalue
does not match the primary header value.- Since:
- 5.3
-
valueMatches
Match the first value of the response header with a regex.- Parameters:
name
- the header namepattern
- the regex pattern
-
valuesMatch
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. Note that the number of patterns must match the number of actual values.- Parameters:
name
- the header namepatterns
- one or more regex patterns, one per expected value- Since:
- 5.3
-
value
Assert the first value of the response header with a HamcrestMatcher
.- Parameters:
name
- the header namematcher
- the matcher to use- Since:
- 5.1
-
values
Assert all values of the response header with a HamcrestMatcher
.- Parameters:
name
- the header namematcher
- the matcher to use- Since:
- 5.3
-
value
Consume the first value of the named response header.- Parameters:
name
- the header nameconsumer
- the consumer to use- Since:
- 5.1
-
values
Consume all values of the named response header.- Parameters:
name
- the header nameconsumer
- the consumer to use- Since:
- 5.3
-
exists
Expect that the header with the given name is present.- Since:
- 5.0.3
-
doesNotExist
Expect that the header with the given name is not present. -
cacheControl
Expect a "Cache-Control" header with the given value. -
contentDisposition
Expect a "Content-Disposition" header with the given value. -
contentLength
Expect a "Content-Length" header with the given value. -
contentType
Expect a "Content-Type" header with the given value. -
contentType
Expect a "Content-Type" header with the given value. -
contentTypeCompatibleWith
Expect a "Content-Type" header compatible with the given value. -
contentTypeCompatibleWith
Expect a "Content-Type" header compatible with the given value. -
expires
Expect an "Expires" header with the given value. -
lastModified
Expect a "Last-Modified" header with the given value. -
location
Expect a "Location" header with the given value.- Since:
- 5.3
-