Skip to content

Commit bc9d5f1

Browse files
committed
Start building against Spring Framework 5.2.2.RELEASE snapshots
See: #1548
1 parent 3a4345e commit bc9d5f1

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

gradle/dependency-management.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dependencyManagement {
22
imports {
33
mavenBom 'io.projectreactor:reactor-bom:Dysprosium-RELEASE'
44
mavenBom 'org.junit:junit-bom:5.5.2'
5-
mavenBom 'org.springframework:spring-framework-bom:5.2.0.RELEASE'
5+
mavenBom 'org.springframework:spring-framework-bom:5.2.2.BUILD-SNAPSHOT'
66
mavenBom 'org.springframework.data:spring-data-releasetrain:Moore-RELEASE'
77
mavenBom 'org.springframework.security:spring-security-bom:5.2.0.RELEASE'
88
mavenBom 'org.testcontainers:testcontainers-bom:1.12.2'

spring-session-core/src/test/java/org/springframework/session/web/http/DefaultCookieSerializerTests.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.time.Clock;
2020
import java.time.Instant;
2121
import java.time.ZoneOffset;
22+
import java.time.ZonedDateTime;
23+
import java.time.format.DateTimeFormatter;
2224
import java.util.Base64;
2325

2426
import javax.servlet.http.Cookie;
@@ -28,7 +30,6 @@
2830
import org.junit.jupiter.params.ParameterizedTest;
2931
import org.junit.jupiter.params.provider.ValueSource;
3032

31-
import org.springframework.http.HttpHeaders;
3233
import org.springframework.mock.web.MockCookie;
3334
import org.springframework.mock.web.MockHttpServletRequest;
3435
import org.springframework.mock.web.MockHttpServletResponse;
@@ -52,7 +53,7 @@ class DefaultCookieSerializerTests {
5253

5354
private MockHttpServletRequest request;
5455

55-
private CookiePreservingMockHttpServletResponse response;
56+
private MockHttpServletResponse response;
5657

5758
private DefaultCookieSerializer serializer;
5859

@@ -62,7 +63,7 @@ class DefaultCookieSerializerTests {
6263
void setup() {
6364
this.cookieName = "SESSION";
6465
this.request = new MockHttpServletRequest();
65-
this.response = new CookiePreservingMockHttpServletResponse();
66+
this.response = new MockHttpServletResponse();
6667
this.sessionId = "sessionId";
6768
this.serializer = new DefaultCookieSerializer();
6869
}
@@ -213,14 +214,14 @@ void writeCookieDomainNamePattern() {
213214
this.request.setServerName(domain);
214215
this.serializer.writeCookieValue(cookieValue(this.sessionId));
215216
assertThat(getCookie().getDomain()).isEqualTo("example.com");
216-
this.response = new CookiePreservingMockHttpServletResponse();
217+
this.response = new MockHttpServletResponse();
217218
}
218219
String[] notMatchingDomains = { "example.com", "localhost", "127.0.0.1" };
219220
for (String domain : notMatchingDomains) {
220221
this.request.setServerName(domain);
221222
this.serializer.writeCookieValue(cookieValue(this.sessionId));
222223
assertThat(getCookie().getDomain()).isNull();
223-
this.response = new CookiePreservingMockHttpServletResponse();
224+
this.response = new MockHttpServletResponse();
224225
}
225226
}
226227

@@ -291,25 +292,31 @@ void writeCookieCookiePathExplicitCookiePath() {
291292
void writeCookieCookieMaxAgeDefault() {
292293
this.serializer.writeCookieValue(cookieValue(this.sessionId));
293294
assertThat(getCookie().getMaxAge()).isEqualTo(-1);
294-
assertThat(this.response.rawCookie).doesNotContain("Expires");
295+
assertThat(getCookie().getExpires()).isNull();
295296
}
296297

297298
@Test
298299
void writeCookieCookieMaxAgeExplicit() {
299300
this.serializer.setClock(Clock.fixed(Instant.parse("2019-10-07T20:10:00Z"), ZoneOffset.UTC));
300301
this.serializer.setCookieMaxAge(100);
301302
this.serializer.writeCookieValue(cookieValue(this.sessionId));
302-
assertThat(getCookie().getMaxAge()).isEqualTo(100);
303-
assertThat(this.response.rawCookie).contains("Expires=Mon, 7 Oct 2019 20:11:40 GMT");
303+
MockCookie cookie = getCookie();
304+
assertThat(cookie.getMaxAge()).isEqualTo(100);
305+
ZonedDateTime expires = cookie.getExpires();
306+
assertThat(expires).isNotNull();
307+
assertThat(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME)).isEqualTo("Mon, 7 Oct 2019 20:11:40 GMT");
304308
}
305309

306310
@Test
307311
void writeCookieCookieMaxAgeExplicitEmptyCookie() {
308312
this.serializer.setClock(Clock.fixed(Instant.parse("2019-10-07T20:10:00Z"), ZoneOffset.UTC));
309313
this.serializer.setCookieMaxAge(100);
310314
this.serializer.writeCookieValue(cookieValue(""));
311-
assertThat(getCookie().getMaxAge()).isEqualTo(0);
312-
assertThat(this.response.rawCookie).contains("Expires=Thu, 1 Jan 1970 00:00:00 GMT");
315+
MockCookie cookie = getCookie();
316+
assertThat(cookie.getMaxAge()).isEqualTo(0);
317+
ZonedDateTime expires = cookie.getExpires();
318+
assertThat(expires).isNotNull();
319+
assertThat(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME)).isEqualTo("Thu, 1 Jan 1970 00:00:00 GMT");
313320
}
314321

315322
@Test
@@ -318,8 +325,11 @@ void writeCookieCookieMaxAgeExplicitCookieValue() {
318325
CookieValue cookieValue = cookieValue(this.sessionId);
319326
cookieValue.setCookieMaxAge(100);
320327
this.serializer.writeCookieValue(cookieValue);
321-
assertThat(getCookie().getMaxAge()).isEqualTo(100);
322-
assertThat(this.response.rawCookie).contains("Expires=Mon, 7 Oct 2019 20:11:40 GMT");
328+
MockCookie cookie = getCookie();
329+
assertThat(cookie.getMaxAge()).isEqualTo(100);
330+
ZonedDateTime expires = cookie.getExpires();
331+
assertThat(expires).isNotNull();
332+
assertThat(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME)).isEqualTo("Mon, 7 Oct 2019 20:11:40 GMT");
323333
}
324334

325335
// --- secure ---
@@ -482,18 +492,4 @@ private CookieValue cookieValue(String cookieValue) {
482492
return new CookieValue(this.request, this.response, cookieValue);
483493
}
484494

485-
private static class CookiePreservingMockHttpServletResponse extends MockHttpServletResponse {
486-
487-
private String rawCookie;
488-
489-
@Override
490-
public void addHeader(String name, String value) {
491-
if (HttpHeaders.SET_COOKIE.equals(name)) {
492-
this.rawCookie = value;
493-
}
494-
super.addHeader(name, value);
495-
}
496-
497-
}
498-
499495
}

0 commit comments

Comments
 (0)