Class AbstractHeaderAssertions<E,R> 
java.lang.Object
org.springframework.test.web.support.AbstractHeaderAssertions<E,R> 
- Type Parameters:
- E- the type of the exchange result
- R- the type of the response spec
- Direct Known Subclasses:
- HeaderAssertions, HeaderAssertions
Assertions on headers of the response.
- Since:
- 7.0
- Author:
- Rob Worsnop, Rossen Stoyanchev
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractHeaderAssertions(E exchangeResult, R responseSpec) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidassertWithDiagnostics(Runnable assertion) Subclasses must implement this to assert with diagnostics.cacheControl(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.protected EReturn the exchange result.protected StringgetMessage(String headerName) protected abstract HttpHeadersSubclasses must implement this to provide access to response headers.protected RlastModified(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.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.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.
- 
Constructor Details- 
AbstractHeaderAssertions
 
- 
- 
Method Details- 
getExchangeResultReturn the exchange result.
- 
getResponseSpec
- 
getResponseHeadersSubclasses must implement this to provide access to response headers.
- 
assertWithDiagnosticsSubclasses must implement this to assert with diagnostics.
- 
valueEquals
- 
valueEquals
- 
valueEqualsDateExpect 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 AssertionErroris thrown if the response does not contain the specified header, or if the suppliedvaluedoes not match the primary header value.
- 
valueMatches
- 
valuesMatchMatch 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 name
- patterns- one or more regex patterns, one per expected value
 
- 
value
- 
values
- 
exists
- 
doesNotExist
- 
cacheControlExpect a "Cache-Control" header with the given value.
- 
contentDispositionExpect a "Content-Disposition" header with the given value.
- 
contentLengthExpect a "Content-Length" header with the given value.
- 
contentType
- 
contentType
- 
contentTypeCompatibleWith
- 
contentTypeCompatibleWith
- 
expiresExpect an "Expires" header with the given value.
- 
lastModifiedExpect a "Last-Modified" header with the given value.
- 
location
- 
getMessage
 
-