Align with Servlet 6.0 and introduce support for Jakarta WebSocket 2.1
Includes corresponding build upgrade to Tomcat 10.1.1 and Undertow 2.3.0 (while retaining runtime compatibility with Tomcat 10.0 and Undertow 2.2) Closes gh-29435 Closes gh-29436
This commit is contained in:
@@ -65,9 +65,10 @@ class MockCookieTests {
|
||||
assertCookie(cookie, "SESSION", "123");
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Test
|
||||
void parseHeaderWithAttributes() {
|
||||
MockCookie cookie = MockCookie.parse("SESSION=123; Comment=Session Cookie; Domain=example.com; Max-Age=60; " +
|
||||
MockCookie cookie = MockCookie.parse("SESSION=123; Domain=example.com; Max-Age=60; " +
|
||||
"Expires=Tue, 8 Oct 2019 19:50:00 GMT; Path=/; Secure; HttpOnly; SameSite=Lax");
|
||||
|
||||
assertCookie(cookie, "SESSION", "123");
|
||||
@@ -79,7 +80,7 @@ class MockCookieTests {
|
||||
assertThat(cookie.getExpires()).isEqualTo(ZonedDateTime.parse("Tue, 8 Oct 2019 19:50:00 GMT",
|
||||
DateTimeFormatter.RFC_1123_DATE_TIME));
|
||||
assertThat(cookie.getSameSite()).isEqualTo("Lax");
|
||||
assertThat(cookie.getComment()).isEqualTo("Session Cookie");
|
||||
assertThat(cookie.getComment()).isNull();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
@@ -421,10 +421,9 @@ class MockHttpServletResponseTests {
|
||||
}
|
||||
|
||||
@Test // SPR-10414
|
||||
@SuppressWarnings("deprecation")
|
||||
void modifyStatusMessageAfterSendError() throws IOException {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Server Error");
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -474,23 +473,6 @@ class MockHttpServletResponseTests {
|
||||
assertThat(header).startsWith("SESSION=123; Path=/; Max-Age=100; Expires=");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3.22
|
||||
*/
|
||||
@Test
|
||||
void setCookieHeaderWithComment() {
|
||||
response.setHeader(SET_COOKIE, "SESSION=123;Comment=Test Comment;Path=/");
|
||||
|
||||
assertThat(response.getHeader(SET_COOKIE)).isEqualTo(("SESSION=123; Path=/; Comment=Test Comment"));
|
||||
|
||||
assertNumCookies(1);
|
||||
assertThat(response.getCookies()[0]).isInstanceOf(MockCookie.class).satisfies(mockCookie -> {
|
||||
assertThat(mockCookie.getName()).isEqualTo("SESSION");
|
||||
assertThat(mockCookie.getPath()).isEqualTo("/");
|
||||
assertThat(mockCookie.getComment()).isEqualTo("Test Comment");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void addCookieHeader() {
|
||||
response.addHeader(SET_COOKIE, "SESSION=123; Path=/; Secure; HttpOnly; SameSite=Lax");
|
||||
@@ -504,26 +486,6 @@ class MockHttpServletResponseTests {
|
||||
assertCookieValues("123", "999");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addCookieHeaderWithComment() {
|
||||
response.addHeader(SET_COOKIE, "SESSION=123; Path=/; Secure; HttpOnly; SameSite=Lax");
|
||||
assertNumCookies(1);
|
||||
assertPrimarySessionCookie("123");
|
||||
|
||||
// Adding a 2nd cookie header should result in 2 cookies.
|
||||
response.addHeader(SET_COOKIE, "SESSION=999; Comment=Test Comment; Path=/; Secure; HttpOnly; SameSite=Lax");
|
||||
assertNumCookies(2);
|
||||
assertPrimarySessionCookie("123");
|
||||
assertThat(response.getCookies()[1]).isInstanceOf(MockCookie.class).satisfies(mockCookie -> {
|
||||
assertThat(mockCookie.getName()).isEqualTo("SESSION");
|
||||
assertThat(mockCookie.getValue()).isEqualTo("999");
|
||||
assertThat(mockCookie.getComment()).isEqualTo("Test Comment");
|
||||
assertThat(mockCookie.getPath()).isEqualTo("/");
|
||||
assertThat(mockCookie.getSecure()).isTrue();
|
||||
assertThat(mockCookie.isHttpOnly()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.1.11
|
||||
*/
|
||||
@@ -605,6 +567,7 @@ class MockHttpServletResponseTests {
|
||||
assertThat(response.getCookies()).extracting(Cookie::getValue).containsExactly(expected);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private void assertPrimarySessionCookie(String expectedValue) {
|
||||
Cookie cookie = this.response.getCookie("SESSION");
|
||||
assertThat(cookie).asInstanceOf(type(MockCookie.class)).satisfies(mockCookie -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,20 +79,6 @@ class MockHttpSessionTests {
|
||||
session::getAttributeNames);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getValueOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
session.getValue("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getValueNamesOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
assertThatIllegalStateException().isThrownBy(
|
||||
session::getValueNames);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setAttributeOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
@@ -100,13 +86,6 @@ class MockHttpSessionTests {
|
||||
session.setAttribute("name", "value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putValueOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
session.putValue("name", "value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeAttributeOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
@@ -114,13 +93,6 @@ class MockHttpSessionTests {
|
||||
session.removeAttribute("name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeValueOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
session.removeValue("name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewOnInvalidatedSession() {
|
||||
session.invalidate();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,17 +144,16 @@ public class PrintingResultHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings("removal")
|
||||
public void printResponse() throws Exception {
|
||||
Cookie enigmaCookie = new Cookie("enigma", "42");
|
||||
enigmaCookie.setComment("This is a comment");
|
||||
enigmaCookie.setHttpOnly(true);
|
||||
enigmaCookie.setMaxAge(1234);
|
||||
enigmaCookie.setDomain(".example.com");
|
||||
enigmaCookie.setPath("/crumbs");
|
||||
enigmaCookie.setSecure(true);
|
||||
|
||||
this.response.setStatus(400, "error");
|
||||
this.response.setStatus(400);
|
||||
this.response.addHeader("header", "headerValue");
|
||||
this.response.setContentType("text/plain");
|
||||
this.response.getWriter().print("content");
|
||||
@@ -197,7 +196,7 @@ public class PrintingResultHandlerTests {
|
||||
assertThat(cookie1.endsWith("]")).isTrue();
|
||||
assertThat(cookie2.startsWith("[" + Cookie.class.getSimpleName())).isTrue();
|
||||
assertThat(cookie2.contains("name = 'enigma', value = '42', " +
|
||||
"comment = 'This is a comment', domain = '.example.com', maxAge = 1234, " +
|
||||
"comment = [null], domain = '.example.com', maxAge = 1234, " +
|
||||
"path = '/crumbs', secure = true, version = 0, httpOnly = true")).isTrue();
|
||||
assertThat(cookie2.endsWith("]")).isTrue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user