From 865cecc01a41076b69cbc0069a953f78e00f941d Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Sat, 9 Mar 2024 16:28:34 +0100 Subject: [PATCH] Update Java dependencies: Selenium, GitLab API, Netty, parent POM (#1499) * Update dependency gradle to v8.6 * Update dependency io.netty:netty-bom to v4.1.107.Final * Update dependency org.gitlab4j:gitlab4j-api to v5.5.0 * Update Selenium to v4.18.1 * Update dependency org.jenkins-ci:jenkins to v1.111 * Update Java dependencies --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pom.xml | 16 ++++++---- .../test/acceptance/FallbackConfig.java | 12 ++++---- .../ConfigFileProvider.java | 2 +- .../ssh_credentials/SshCredentialDialog.java | 2 +- .../acceptance/po/ConfigurablePageObject.java | 2 +- .../test/acceptance/po/JobsMixIn.java | 2 +- .../test/acceptance/po/SlavesMixIn.java | 2 +- .../test/acceptance/selenium/Scroller.java | 30 +++++++++++-------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../artifactory_plugin/quickstart/gradlew.bat | 20 ++++++------- 10 files changed, 51 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index bfcc663b79..d586a1632e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci jenkins - 1.108 + 1.111 acceptance-test-harness @@ -31,7 +31,7 @@ 999999-SNAPSHOT true 2.443 - 4.14.0 + 4.18.1 33.0.0-jre 3.8.1 1.6.2 @@ -58,7 +58,7 @@ org.gitlab4j gitlab4j-api - 5.2.0 + 5.5.0 args4j @@ -350,7 +350,7 @@ io.netty netty-bom - 4.1.104.Final + 4.1.107.Final pom import @@ -363,7 +363,13 @@ net.bytebuddy byte-buddy - 1.14.11 + 1.14.12 + + + + org.javassist + javassist + 3.29.0-GA org.apache.commons diff --git a/src/main/java/org/jenkinsci/test/acceptance/FallbackConfig.java b/src/main/java/org/jenkinsci/test/acceptance/FallbackConfig.java index 408688023c..cf9c050386 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/FallbackConfig.java +++ b/src/main/java/org/jenkinsci/test/acceptance/FallbackConfig.java @@ -69,7 +69,7 @@ import org.openqa.selenium.remote.LocalFileDetector; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.safari.SafariDriver; -import org.openqa.selenium.support.events.EventFiringWebDriver; +import org.openqa.selenium.support.events.EventFiringDecorator; import org.openqa.selenium.support.ui.ExpectedConditions; /** @@ -112,9 +112,9 @@ private WebDriver createWebDriver(TestCleaner cleaner, TestName testName) throws GeckoDriverService service = builder.build(); return new FirefoxDriver(service, buildFirefoxOptions(testName)); case "firefox-container": - return createContainerWebDriver(cleaner, "selenium/standalone-firefox:4.14.1", buildFirefoxOptions(testName)); + return createContainerWebDriver(cleaner, "selenium/standalone-firefox:4.18.1", buildFirefoxOptions(testName)); case "chrome-container": - return createContainerWebDriver(cleaner, "selenium/standalone-chrome:4.14.1", new ChromeOptions()); + return createContainerWebDriver(cleaner, "selenium/standalone-chrome:4.18.1", new ChromeOptions()); case "chrome": Map prefs = new HashMap(); prefs.put(LANGUAGE_SELECTOR, "en"); @@ -320,9 +320,9 @@ public WebDriver createWebDriver(TestCleaner cleaner, TestName testName, Elastic if (oldSize.height < 1050 || oldSize.width < 1680) { base.manage().window().setSize(new Dimension(1680, 1050)); } - - final EventFiringWebDriver d = new EventFiringWebDriver(base); - d.register(new Scroller()); + Scroller scroller = new Scroller(base); + final EventFiringDecorator decorator = new EventFiringDecorator<>(scroller); + WebDriver d = decorator.decorate(base); try { d.manage().timeouts().pageLoadTimeout(Duration.ofMillis(time.seconds(PAGE_LOAD_TIMEOUT))); diff --git a/src/main/java/org/jenkinsci/test/acceptance/plugins/config_file_provider/ConfigFileProvider.java b/src/main/java/org/jenkinsci/test/acceptance/plugins/config_file_provider/ConfigFileProvider.java index c2ee0d04d6..8e178a719d 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/plugins/config_file_provider/ConfigFileProvider.java +++ b/src/main/java/org/jenkinsci/test/acceptance/plugins/config_file_provider/ConfigFileProvider.java @@ -58,7 +58,7 @@ protected WebElement find(String caption) { String id = getElement(by.name("config.id")).getAttribute("value"); // clicking the button leads to the load of a new page but it is not a navigation event from the listeners PoV // so we need to disable the sticky elmements again - new Scroller().disableStickyElements(driver); + new Scroller(driver).disableStickyElements(); return newInstance(type, this, id); } } diff --git a/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_credentials/SshCredentialDialog.java b/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_credentials/SshCredentialDialog.java index 92bf9fcb19..63208fa1f9 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_credentials/SshCredentialDialog.java +++ b/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_credentials/SshCredentialDialog.java @@ -59,7 +59,7 @@ private void findAndPerformClick(final By addSubmitButtonLocator) { final Actions builder = new Actions(driver); - new Scroller().scrollIntoView(addSubmitButton, driver); + new Scroller(driver).scrollIntoView(addSubmitButton); addSubmitButton.click(); builder.perform(); } diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/ConfigurablePageObject.java b/src/main/java/org/jenkinsci/test/acceptance/po/ConfigurablePageObject.java index 96d5d3fe8f..c2356f2f1b 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/ConfigurablePageObject.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/ConfigurablePageObject.java @@ -105,7 +105,7 @@ public T configure(final Callable body) { public void configure() { // Automatic disabling of sticky elements doesn't seem to occur after a redirect, // so force it after the configuration page has loaded - new Scroller().disableStickyElements(driver); + new Scroller(driver).disableStickyElements(); if (!driver.getCurrentUrl().equals(getConfigUrl().toExternalForm())) { visit(getConfigUrl()); diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java b/src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java index 8761ec953f..f60f166dc5 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java @@ -45,7 +45,7 @@ public T create(Class type, String name) { // Automatic disabling of sticky elements doesn't seem to occur after a redirect, // so force it after the configuration page has loaded - new Scroller().disableStickyElements(driver); + new Scroller(driver).disableStickyElements(); final T j = get(type, name); diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/SlavesMixIn.java b/src/main/java/org/jenkinsci/test/acceptance/po/SlavesMixIn.java index b616222d35..25b02876da 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/SlavesMixIn.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/SlavesMixIn.java @@ -43,7 +43,7 @@ public S create(Class type, String name) { S s = newInstance(type, jenkins, name); // Automatic disabling of sticky elements doesn't occur after a redirect // so force it after the configuration page has loaded - new Scroller().disableStickyElements(driver); + new Scroller(driver).disableStickyElements(); // reasonable starting point values diff --git a/src/main/java/org/jenkinsci/test/acceptance/selenium/Scroller.java b/src/main/java/org/jenkinsci/test/acceptance/selenium/Scroller.java index 8fb1b1131e..3bfc981029 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/selenium/Scroller.java +++ b/src/main/java/org/jenkinsci/test/acceptance/selenium/Scroller.java @@ -15,7 +15,7 @@ import org.openqa.selenium.UnhandledAlertException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.events.AbstractWebDriverEventListener; +import org.openqa.selenium.support.events.WebDriverListener; /** * Automatically scrolls the element into view. @@ -71,14 +71,16 @@ * @author ogondza * @author Kohsuke Kawaguchi */ -public class Scroller extends AbstractWebDriverEventListener { +public class Scroller implements WebDriverListener { private final Logger LOGGER = Logger.getLogger(Scroller.class.getName()); private final String scrollJs; private final String disableStickyElementsJs; + private final WebDriver driver; - public Scroller() { + public Scroller(WebDriver driver) { + this.driver = driver; try { scrollJs = IOUtils.toString(getClass() .getResourceAsStream("scroller.js"), StandardCharsets.UTF_8); @@ -90,25 +92,29 @@ public Scroller() { } @Override - public void beforeClickOn(WebElement element, WebDriver driver) { - scrollIntoView(element, driver); + public void beforeClick(WebElement element) { + scrollIntoView(element); } @Override - public void beforeChangeValueOf(WebElement element, WebDriver driver, CharSequence[] keysToSend) { - scrollIntoView(element, driver); + public void beforeSendKeys(WebElement element, CharSequence[] keysToSend) { + scrollIntoView(element); } @Override - public void afterNavigateTo(String url, WebDriver driver) { - super.afterNavigateTo(url, driver); + public void beforeClear(WebElement element) { + scrollIntoView(element); + } + + @Override + public void afterGet(WebDriver driver, String url) { try { // if there's an alert we can't run JavaScript // if we catch the exception from running JavaScript then FormValidationTest hangs // not the nicest hack, but it works driver.switchTo().alert(); } catch (NoAlertPresentException e) { - disableStickyElements(driver); + disableStickyElements(); } } @@ -117,7 +123,7 @@ public void afterNavigateTo(String url, WebDriver driver) { * appear on top of other elements, making those elements inaccessible. This method removes the sticky * nature of these elements meaning that they'll no longer appear on top of other elements. */ - public void disableStickyElements(WebDriver driver) { + public void disableStickyElements() { final JavascriptExecutor executor = (JavascriptExecutor) driver; try { executor.executeScript(disableStickyElementsJs); @@ -130,7 +136,7 @@ public void disableStickyElements(WebDriver driver) { * The framework is expected to take care of the correct scrolling. When you are tempted to scroll from PageObjects * or tests, there is likely a framework problem to be fixed. */ - public void scrollIntoView(WebElement e, WebDriver driver) { + public void scrollIntoView(WebElement e) { WebElement element = e; if (Objects.equals(element.getTagName(), "option")) { element = e.findElement(By.xpath("..")); // scroll select into view not option diff --git a/src/test/resources/artifactory_plugin/quickstart/gradle/wrapper/gradle-wrapper.properties b/src/test/resources/artifactory_plugin/quickstart/gradle/wrapper/gradle-wrapper.properties index 1af9e0930b..a80b22ce5c 100644 --- a/src/test/resources/artifactory_plugin/quickstart/gradle/wrapper/gradle-wrapper.properties +++ b/src/test/resources/artifactory_plugin/quickstart/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/test/resources/artifactory_plugin/quickstart/gradlew.bat b/src/test/resources/artifactory_plugin/quickstart/gradlew.bat index 6689b85bee..7101f8e467 100644 --- a/src/test/resources/artifactory_plugin/quickstart/gradlew.bat +++ b/src/test/resources/artifactory_plugin/quickstart/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail