11/*
2- * Copyright 2002-2022 the original author or authors.
2+ * Copyright 2002-2023 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -148,11 +148,11 @@ void setSameSiteShouldSetAttribute() {
148148
149149 @ Test
150150 void setExpiresShouldSetAttribute () {
151+ String expiresText = "Tue, 8 Oct 2019 19:50:00 GMT" ;
151152 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 ));
154154
155- assertThat (cookie .getAttribute ("expires" )).isEqualTo ("Tue, 8 Oct 2019 19:50:00 GMT" );
155+ assertThat (cookie .getAttribute ("expires" )).isEqualTo (expiresText );
156156 }
157157
158158 @ Test
@@ -168,11 +168,11 @@ void setSameSiteNullShouldClear() {
168168
169169 @ Test
170170 void setExpiresNullShouldClear () {
171+ ZonedDateTime expiresDateTime = ZonedDateTime .parse ("Tue, 8 Oct 2019 19:50:00 GMT" ,
172+ DateTimeFormatter .RFC_1123_DATE_TIME );
171173 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 );
176176
177177 cookie .setExpires (null );
178178 assertThat (cookie .getExpires ()).isNull ();
@@ -189,16 +189,18 @@ void setAttributeSameSiteShouldSetSameSite() {
189189
190190 @ Test
191191 void setAttributeExpiresShouldSetExpires () {
192+ String expiresText = "Tue, 8 Oct 2019 19:50:00 GMT" ;
192193 MockCookie cookie = new MockCookie ("SESSION" , "123" );
193- cookie .setAttribute ("expires" , "Tue, 8 Oct 2019 19:50:00 GMT" );
194+ cookie .setAttribute ("expires" , expiresText );
194195
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 ));
197198 }
198199
199200 @ Test
200201 void setInvalidAttributeExpiresShouldThrow () {
201202 MockCookie cookie = new MockCookie ("SESSION" , "123" );
202203 assertThatThrownBy (() -> cookie .setAttribute ("expires" , "12345" )).isInstanceOf (DateTimeParseException .class );
203204 }
205+
204206}
0 commit comments