Class AbstractCookieAssertions<E,R>

java.lang.Object
org.springframework.test.web.support.AbstractCookieAssertions<E,R>
Type Parameters:
E - the type of the exchange result
R - the type of the response spec
Direct Known Subclasses:
CookieAssertions, CookieAssertions

public abstract class AbstractCookieAssertions<E,R> extends Object
Assertions on cookies of the response.
Since:
7.0
Author:
Rob Worsnop, Rossen Stoyanchev
  • Constructor Details

    • AbstractCookieAssertions

      protected AbstractCookieAssertions(E exchangeResult, R responseSpec)
  • Method Details

    • getExchangeResult

      protected E getExchangeResult()
      Return the exchange result.
    • getResponseCookies

      protected abstract MultiValueMap<String, ResponseCookie> getResponseCookies()
      Subclasses must implement this to provide access to response cookies.
    • assertWithDiagnostics

      protected abstract void assertWithDiagnostics(Runnable assertion)
      Subclasses must implement this to assert with diagnostics.
    • valueEquals

      public R valueEquals(String name, String value)
      Expect a response cookie with the given name to match the specified value.
    • value

      public R value(String name, Matcher<? super String> matcher)
      Assert the value of the response cookie with the given name with a Hamcrest Matcher.
    • value

      public R value(String name, Consumer<String> consumer)
      Consume the value of the response cookie with the given name.
    • exists

      public R exists(String name)
      Expect that the cookie with the given name is present.
    • doesNotExist

      public R doesNotExist(String name)
      Expect that the cookie with the given name is not present.
    • maxAge

      public R maxAge(String name, Duration expected)
      Assert a cookie's "Max-Age" attribute.
    • maxAge

      public R maxAge(String name, Matcher<? super Long> matcher)
      Assert a cookie's "Max-Age" attribute with a Hamcrest Matcher.
    • path

      public R path(String name, String expected)
      Assert a cookie's "Path" attribute.
    • path

      public R path(String name, Matcher<? super String> matcher)
      Assert a cookie's "Path" attribute with a Hamcrest Matcher.
    • domain

      public R domain(String name, String expected)
      Assert a cookie's "Domain" attribute.
    • domain

      public R domain(String name, Matcher<? super String> matcher)
      Assert a cookie's "Domain" attribute with a Hamcrest Matcher.
    • secure

      public R secure(String name, boolean expected)
      Assert a cookie's "Secure" attribute.
    • httpOnly

      public R httpOnly(String name, boolean expected)
      Assert a cookie's "HttpOnly" attribute.
    • partitioned

      public R partitioned(String name, boolean expected)
      Assert a cookie's "Partitioned" attribute.
    • sameSite

      public R sameSite(String name, String expected)
      Assert a cookie's "SameSite" attribute.