java.lang.Object
io.helidon.common.testing.http.junit5.HttpHeaderMatcher

public final class HttpHeaderMatcher extends Object
Matchers for Headers.
  • Method Details

    • noHeader

      public static org.hamcrest.Matcher<Headers> noHeader(HeaderName name)
      A matcher for an Headers that checks that the header is not present.

      Usage example:

           assertThat(httpHeaders, noHeader(HeaderNames.CONNECTION));
       
      Parameters:
      name - header name
      Returns:
      matcher validating the Headers does not contain the provided header
    • hasHeader

      public static org.hamcrest.Matcher<Headers> hasHeader(HeaderName name)
      A matcher for an Headers that checks that the header is present, ignoring its value.

      Usage example:

           assertThat(httpHeaders, hasHeader(HeaderNames.CONNECTION));
       
      Parameters:
      name - header name
      Returns:
      matcher validating the Headers does contain the provided header regardless of its value(s)
    • hasHeader

      public static org.hamcrest.Matcher<Headers> hasHeader(Header header)
      A matcher for an Headers that checks that the header is present and has the defined value.

      Usage example:

           assertThat(httpHeaders, hasHeader(HeaderValues.CONNECTION_CLOSE));
       
      Parameters:
      header - http header with values
      Returns:
      matcher validating the Headers does contain the provided header
    • hasHeader

      public static org.hamcrest.Matcher<Headers> hasHeader(HeaderName name, String... value)
      A matcher for an Headers that checks that the header is present and has the defined value(s).

      Usage example:

           assertThat(httpHeaders, hasHeader(HeaderValues.REDIRECT, "/location"));
       
      Parameters:
      name - http header name
      value - value(s) of the header
      Returns:
      matcher validating the Headers does contain the provided header
    • hasHeader

      public static org.hamcrest.Matcher<Headers> hasHeader(HeaderName name, org.hamcrest.Matcher<Iterable<? extends String>> valuesMatcher)
      A matcher for an Headers that checks that the header is present and values match the provided matcher.

      Usage example:

           assertThat(httpHeaders, hasHeader(HeaderNames.CONNECTION, contains("close")));
       
      Parameters:
      name - header name
      valuesMatcher - matcher to validate the values are OK
      Returns:
      matcher validating the Headers does contain the expected values
    • hasHeaderValue

      public static org.hamcrest.Matcher<Headers> hasHeaderValue(HeaderName name, org.hamcrest.Matcher<String> valueMatcher)
      A matcher for an Headers that checks that the header is present and its single value matches the provided matcher.

      Usage example:

           assertThat(httpHeaders, hasHeaderValue(HeaderNames.CONNECTION, startsWith("c")));
       
      Parameters:
      name - header name
      valueMatcher - matcher to validate the value is OK
      Returns:
      matcher validating the Headers does contain the expected value