1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -148,11 +148,11 @@ void setSameSiteShouldSetAttribute() {
148
148
149
149
@ Test
150
150
void setExpiresShouldSetAttribute () {
151
+ String expiresText = "Tue, 8 Oct 2019 19:50:00 GMT" ;
151
152
MockCookie cookie = new MockCookie ("SESSION" , "123" );
152
- cookie .setExpires (ZonedDateTime .parse ("Tue, 8 Oct 2019 19:50:00 GMT" ,
153
- DateTimeFormatter .RFC_1123_DATE_TIME ));
153
+ cookie .setExpires (ZonedDateTime .parse (expiresText , DateTimeFormatter .RFC_1123_DATE_TIME ));
154
154
155
- assertThat (cookie .getAttribute ("expires" )).isEqualTo ("Tue, 8 Oct 2019 19:50:00 GMT" );
155
+ assertThat (cookie .getAttribute ("expires" )).isEqualTo (expiresText );
156
156
}
157
157
158
158
@ Test
@@ -168,11 +168,11 @@ void setSameSiteNullShouldClear() {
168
168
169
169
@ Test
170
170
void setExpiresNullShouldClear () {
171
+ ZonedDateTime expiresDateTime = ZonedDateTime .parse ("Tue, 8 Oct 2019 19:50:00 GMT" ,
172
+ DateTimeFormatter .RFC_1123_DATE_TIME );
171
173
MockCookie cookie = new MockCookie ("SESSION" , "123" );
172
- cookie .setExpires (ZonedDateTime .parse ("Tue, 8 Oct 2019 19:50:00 GMT" ,
173
- DateTimeFormatter .RFC_1123_DATE_TIME ));
174
- assertThat (cookie .getExpires ()).isEqualTo (ZonedDateTime .parse ("Tue, 8 Oct 2019 19:50:00 GMT" ,
175
- DateTimeFormatter .RFC_1123_DATE_TIME ));
174
+ cookie .setExpires (expiresDateTime );
175
+ assertThat (cookie .getExpires ()).isEqualTo (expiresDateTime );
176
176
177
177
cookie .setExpires (null );
178
178
assertThat (cookie .getExpires ()).isNull ();
@@ -189,16 +189,18 @@ void setAttributeSameSiteShouldSetSameSite() {
189
189
190
190
@ Test
191
191
void setAttributeExpiresShouldSetExpires () {
192
+ String expiresText = "Tue, 8 Oct 2019 19:50:00 GMT" ;
192
193
MockCookie cookie = new MockCookie ("SESSION" , "123" );
193
- cookie .setAttribute ("expires" , "Tue, 8 Oct 2019 19:50:00 GMT" );
194
+ cookie .setAttribute ("expires" , expiresText );
194
195
195
- assertThat (cookie .getExpires ()).isEqualTo (ZonedDateTime . parse ( "Tue, 8 Oct 2019 19:50:00 GMT" ,
196
- DateTimeFormatter .RFC_1123_DATE_TIME ));
196
+ assertThat (cookie .getExpires ()).isEqualTo (
197
+ ZonedDateTime . parse ( expiresText , DateTimeFormatter .RFC_1123_DATE_TIME ));
197
198
}
198
199
199
200
@ Test
200
201
void setInvalidAttributeExpiresShouldThrow () {
201
202
MockCookie cookie = new MockCookie ("SESSION" , "123" );
202
203
assertThatThrownBy (() -> cookie .setAttribute ("expires" , "12345" )).isInstanceOf (DateTimeParseException .class );
203
204
}
205
+
204
206
}
0 commit comments