From acb2aec3dd326b10e15f56291d63cde602968f7a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 9 Jul 2021 13:22:34 +0200 Subject: [PATCH] Compatibility with HtmlUnit 2.51 Includes upgrade to Tomcat 9.0.50, Jetty 9.4.43, Jackson 2.12.4. Closes gh-27147 --- build.gradle | 12 ++++++------ .../webdriver/WebConnectionHtmlUnitDriver.java | 17 +++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 15661c02c3c..c5f574277b9 100644 --- a/build.gradle +++ b/build.gradle @@ -27,12 +27,12 @@ configure(allprojects) { project -> dependencyManagement { imports { - mavenBom "com.fasterxml.jackson:jackson-bom:2.12.3" + mavenBom "com.fasterxml.jackson:jackson-bom:2.12.4" mavenBom "io.netty:netty-bom:4.1.65.Final" mavenBom "io.projectreactor:reactor-bom:2020.0.8" mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR10" mavenBom "io.rsocket:rsocket-bom:1.1.1" - mavenBom "org.eclipse.jetty:jetty-bom:9.4.42.v20210604" + mavenBom "org.eclipse.jetty:jetty-bom:9.4.43.v20210629" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.10" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.0" mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.1" @@ -127,14 +127,14 @@ configure(allprojects) { project -> dependency "org.webjars:webjars-locator-core:0.47" dependency "org.webjars:underscorejs:1.8.3" - dependencySet(group: 'org.apache.tomcat', version: '9.0.48') { + dependencySet(group: 'org.apache.tomcat', version: '9.0.50') { entry 'tomcat-util' entry('tomcat-websocket') { exclude group: "org.apache.tomcat", name: "tomcat-websocket-api" exclude group: "org.apache.tomcat", name: "tomcat-servlet-api" } } - dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.48') { + dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.50') { entry 'tomcat-embed-core' entry 'tomcat-embed-websocket' } @@ -204,10 +204,10 @@ configure(allprojects) { project -> } dependency "io.mockk:mockk:1.11.0" - dependency("net.sourceforge.htmlunit:htmlunit:2.50.0") { + dependency("net.sourceforge.htmlunit:htmlunit:2.51.0") { exclude group: "commons-logging", name: "commons-logging" } - dependency("org.seleniumhq.selenium:htmlunit-driver:2.50.0") { + dependency("org.seleniumhq.selenium:htmlunit-driver:2.51.0") { exclude group: "commons-logging", name: "commons-logging" } dependency("org.seleniumhq.selenium:selenium-java:3.141.59") { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriver.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriver.java index 1b491f50bb3..638648d234f 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriver.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 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. @@ -22,7 +22,6 @@ import com.gargoylesoftware.htmlunit.WebConnection; import org.openqa.selenium.Capabilities; import org.openqa.selenium.htmlunit.HtmlUnitDriver; -import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -35,15 +34,12 @@ import org.springframework.util.Assert; * * @author Rob Winch * @author Sam Brannen + * @author Juergen Hoeller * @since 4.2 * @see MockMvcHtmlUnitDriverBuilder */ public class WebConnectionHtmlUnitDriver extends HtmlUnitDriver { - @Nullable - private WebClient webClient; - - public WebConnectionHtmlUnitDriver() { } @@ -72,9 +68,7 @@ public class WebConnectionHtmlUnitDriver extends HtmlUnitDriver { */ @Override protected final WebClient modifyWebClient(WebClient webClient) { - this.webClient = super.modifyWebClient(webClient); - this.webClient = modifyWebClientInternal(this.webClient); - return this.webClient; + return modifyWebClientInternal(super.modifyWebClient(webClient)); } /** @@ -90,13 +84,12 @@ public class WebConnectionHtmlUnitDriver extends HtmlUnitDriver { } /** - * Return the current {@link WebClient}. + * Return the current {@link WebClient} in a public fashion. * @since 4.3 */ @Override public WebClient getWebClient() { - Assert.state(this.webClient != null, "No WebClient set"); - return this.webClient; + return super.getWebClient(); } /**