Package org.springframework.mock.web
Class MockCookie
java.lang.Object
jakarta.servlet.http.Cookie
org.springframework.mock.web.MockCookie
- All Implemented Interfaces:
- Serializable,- Cloneable
Extension of 
Cookie with extra attributes, as defined in
 RFC 6265.
 As of Spring 6.0, this set of mocks is designed on a Servlet 6.0 baseline.
- Since:
- 5.1
- Author:
- Vedran Pavic, Juergen Hoeller, Sam Brannen
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionMockCookie(String name, String value) Construct a newMockCookiewith the supplied name and value.
- 
Method SummaryModifier and TypeMethodDescriptionGet the "Expires" attribute for this cookie.Get the "SameSite" attribute for this cookie.static MockCookieFactory method that parses the value of the supplied "Set-Cookie" header.voidsetAttribute(String name, String value) voidsetExpires(ZonedDateTime expires) Set the "Expires" attribute for this cookie.voidsetSameSite(String sameSite) Set the "SameSite" attribute for this cookie.toString()Methods inherited from class jakarta.servlet.http.Cookieclone, equals, getAttribute, getAttributes, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, hashCode, isHttpOnly, setComment, setDomain, setHttpOnly, setMaxAge, setPath, setSecure, setValue, setVersion
- 
Constructor Details- 
MockCookieConstruct a newMockCookiewith the supplied name and value.- Parameters:
- name- the name
- value- the value
- See Also:
 
 
- 
- 
Method Details- 
setExpiresSet the "Expires" attribute for this cookie.- Since:
- 5.1.11
 
- 
getExpiresGet the "Expires" attribute for this cookie.- Returns:
- the "Expires" attribute for this cookie, or nullif not set
- Since:
- 5.1.11
 
- 
setSameSiteSet the "SameSite" attribute for this cookie.This limits the scope of the cookie such that it will only be attached to same-site requests if the supplied value is "Strict"or cross-site requests if the supplied value is"Lax".- See Also:
 
- 
getSameSiteGet the "SameSite" attribute for this cookie.- Returns:
- the "SameSite" attribute for this cookie, or nullif not set
 
- 
parseFactory method that parses the value of the supplied "Set-Cookie" header.- Parameters:
- setCookieHeader- the "Set-Cookie" value; never- nullor empty
- Returns:
- the created cookie
 
- 
setAttribute- Overrides:
- setAttributein class- Cookie
 
- 
toString
 
-