org.springframework.test.web.reactive.server

Class HeaderAssertions

  • java.lang.Object
    • org.springframework.test.web.reactive.server.HeaderAssertions


  • public class HeaderAssertions
    extends java.lang.Object
    Assertions on headers of the response.
    Since:
    5.0
    Author:
    Rossen Stoyanchev, Brian Clozel, Sam Brannen
    See Also:
    WebTestClient.ResponseSpec.expectHeader()
    • Method Detail

      • valueEquals

        public WebTestClient.ResponseSpec valueEquals(java.lang.String headerName,
                                                      java.lang.String... values)
        Expect a header with the given name to match the specified values.
      • valueMatches

        public WebTestClient.ResponseSpec valueMatches(java.lang.String name,
                                                       java.lang.String pattern)
        Match the primary value of the response header with a regex.
        Parameters:
        name - the header name
        pattern - the regex pattern
      • value

        public WebTestClient.ResponseSpec value(java.lang.String name,
                                                org.hamcrest.Matcher<? super java.lang.String> matcher)
        Assert the primary value of the response header with a Matcher.
        Parameters:
        name - the header name
        matcher - the matcher to sue
        Since:
        5.1
      • value

        public WebTestClient.ResponseSpec value(java.lang.String name,
                                                java.util.function.Consumer<java.lang.String> consumer)
        Assert the primary value of the response header with a Matcher.
        Parameters:
        name - the header name
        consumer - the matcher to sue
        Since:
        5.1
      • exists

        public WebTestClient.ResponseSpec exists(java.lang.String name)
        Expect that the header with the given name is present.
        Since:
        5.0.3
      • doesNotExist

        public WebTestClient.ResponseSpec doesNotExist(java.lang.String name)
        Expect that the header with the given name is not present.
      • contentLength

        public WebTestClient.ResponseSpec contentLength(long contentLength)
        Expect a "Content-Length" header with the given value.
      • contentType

        public WebTestClient.ResponseSpec contentType(java.lang.String mediaType)
        Expect a "Content-Type" header with the given value.
      • contentTypeCompatibleWith

        public WebTestClient.ResponseSpec contentTypeCompatibleWith(MediaType mediaType)
        Expect a "Content-Type" header compatible with the given value.
      • contentTypeCompatibleWith

        public WebTestClient.ResponseSpec contentTypeCompatibleWith(java.lang.String mediaType)
        Expect a "Content-Type" header compatible with the given value.
      • lastModified

        public WebTestClient.ResponseSpec lastModified(long lastModified)
        Expect a "Last-Modified" header with the given value.