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:
jungh8n
2026-08-28 18:20:04 +02:00
committed by Brian Clozel
parent 491859b5ce
commit 09548c0874
6 changed files with 13 additions and 23 deletions
+3 -3
View File
@@ -123,7 +123,7 @@ dependencies {
api("org.hibernate.orm:hibernate-core:7.4.5.Final")
api("org.hibernate.validator:hibernate-validator:9.1.3.Final")
api("org.hsqldb:hsqldb:2.7.4")
api("org.htmlunit:htmlunit:4.21.0")
api("org.htmlunit:htmlunit:5.4.0")
api("org.javamoney:moneta:1.4.4")
api("org.jboss.logging:jboss-logging:3.6.1.Final")
api("org.jruby:jruby:10.0.2.0")
@@ -134,8 +134,8 @@ dependencies {
api("org.python:jython-standalone:2.7.4")
api("org.quartz-scheduler:quartz:2.3.2")
api("org.reactivestreams:reactive-streams:1.0.4")
api("org.seleniumhq.selenium:htmlunit3-driver:4.41.0")
api("org.seleniumhq.selenium:selenium-java:4.41.0")
api("org.seleniumhq.selenium:htmlunit3-driver:4.47.0")
api("org.seleniumhq.selenium:selenium-java:4.47.0")
api("org.skyscreamer:jsonassert:1.5.3")
api("org.testng:testng:7.12.0")
api("org.webjars:webjars-locator-lite:1.1.0")
@@ -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);
}
@@ -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
@@ -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;
@@ -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;
@@ -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;