mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Upgrade HtmlUnit and Selenium dependencies
HtmlUnit 5 moved its Cookie type to org.htmlunit.http, so Spring Test's HtmlUnit integration now uses the new API. Constraint: Keep HtmlUnit and htmlunit3-driver versions compatible. Rejected: Upgrade HtmlUnit alone | driver requires HtmlUnit 5.4.0. Confidence: high Scope-risk: narrow Directive: Keep HtmlUnit and the driver version aligned. Tested: JAVA_HOME=/opt/homebrew/opt/openjdk@25 ./gradlew build Not-tested: None Signed-off-by: jungh8n <jh981113@naver.com>
This commit is contained in:
+4
-4
@@ -293,8 +293,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||
}
|
||||
}
|
||||
|
||||
Set<org.htmlunit.util.Cookie> managedCookies = this.webClient.getCookies(this.webRequest.getUrl());
|
||||
for (org.htmlunit.util.Cookie cookie : managedCookies) {
|
||||
Set<org.htmlunit.http.Cookie> managedCookies = this.webClient.getCookies(this.webRequest.getUrl());
|
||||
for (org.htmlunit.http.Cookie cookie : managedCookies) {
|
||||
processCookie(request, cookies, new Cookie(cookie.getName(), cookie.getValue()));
|
||||
}
|
||||
|
||||
@@ -343,8 +343,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||
this.webClient.getCookieManager().removeCookie(createCookie(request, sessionid));
|
||||
}
|
||||
|
||||
private org.htmlunit.util.Cookie createCookie(MockHttpServletRequest request, String sessionid) {
|
||||
return new org.htmlunit.util.Cookie(request.getServerName(), "JSESSIONID", sessionid,
|
||||
private org.htmlunit.http.Cookie createCookie(MockHttpServletRequest request, String sessionid) {
|
||||
return new org.htmlunit.http.Cookie(request.getServerName(), "JSESSIONID", sessionid,
|
||||
request.getContextPath() + "/", null, request.isSecure(), true);
|
||||
}
|
||||
|
||||
|
||||
+3
-13
@@ -21,13 +21,12 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.impl.cookie.BasicClientCookie;
|
||||
import org.htmlunit.CookieManager;
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.WebConnection;
|
||||
import org.htmlunit.WebRequest;
|
||||
import org.htmlunit.WebResponse;
|
||||
import org.htmlunit.util.Cookie;
|
||||
import org.htmlunit.http.Cookie;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
@@ -179,22 +178,13 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static Cookie createCookie(jakarta.servlet.http.Cookie cookie) {
|
||||
Date expires = null;
|
||||
if (cookie.getMaxAge() > -1) {
|
||||
expires = new Date(System.currentTimeMillis() + cookie.getMaxAge() * 1000);
|
||||
}
|
||||
BasicClientCookie result = new BasicClientCookie(cookie.getName(), cookie.getValue());
|
||||
result.setDomain(cookie.getDomain());
|
||||
result.setComment(cookie.getComment());
|
||||
result.setExpiryDate(expires);
|
||||
result.setPath(cookie.getPath());
|
||||
result.setSecure(cookie.getSecure());
|
||||
if (cookie.isHttpOnly()) {
|
||||
result.setAttribute("httponly", "true");
|
||||
}
|
||||
return new Cookie(result);
|
||||
return new Cookie(cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getPath(),
|
||||
expires, cookie.getSecure(), cookie.isHttpOnly());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -885,7 +885,7 @@ class HtmlUnitRequestBuilderTests {
|
||||
|
||||
|
||||
private void assertSingleSessionCookie(String expected) {
|
||||
org.htmlunit.util.Cookie jsessionidCookie = webClient.getCookieManager().getCookie("JSESSIONID");
|
||||
org.htmlunit.http.Cookie jsessionidCookie = webClient.getCookieManager().getCookie("JSESSIONID");
|
||||
if (expected == null || expected.contains("Expires=Thu, 01-Jan-1970 00:00:01 GMT")) {
|
||||
assertThat(jsessionidCookie).isNull();
|
||||
return;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.htmlunit.HttpMethod;
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.WebRequest;
|
||||
import org.htmlunit.WebResponse;
|
||||
import org.htmlunit.util.Cookie;
|
||||
import org.htmlunit.http.Cookie;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
package org.springframework.test.web.servlet.htmlunit.webdriver;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.htmlunit.util.Cookie;
|
||||
import org.htmlunit.http.Cookie;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user