Class HeaderResultMatchers
- java.lang.Object
- org.springframework.test.web.servlet.result.HeaderResultMatchers
public class HeaderResultMatchers extends Object
Factory for response header assertions.An instance of this class is available via
MockMvcResultMatchers.header()
.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen, Brian Clozel
Constructor Summary
Constructors Modifier Constructor Description protected
HeaderResultMatchers()
Protected constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultMatcher
dateValue(String name, long value)
Assert the primary value of the named response header parsed into a date using the preferred date format described in RFC 7231.ResultMatcher
doesNotExist(String name)
Assert that the named response header does not exist.ResultMatcher
exists(String name)
Assert that the named response header exists.ResultMatcher
longValue(String name, long value)
Assert the primary value of the named response header as along
.ResultMatcher
string(String name, String value)
Assert the primary value of the response header as a String value.ResultMatcher
string(String name, Matcher<? super String> matcher)
Assert the primary value of the response header with the given Hamcrest StringMatcher
.ResultMatcher
stringValues(String name, String... values)
Assert the values of the response header as String values.ResultMatcher
stringValues(String name, Matcher<Iterable<String>> matcher)
Assert the values of the response header with the given Hamcrest IterableMatcher
.
Constructor Detail
HeaderResultMatchers
protected HeaderResultMatchers()
Protected constructor. SeeMockMvcResultMatchers.header()
.
Method Detail
string
public ResultMatcher string(String name, Matcher<? super String> matcher)
Assert the primary value of the response header with the given Hamcrest StringMatcher
.
stringValues
public ResultMatcher stringValues(String name, Matcher<Iterable<String>> matcher)
Assert the values of the response header with the given Hamcrest IterableMatcher
.- Since:
- 4.3
string
public ResultMatcher string(String name, String value)
Assert the primary value of the response header as a String value.
stringValues
public ResultMatcher stringValues(String name, String... values)
Assert the values of the response header as String values.- Since:
- 4.3
exists
public ResultMatcher exists(String name)
Assert that the named response header exists.- Since:
- 5.0.3
doesNotExist
public ResultMatcher doesNotExist(String name)
Assert that the named response header does not exist.- Since:
- 4.0
longValue
public ResultMatcher longValue(String name, long value)
Assert the primary value of the named response header as along
.The
ResultMatcher
returned by this method throws anAssertionError
if the response does not contain the specified header, or if the suppliedvalue
does not match the primary value.
dateValue
public ResultMatcher dateValue(String name, long value)
Assert the primary value of the named response header parsed into a date using the preferred date format described in RFC 7231.The
ResultMatcher
returned by this method throws anAssertionError
if the response does not contain the specified header, or if the suppliedvalue
does not match the primary value.- Since:
- 4.2
- See Also:
- Section 7.1.1.1 of RFC 7231