spring-framework / org.springframework.test.web.servlet.result / HeaderResultMatchers

HeaderResultMatchers

open class HeaderResultMatchers

Factory for response header assertions.

An instance of this class is available via MockMvcResultMatchers#header.

Author
Rossen Stoyanchev

Author
Sam Brannen

Author
Brian Clozel

Since
3.2

Functions

dateValue

open fun dateValue(name: String, value: Long): ResultMatcher

Assert the primary value of the named response header as a date String, using the preferred date format described in RFC 7231.

The ResultMatcher returned by this method throws an AssertionError if the response does not contain the specified header, or if the supplied value does not match the primary value.

doesNotExist

open fun doesNotExist(name: String): ResultMatcher

Assert that the named response header does not exist.

longValue

open fun longValue(name: String, value: Long): ResultMatcher

Assert the primary value of the named response header as a long.

The ResultMatcher returned by this method throws an AssertionError if the response does not contain the specified header, or if the supplied value does not match the primary value.

string

open fun string(name: String, matcher: Matcher<in String>): ResultMatcher

Assert the primary value of the response header with the given Hamcrest String Matcher.

open fun string(name: String, value: String): ResultMatcher

Assert the primary value of the response header as a String value.

stringValues

open fun <T : Any> stringValues(name: String, matcher: Matcher<MutableIterable<String>>): ResultMatcher

Assert the values of the response header with the given Hamcrest Iterable Matcher.

open fun stringValues(name: String, vararg values: String): ResultMatcher

Assert the values of the response header as String values.