From 83f482b1374d8cb68dab51f8acc3c18374cd4990 Mon Sep 17 00:00:00 2001 From: Thomas Heigl Date: Thu, 7 Nov 2024 15:10:12 +0100 Subject: [PATCH 01/15] WICKET-6794 Re-add author tag for original author --- .../main/java/org/apache/wicket/util/encoding/UrlDecoder.java | 1 + .../main/java/org/apache/wicket/util/encoding/UrlEncoder.java | 1 + 2 files changed, 2 insertions(+) diff --git a/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlDecoder.java b/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlDecoder.java index 0cd83300f88..da54b8bc75a 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlDecoder.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlDecoder.java @@ -33,6 +33,7 @@ * The difference is important because a space is encoded as a + in a query string, but this is a * valid value in a path component (and is therefore not decode back to a space). * + * @author Doug Donohoe * @author Thomas Heigl * @see RFC-2396 */ diff --git a/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlEncoder.java b/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlEncoder.java index 299fb8b6933..422ad779741 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlEncoder.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/encoding/UrlEncoder.java @@ -31,6 +31,7 @@ * The difference is important because a space is encoded as a + in a query string, but this is a * valid value in a path component (and is therefore not decode back to a space). * + * @author Doug Donohoe * @author Thomas Heigl * @see RFC-2396 */ From a5e43aeed041e0366d01a1a35aa48ed1bf62a581 Mon Sep 17 00:00:00 2001 From: Andrea Del Bene Date: Sun, 10 Nov 2024 22:08:42 +0100 Subject: [PATCH 02/15] Setting Java 21 as minimum version --- .github/workflows/maven.yml | 1 - pom.xml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index bec22356235..20dc2cf68b5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,6 @@ jobs: strategy: matrix: java: - - '17' - '21' - '23' diff --git a/pom.xml b/pom.xml index f594be5ec0c..e52592614bc 100644 --- a/pom.xml +++ b/pom.xml @@ -136,8 +136,8 @@ true true - 17 - 17 + 21 + 21 9.7.1 From 22605abb37cf9ba1612de52d9b718ba9f6796d95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:11:23 +0200 Subject: [PATCH 03/15] Bump org.openrewrite.recipe:rewrite-migrate-java from 2.28.0 to 2.29.0 (#1035) Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 2.28.0 to 2.29.0. - [Release notes](https://github.com/openrewrite/rewrite-migrate-java/releases) - [Commits](https://github.com/openrewrite/rewrite-migrate-java/compare/v2.28.0...v2.29.0) --- updated-dependencies: - dependency-name: org.openrewrite.recipe:rewrite-migrate-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- wicket-migration/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wicket-migration/pom.xml b/wicket-migration/pom.xml index 0203692f99a..ed190107142 100644 --- a/wicket-migration/pom.xml +++ b/wicket-migration/pom.xml @@ -38,7 +38,7 @@ org.openrewrite.recipe rewrite-migrate-java - 2.28.0 + 2.29.0 org.openrewrite.recipe From ba56b0aa7b49e2bf05883886b9783c29b9cc70fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:11:31 +0200 Subject: [PATCH 04/15] Bump net.bytebuddy:byte-buddy from 1.15.9 to 1.15.10 (#1032) Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.15.9 to 1.15.10. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.15.9...byte-buddy-1.15.10) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e52592614bc..34e31cfaefa 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ 1.9.22.1 3.26.3 1.79 - 1.15.9 + 1.15.10 4.2.0 4.4 2.0.0-M2 From 9db409d832b62a1572db72cf3063ff82093afade Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:40:42 +0200 Subject: [PATCH 05/15] Bump io.micrometer:micrometer-core from 1.13.6 to 1.14.1 (#1037) Bumps [io.micrometer:micrometer-core](https://github.com/micrometer-metrics/micrometer) from 1.13.6 to 1.14.1. - [Release notes](https://github.com/micrometer-metrics/micrometer/releases) - [Commits](https://github.com/micrometer-metrics/micrometer/compare/v1.13.6...v1.14.1) --- updated-dependencies: - dependency-name: io.micrometer:micrometer-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- wicket-migration/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wicket-migration/pom.xml b/wicket-migration/pom.xml index ed190107142..e3c366c5fa9 100644 --- a/wicket-migration/pom.xml +++ b/wicket-migration/pom.xml @@ -59,7 +59,7 @@ io.micrometer micrometer-core - 1.13.6 + 1.14.1 test From e8d583ab2ab663ff149cfe0da89db4c4fac27ab8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:50:28 +0200 Subject: [PATCH 06/15] Bump spring.version from 6.1.14 to 6.2.0 (#1036) Bumps `spring.version` from 6.1.14 to 6.2.0. Updates `org.springframework:spring-context` from 6.1.14 to 6.2.0 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.1.14...v6.2.0) Updates `org.springframework:spring-core` from 6.1.14 to 6.2.0 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.1.14...v6.2.0) Updates `org.springframework:spring-web` from 6.1.14 to 6.2.0 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.1.14...v6.2.0) Updates `org.springframework:spring-test` from 6.1.14 to 6.2.0 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.1.14...v6.2.0) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springframework:spring-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springframework:spring-web dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34e31cfaefa..6eb2ebbf95e 100644 --- a/pom.xml +++ b/pom.xml @@ -178,7 +178,7 @@ 3.4 1.0.13 2.0.16 - 6.1.14 + 6.2.0 3.5.3 4.0.3.Final 2.4.1 From 219d45ccb3f9a9069295eb53da9d9a7141fd225c Mon Sep 17 00:00:00 2001 From: Erik Strid Date: Tue, 19 Nov 2024 10:09:16 +0100 Subject: [PATCH 07/15] WICKET-7131 Improved accessibility and screen reader support (#1034) * Improved accessability and screen reader support * Ensure that the input field exists before trying to change its attributes * Fix code style issues --------- Co-authored-by: Erik Strid (cherry picked from commit b25c8311b95e46b46f8b23134b68adc3a4f2e543) --- .../html/autocomplete/wicket-autocomplete.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js index 10fe31f0338..70415e395e1 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js @@ -136,6 +136,7 @@ showAutoComplete(); } render(true, false); + jqEvent.preventDefault(); } break; @@ -153,6 +154,7 @@ render(true, false); showAutoComplete(); } + jqEvent.preventDefault(); } break; @@ -243,7 +245,7 @@ { // Remove the autocompletion menu if still present from // a previous call. This is required to properly register - // the mouse event handler again + // the mouse event handler again var choiceDiv=document.getElementById(getMenuId()); if (choiceDiv !== null) { choiceDiv.parentNode.parentNode.removeChild(choiceDiv.parentNode); @@ -325,7 +327,6 @@ container.appendChild(choiceDiv); choiceDiv.id=getMenuId(); choiceDiv.className = "wicket-aa"; - choiceDiv.ariaLive = "polite"; } @@ -456,7 +457,10 @@ hideAutoCompleteTimer = undefined; var input = Wicket.$(ajaxAttributes.c); - $(input).attr("aria-expanded", "false"); + if (input) { + input.setAttribute("aria-expanded", "false"); + input.removeAttribute("aria-activedescendant"); + } visible = 0; setSelected(-1); @@ -628,6 +632,7 @@ selChSinceLastRender = true; // selected item will not have selected style until rendrered } element.innerHTML=resp; + element.firstChild.role = "listbox"; var selectableElements = getSelectableElements(); if (selectableElements) { elementCount=selectableElements.length; @@ -675,6 +680,11 @@ node.onclick = clickFunc; node.onmouseover = mouseOverFunc; node.onmousedown = mouseDownFunc; + node.role = "option"; + node.id = getMenuId() + '-item-' + i; + node.setAttribute("tabindex", -1); + node.setAttribute("aria-posinset", i + 1); + node.setAttribute("aria-setsize", elementCount); } } else { elementCount=0; @@ -770,6 +780,8 @@ var node=getSelectableElement(0); var re = /\bselected\b/gi; var sizeAffected = false; + var input=Wicket.$(ajaxAttributes.c); + for(var i=0;i Date: Tue, 19 Nov 2024 10:14:17 +0100 Subject: [PATCH 08/15] Fix tab glitch when tabing from and to an autocomplete field, which resulted in a dropdown that didn't open on first character when returning to the field (#1039) Co-authored-by: Erik Strid (cherry picked from commit e7d049b6df62e51e979beaa2982253c3d3f07daa) --- .../ajax/markup/html/autocomplete/wicket-autocomplete.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js index 70415e395e1..be20fc16525 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js @@ -102,7 +102,11 @@ //workaround for IE. Clicks on scrollbar trigger //'blur' event on input field. (See https://issues.apache.org/jira/browse/WICKET-5882) if (menuId !== document.activeElement.id && (menuId + "-container") !== document.activeElement.id) { - hideAutoCompleteTimer = window.setTimeout(hideAutoComplete, 500); + hideAutoCompleteTimer = window.setTimeout(function() { + hideAutoComplete(); + isTriggeredChange = false; + triggerChangeOnHide = false; + }, 500); } else { jQuery(this).trigger("focus"); } From b3a7d62f8c11237dc3a76e6561e2ea6ce2ad3ecb Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Wed, 6 Nov 2024 18:31:41 -0300 Subject: [PATCH 09/15] WICKET-3899 nested form processing test - removing traversal signaling dead code - fix form validator when dependent components aren't enabled or form participants - internalMarkFormComponentsValid in postorder - updateNestedFormComponentModels in postorder - internalOnValidateModelObjects in porstorder --- .../markup/html/form/FormVisitTest.java | 564 ++++++++++++++++++ .../apache/wicket/markup/html/form/Form.java | 214 +++---- .../markup/html/form/FormComponent.java | 29 + 3 files changed, 677 insertions(+), 130 deletions(-) create mode 100644 wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java new file mode 100644 index 00000000000..41485523b59 --- /dev/null +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java @@ -0,0 +1,564 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form; + +import org.apache.wicket.Component; +import org.apache.wicket.MarkupContainer; +import org.apache.wicket.markup.IMarkupResourceStreamProvider; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.form.validation.IFormValidator; +import org.apache.wicket.model.Model; +import org.apache.wicket.util.resource.IResourceStream; +import org.apache.wicket.util.resource.StringResourceStream; +import org.apache.wicket.util.tester.WicketTestCase; +import org.apache.wicket.util.visit.IVisit; +import org.apache.wicket.util.visit.IVisitFilter; +import org.apache.wicket.util.visit.IVisitor; +import org.apache.wicket.util.visit.Visits; +import org.apache.wicket.validation.INullAcceptingValidator; +import org.apache.wicket.validation.IValidatable; +import org.apache.wicket.validation.IValidator; +import org.apache.wicket.validation.ValidationError; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * WICKET-3899 + * + * @author Pedro Santos + */ +public class FormVisitTest extends WicketTestCase +{ + TestFormPage page; + FormValidator formValidator = new FormValidator(); + AlwaysFail alwaysFail = new AlwaysFail(); + static int sequence; + + @BeforeEach + public void initialize() + { + page = new TestFormPage(); + tester.startPage(page); + } + + @Test + public void processForms() + { + page.outerForm.add(formValidator); + tester.newFormTester("outerForm").submit(); + + assertTrue(page.outerForm.onValidateCalled); + assertTrue(page.outerForm.onSubmitCalled); + assertTrue(page.outerForm.isSubmittedFlagged); + assertTrue(page.outerForm.onValidateModelObjectsCalled); + assertTrue(page.outerField.onValidCalled); + assertTrue(page.outerField.updateModelCalled); + assertTrue(formValidator.validatedCalled); + assertTrue(page.innerForm.onValidateCalled); + assertTrue(page.innerForm.onSubmitCalled); + assertTrue(page.innerForm.isSubmittedFlagged); + assertTrue(page.innerForm.onValidateModelObjectsCalled); + assertTrue(page.innerField.onValidCalled); + assertTrue(page.innerField.updateModelCalled); + } + + @Test + public void processOuterFormOnly() + { + page.outerForm.add(formValidator); + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertTrue(page.outerForm.onValidateCalled); + assertTrue(page.outerForm.onSubmitCalled); + assertTrue(page.outerForm.isSubmittedFlagged); + assertTrue(page.outerForm.onValidateModelObjectsCalled); + assertTrue(page.outerField.onValidCalled); + assertTrue(page.outerField.updateModelCalled); + assertTrue(formValidator.validatedCalled); + assertFalse(page.innerForm.onValidateCalled); + assertFalse(page.innerForm.onSubmitCalled); + assertFalse(page.innerForm.isSubmittedFlagged); + assertFalse(page.innerForm.onValidateModelObjectsCalled); + assertFalse(page.innerField.onValidCalled); + assertFalse(page.innerField.updateModelCalled); + } + + @Test + @Disabled + public void processInnerFormOnly() + { + page.outerForm.add(formValidator); + tester.newFormTester("outerForm:outerContainer:innerForm").submit("innerContainer:innerFormSubmitButton"); + + assertFalse(page.outerForm.onValidateCalled); + assertFalse(page.outerForm.onSubmitCalled); + assertFalse(page.outerForm.isSubmittedFlagged); + assertFalse(page.outerForm.onValidateModelObjectsCalled); + assertFalse(page.outerField.onValidCalled); + assertFalse(page.outerField.updateModelCalled); + assertFalse(formValidator.validatedCalled); + assertTrue(page.innerForm.onValidateCalled); + assertTrue(page.innerForm.onSubmitCalled); + assertTrue(page.innerForm.isSubmittedFlagged); + assertTrue(page.innerForm.onValidateModelObjectsCalled); + assertTrue(page.innerField.onValidCalled); + assertTrue(page.innerField.updateModelCalled); + } + + @Test + public void validateInnerForm() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerForm.onValidateCalled); + } + + @Test + public void dontValidateInnerForm() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + assertFalse(page.innerForm.onValidateCalled); + } + + @Test + public void callInnerFormOnError() + { + page.innerField.add(alwaysFail); + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerForm.onErrorCalled); + } + + @Test + public void dontCallInnerFormOnErrorIfNotProcessChildren() + { + page.innerField.add(alwaysFail); + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerForm.onErrorCalled); + } + + @Test + public void dontCallInnerFormOnErrorIfNotEnabled() + { + page.innerField.add(alwaysFail); + page.innerForm.setEnabled(false); + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerForm.onErrorCalled); + } + + @Test + public void dontCallOuterFormOnErrorTwice() + { + page.outerField.add(alwaysFail); + tester.newFormTester("outerForm").submit(); + + assertEquals(1, page.outerForm.numberOfOnErrorCalls); + } + + @Test + public void submitInnerForm() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerForm.onSubmitCalled); + } + + @Test + public void dontSubmitInnerForm() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerForm.onSubmitCalled); + } + + @Test + public void setInnerFormSubmittedFlag() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerForm.isSubmittedFlagged); + } + + @Test + public void dontSetInnerFormSubmittedFlag() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerForm.isSubmittedFlagged); + } + + @Test + public void validateInnerFormField() + { + page.innerField.add(alwaysFail); + tester.newFormTester("outerForm").submit(); + + assertTrue(alwaysFail.validatedCalled); + } + + @Test + public void dontValidateInnerFormFieldIfNotProcessChildren() + { + page.innerField.add(alwaysFail); + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(alwaysFail.validatedCalled); + } + + @Test + public void dontValidateInnerFormFieldIfNotEnabled() + { + page.innerField.add(alwaysFail); + page.innerForm.setEnabled(false); + tester.newFormTester("outerForm").submit(); + + assertFalse(alwaysFail.validatedCalled); + } + + @Test + public void validateFormValidator() + { + page.innerForm.add(formValidator); + tester.newFormTester("outerForm").submit(); + + assertTrue(formValidator.validatedCalled); + } + + @Test + public void dontValidateFormValidatorIfFormNotEnabled() + { + page.innerForm.add(formValidator); + page.innerForm.setEnabled(false); + tester.newFormTester("outerForm").submit(); + + assertFalse(formValidator.validatedCalled); + } + + @Test + public void dontValidateFormValidatorIfFormNotProcessed() + { + page.innerForm.add(formValidator); + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(formValidator.validatedCalled); + } + + @Test + public void dontValidateFormValidatorIfDependentNotEnabled() + { + page.innerForm.add(formValidator.setDependency(page.innerField)); + page.innerContainer.setEnabled(false); + tester.newFormTester("outerForm").submit(); + + assertFalse(formValidator.validatedCalled); + } + + @Test + public void dontValidateFormValidatorIfDependentNotProcessed() + { + page.outerForm.add(formValidator.setDependency(page.innerField)); + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(formValidator.validatedCalled); + } + + @Test + public void validateFormValidatorIfDependentIsParticipant() + { + page.outerForm.add(formValidator.setDependency(page.innerField)); + // currently this flag affects just how form components are + // visited inside their form, the test just reflects this expectation + page.outerContainer.processChildren = false; + tester.newFormTester("outerForm").submit(); + + assertTrue(formValidator.validatedCalled); + } + + @Test + public void dontValidateFormValidatorIfDependentNorParticipant() + { + page.outerForm.add(formValidator.setDependency(page.innerField)); + page.innerContainer.processChildren = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(formValidator.validatedCalled); + } + + @Test + public void validateInnerFormComponent() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerField.onValidCalled); + } + + @Test + public void dontValidateInnerFormComponent() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerField.onValidCalled); + } + + @Test + public void validateFormComponentsInPostorder() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerField.onValidCallOrder < page.outerField.onValidCallOrder); + } + + @Test + public void updateInnerFormComponentModel() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerField.updateModelCalled); + } + + @Test + public void dontUpdateInnerFormComponentModel() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerField.updateModelCalled); + } + + @Test + public void updateFormComponentModelsInPostorder() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerField.updateModelOrder < page.outerField.updateModelOrder); + } + + @Test + public void callInnerFormOnValidateModelObjects() + { + tester.newFormTester("outerForm").submit(); + + assertTrue(page.innerForm.onValidateModelObjectsCalled); + } + + @Test + public void dontCallInnerFormOnValidateModelObjects() + { + page.innerForm.wantSubmitOnParentFormSubmit = false; + tester.newFormTester("outerForm").submit(); + + assertFalse(page.innerForm.onValidateModelObjectsCalled); + } + + @Test + public void callFormOnValidateModelObjectsInPostorder() + { + tester.newFormTester("outerForm").submit(); + + assertTrue( + page.innerForm.onValidateModelObjectsCallOrder < page.outerForm.onValidateModelObjectsCallOrder); + } + + public static class TestFormPage extends WebPage implements IMarkupResourceStreamProvider + { + TestForm outerForm; + TestForm innerForm; + TestField outerField; + TestField innerField; + Button innerFormSubmitButton; + Container outerContainer; + Container innerContainer; + + public TestFormPage() + { + add(outerForm = new TestForm("outerForm")); + outerForm.add(outerContainer = new Container("outerContainer")); + outerContainer.add(outerField = new TestField("outerField")); + outerContainer.add(innerForm = new TestForm("innerForm")); + innerForm.add(innerContainer = new Container("innerContainer")); + innerContainer.add(innerField = new TestField("innerField")); + innerContainer.add(innerFormSubmitButton = new Button("innerFormSubmitButton")); + } + + public IResourceStream getMarkupResourceStream(MarkupContainer container, + Class containerClass) + { + return new StringResourceStream("" // + + "" // + + "
" // + + "
" // + + " " // + + " " // + + "
" // + + " " // + + "
" // + + " "// + + ""); + } + } + + static class TestForm extends Form + { + boolean wantSubmitOnParentFormSubmit = true; + boolean onValidateCalled; + boolean onErrorCalled; + boolean onSubmitCalled; + boolean isSubmittedFlagged; + boolean onValidateModelObjectsCalled; + int onValidateModelObjectsCallOrder; + int numberOfOnErrorCalls; + + public TestForm(String id) + { + super(id); + } + + @Override + protected void onSubmit() + { + onSubmitCalled = true; + } + + @Override + protected void onConfigure() + { + super.onConfigure(); + isSubmittedFlagged = isSubmitted(); + } + + @Override + protected boolean wantSubmitOnParentFormSubmit() + { + return wantSubmitOnParentFormSubmit; + } + + @Override + protected void onValidate() + { + onValidateCalled = true; + } + + @Override + protected void onValidateModelObjects() + { + onValidateModelObjectsCalled = true; + onValidateModelObjectsCallOrder = sequence++; + } + + @Override + protected void onError() + { + onErrorCalled = true; + numberOfOnErrorCalls++; + } + } + + static class Container extends WebMarkupContainer implements IFormVisitorParticipant + { + boolean processChildren = true; + + public Container(final String id) + { + super(id); + } + + @Override + public boolean processChildren() + { + return processChildren; + } + } + + static class TestField extends TextField implements IFormModelUpdateListener + { + + boolean onValidCalled; + boolean updateModelCalled; + int updateModelOrder; + int onValidCallOrder; + + public TestField(String id) + { + super(id, Model.of((String)null)); + } + + @Override + protected void onValid() + { + onValidCalled = true; + onValidCallOrder = sequence++; + } + + @Override + public void updateModel() + { + super.updateModel(); + updateModelCalled = true; + updateModelOrder = sequence++; + } + } + + static class FormValidator implements IFormValidator + { + FormComponent[] dependencies; + boolean validatedCalled; + + public FormComponent[] getDependentFormComponents() + { + return dependencies; + } + + public void validate(Form form) + { + validatedCalled = true; + } + + public FormValidator setDependency(FormComponent component) + { + this.dependencies = new FormComponent[] { component }; + return this; + } + } + + static class AlwaysFail implements IValidator, INullAcceptingValidator + { + boolean validatedCalled; + + @Override + public void validate(IValidatable validatable) + { + validatable.error(new ValidationError("foo")); + validatedCalled = true; + } + } + +} diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java index 8e80799c530..c040536fde5 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java @@ -65,10 +65,7 @@ import org.apache.wicket.util.string.Strings; import org.apache.wicket.util.string.interpolator.MapVariableInterpolator; import org.apache.wicket.util.value.LongValue; -import org.apache.wicket.util.visit.ClassVisitFilter; -import org.apache.wicket.util.visit.IVisit; -import org.apache.wicket.util.visit.IVisitor; -import org.apache.wicket.util.visit.Visits; +import org.apache.wicket.util.visit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -166,23 +163,10 @@ public abstract static class ValidationVisitor implements IVisitor formComponent, final IVisit visit) { - - Form form = formComponent.getForm(); - if (!form.isVisibleInHierarchy() || !form.isEnabledInHierarchy()) - { - // do not validate formComponent or any of formComponent's children - visit.dontGoDeeper(); - return; - } - if (formComponent.isVisibleInHierarchy() && formComponent.isEnabledInHierarchy()) { validate(formComponent); } - if (formComponent.processChildren() == false) - { - visit.dontGoDeeper(); - } } /** @@ -1052,22 +1036,16 @@ protected void callOnError(IFormSubmitter submitter) } // invoke Form#onSubmit(..) going from innermost to outermost - Visits.visitPostOrder(processingForm, new IVisitor, Void>() - { - @Override - public void component(Form form, IVisit visit) + visitFormsPostOrder(processingForm, (form, visit) -> { + if (!form.isEnabledInHierarchy() || !form.isVisibleInHierarchy()) { - if (!form.isEnabledInHierarchy() || !form.isVisibleInHierarchy()) - { - visit.dontGoDeeper(); - return; - } - if (form.hasError()) - { - form.onError(); - } + return; + } + if (form.hasError()) + { + form.onError(); } - }, new ClassVisitFilter(Form.class)); + }); } @@ -1077,22 +1055,12 @@ public void component(Form form, IVisit visit) */ private void markFormsSubmitted(IFormSubmitter submitter) { - setFlag(FLAG_SUBMITTED, true); Form formToProcess = findFormToProcess(submitter); - visitChildren(Form.class, new IVisitor() - { - @Override - public void component(final Component component, final IVisit visit) + visitFormsPostOrder(formToProcess, (form, visit) -> { + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { - Form form = (Form)component; - if ((form.wantSubmitOnParentFormSubmit() || form == formToProcess) - && form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) - { - form.setFlag(FLAG_SUBMITTED, true); - return; - } - visit.dontGoDeeper(); + form.setFlag(FLAG_SUBMITTED, true); } }); } @@ -1210,6 +1178,38 @@ public final R visitFormComponentsPostOrder( return FormComponent.visitFormComponentsPostOrder(this, visitor); } + /** + * Visits forms from the @parameter form down in postorder, skipping any branch not flagged as + * form visitor participant + * + * @param formToProcess + * @param visitor + */ + private static void visitFormsPostOrder(Form formToProcess, IVisitor, Void> visitor) + { + Visits.visitPostOrder(formToProcess, visitor, new IVisitFilter() + { + @Override + public boolean visitObject(Object object) + { + if (object instanceof Form form) + { + return form == formToProcess || form.wantSubmitOnParentFormSubmit(); + } + return false; + } + @Override + public boolean visitChildren(Object object) + { + if (object instanceof Form form) + { + return form.wantSubmitOnParentFormSubmit(); + } + return true; + } + }); + } + /** * Find out whether there is any registered error for a form component. * @@ -1324,17 +1324,12 @@ protected void delegateSubmit(IFormSubmitter submittingComponent) // collect all forms innermost to outermost before any hierarchy is changed final List> forms = Generics.newArrayList(3); - Visits.visitPostOrder(processingForm, new IVisitor, Void>() - { - @Override - public void component(Form form, IVisit visit) + visitFormsPostOrder(processingForm, (form, visit) -> { + if (form.isSubmitted()) { - if (form.isSubmitted()) - { - forms.add(form); - } + forms.add(form); } - }, new ClassVisitFilter(Form.class)); + }); // process submitting component (if specified) if (submittingComponent != null) @@ -1563,8 +1558,8 @@ public void component(final FormComponent formComponent, IVisit visit) */ protected final void markFormComponentsValid() { - internalMarkFormComponentsValid(); markNestedFormComponentsValid(); + internalMarkFormComponentsValid(); } /** @@ -1572,19 +1567,14 @@ protected final void markFormComponentsValid() */ private void markNestedFormComponentsValid() { - visitChildren(Form.class, new IVisitor, Void>() - { - @Override - public void component(final Form form, final IVisit visit) + visitFormsPostOrder(this, (form, visit) -> { + if (form == Form.this) { - if (form.isSubmitted()) - { - form.internalMarkFormComponentsValid(); - } - else - { - visit.dontGoDeeper(); - } + return; + } + if (form.isSubmitted()) + { + form.internalMarkFormComponentsValid(); } }); } @@ -1890,8 +1880,8 @@ protected void onSubmit() */ protected final void updateFormComponentModels() { - internalUpdateFormComponentModels(); updateNestedFormComponentModels(); + internalUpdateFormComponentModels(); } /** @@ -1901,19 +1891,14 @@ protected final void updateFormComponentModels() */ private void updateNestedFormComponentModels() { - visitChildren(Form.class, new IVisitor, Void>() - { - @Override - public void component(final Form form, final IVisit visit) + visitFormsPostOrder(this, (form, visit) -> { + if (form == Form.this) { - if (form.isSubmitted()) - { - form.internalUpdateFormComponentModels(); - } - else - { - visit.dontGoDeeper(); - } + return; + } + if (form.isSubmitted()) + { + form.internalUpdateFormComponentModels(); } }); } @@ -1963,22 +1948,17 @@ protected void onValidate() */ private void internalOnValidateModelObjects() { - onValidateModelObjects(); - visitChildren(Form.class, new IVisitor, Void>() - { - @Override - public void component(Form form, IVisit visit) + visitFormsPostOrder(this, (form, visit) -> { + if (form == Form.this) { - if (form.isSubmitted()) - { - form.onValidateModelObjects(); - } - else - { - visit.dontGoDeeper(); - } + return; + } + if (form.isSubmitted()) + { + form.onValidateModelObjects(); } }); + onValidateModelObjects(); } /** @@ -2015,25 +1995,6 @@ public void validate(final FormComponent formComponent) }); } - /** - * Checks if the specified form component visible and is attached to a page - * - * @param fc - * form component - * - * @return true if the form component and all its parents are visible and there component is in - * page's hierarchy - */ - private boolean isFormComponentVisibleInPage(FormComponent fc) - { - if (fc == null) - { - throw new IllegalArgumentException("Argument `fc` cannot be null"); - } - return fc.isVisibleInHierarchy(); - } - - /** * Validates form with the given form validator * @@ -2059,13 +2020,13 @@ protected final void validateFormValidator(final IFormValidator validator) } // check if the dependent component is visible and is attached to // the page - else if (!isFormComponentVisibleInPage(dependent)) + else if (!dependent.isVisibleInHierarchy() || !dependent.isEnabledInHierarchy() || !dependent.isFormParticipant()) { if (log.isWarnEnabled()) { log.warn("IFormValidator in form `" + getPageRelativePath() + - "` depends on a component that has been removed from the page or is no longer visible. " + + "` depends on a component that has been removed from the page or is no longer visible/enabled. " + "Offending component id `" + dependent.getId() + "`."); } validate = false; @@ -2101,26 +2062,19 @@ protected final void validateFormValidators() */ private void validateNestedForms() { - Visits.visitPostOrder(this, new IVisitor, Void>() - { - @Override - public void component(final Form form, final IVisit visit) + visitFormsPostOrder(this, (form, visit) -> { + if (form == Form.this) { - if (form == Form.this) - { - // skip self, only process children - visit.stop(); - return; - } + return; + } - if (form.isSubmitted()) - { - form.validateComponents(); - form.validateFormValidators(); - form.onValidate(); - } + if (form.isSubmitted()) + { + form.validateComponents(); + form.validateFormValidators(); + form.onValidate(); } - }, new ClassVisitFilter(Form.class)); + }); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java index 6eddd4685c5..28331766df4 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java @@ -1602,6 +1602,35 @@ public final void updateAutoLabels(AjaxRequestTarget target) updateAutoLabels(target, false); } + /** + * @return if this form component is visited during the form processing + */ + public boolean isFormParticipant() + { + Component parent = getParent(); + boolean outsideParentForm = false; + while (parent != null) + { + if (parent instanceof IFormVisitorParticipant && !((IFormVisitorParticipant)parent).processChildren() && !outsideParentForm) + { + return false; + } + if (parent instanceof Form form) + { + if (!form.wantSubmitOnParentFormSubmit()) + { + return false; + } + if (form == this.getForm()) + { + outsideParentForm = true; + } + } + parent = parent.getParent(); + } + return true; + } + /** * Update the model of a {@link FormComponent} containing a {@link Collection}. * From f67bccff1a98cc12d910cee4088b81db02c3e559 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Sat, 16 Nov 2024 12:15:18 -0300 Subject: [PATCH 10/15] WICKET-3899 fix submitted flag set for not submitted form --- .../org/apache/wicket/markup/html/form/FormVisitTest.java | 7 ------- .../main/java/org/apache/wicket/markup/html/form/Form.java | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java index 41485523b59..4e2f0396249 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/FormVisitTest.java @@ -16,7 +16,6 @@ */ package org.apache.wicket.markup.html.form; -import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.IMarkupResourceStreamProvider; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -26,16 +25,11 @@ import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.tester.WicketTestCase; -import org.apache.wicket.util.visit.IVisit; -import org.apache.wicket.util.visit.IVisitFilter; -import org.apache.wicket.util.visit.IVisitor; -import org.apache.wicket.util.visit.Visits; import org.apache.wicket.validation.INullAcceptingValidator; import org.apache.wicket.validation.IValidatable; import org.apache.wicket.validation.IValidator; import org.apache.wicket.validation.ValidationError; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -103,7 +97,6 @@ public void processOuterFormOnly() } @Test - @Disabled public void processInnerFormOnly() { page.outerForm.add(formValidator); diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java index c040536fde5..2c40d09a41a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java @@ -741,7 +741,7 @@ public final boolean isSubmitted() @Override public final void onRequest() { - onFormSubmitted(null); + onFormSubmitted(findSubmitter()); } /** From 49cde3e54f5efa882ac796d6f8095a8e33f9bd5f Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Fri, 29 Nov 2024 11:17:08 -0300 Subject: [PATCH 11/15] WICKET-7024 Javadoc --- .../resource/locator/caching/CachingResourceStreamLocator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java index 7cc3a45684f..8dece40fd53 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java @@ -110,8 +110,9 @@ else if (stream instanceof UrlResourceStream) } /** - * @deprecated + * @deprecated use {@link #locate(Class, String, String, String, Locale, String, boolean, boolean)} */ + @Deprecated(since = "9.19.0, 10.3.0") @Override public IResourceStream locate(Class scope, String path, String style, String variation, Locale locale, String extension, boolean strict) From e04d58be646f4e697813d14583a7c9a0988ead83 Mon Sep 17 00:00:00 2001 From: Erik Strid Date: Wed, 20 Nov 2024 06:49:02 +0100 Subject: [PATCH 12/15] WICKET-7133 Ability move focus back to the autocomplete field when selecting an item using the Tab key --- .../AbstractAutoCompleteBehavior.java | 2 + .../autocomplete/AutoCompleteSettings.java | 54 +++++++++++++++++++ .../html/autocomplete/wicket-autocomplete.js | 9 +++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java index 6e9db0f21bb..166b9fea1e0 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java @@ -187,6 +187,8 @@ protected final String constructSettingsJS() { sb.append(",className: '").append(settings.getCssClassName()).append('\''); } + sb.append(",keyTabBehavior: '").append( + settings.getKeyTabBehavior().getValue()).append('\''); sb.append('}'); return sb.toString(); } diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java index c9c43ceac8a..010846686a0 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java @@ -74,6 +74,8 @@ public final class AutoCompleteSettings implements IClusterable private int minInputLength = 1; + private KeyTabBehavior keyTabBehavior = KeyTabBehavior.SELECT_FOCUS_NEXT_ELEMENT; + /** * Indicates whether the first item in the list is automatically selected when the autocomplete * list is shown. @@ -379,4 +381,56 @@ public AutoCompleteSettings setMinInputLength(int minInputLength) this.minInputLength = minInputLength; return this; } + + /** + * Indicates how the Tab key should be handled when having an item in the autocomplete list + * selected, {@link KeyTabBehavior#SELECT_FOCUS_NEXT_ELEMENT} is the default behavior. + * + * @return the behavior that should be used when the Tab key is pressed + */ + public KeyTabBehavior getKeyTabBehavior() + { + return keyTabBehavior; + } + + /** + * Set how the Tab key should be handled when having an item in the autocomplete list selected. + * + * @param keyTabBehavior the behavior that should be used when the Tab key is pressed, + * {@link KeyTabBehavior#SELECT_FOCUS_NEXT_ELEMENT} is the default behavior + * @return this {@link AutoCompleteSettings} + */ + public AutoCompleteSettings setKeyTabBehavior(KeyTabBehavior keyTabBehavior) + { + this.keyTabBehavior = keyTabBehavior; + return this; + } + + /** + * A behavior that can be used to control how the Tab key should be handled when having an item + * in the autocomplete list is marked. + */ + public enum KeyTabBehavior + { + /** + * Select the currently marked item and move the focus to the next focusable element. + */ + SELECT_FOCUS_NEXT_ELEMENT("selectFocusNextElement"), + /** + * Select the currently marked item and move the focus to the auto complete input field. + */ + SELECT_FOCUS_INPUT("selectFocusAutocompleteInput"); + + private final String value; + + KeyTabBehavior(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + } } diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js index be20fc16525..eb3afea13dd 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js @@ -126,7 +126,8 @@ }); Wicket.Event.add(obj, 'keydown', function (jqEvent) { - switch(Wicket.Event.keyCode(jqEvent)){ + var keyCode = Wicket.Event.keyCode(jqEvent); + switch (keyCode) { case KEY_UP: if (elementCount > 0) { if (selected>-1) { @@ -183,6 +184,12 @@ hideAutoComplete(); + if (cfg.keyTabBehavior === 'selectFocusAutocompleteInput' && keyCode === KEY_TAB) { + // prevent moving focus to the next component if an item in the dropdown is selected + // using the Tab key + jqEvent.preventDefault(); + } + ignoreKeyEnter = true; } else if (Wicket.AutoCompleteSettings.enterHidesWithNoSelection) { hideAutoComplete(); From da01909263cc6b48d7e082ac2fc4bcd0dda75e8a Mon Sep 17 00:00:00 2001 From: Peter Major Date: Mon, 2 Dec 2024 20:41:48 +0000 Subject: [PATCH 13/15] WICKET-7135 Work on deprecation warnings (#1049) * Migrate new Locale constructor invocations to Locale.of calls * Migrate new URL constructor invocations to URI#toURL * Migrate deprecated API calls to their replacements --- .../wicket/threadtest/apps/app1/Home.java | 6 ++-- .../java/org/apache/wicket/LocalizerTest.java | 2 +- .../apache/wicket/PageMarkupLoadingTest.java | 6 ++-- .../AbstractResourceReferenceMapperTest.java | 4 +-- .../BasicResourceReferenceMapperTest.java | 6 ++-- .../PackageResourceReferenceTest.java | 8 ++--- .../util/file/WebApplicationPathTest.java | 3 +- .../resource/ResourceStreamLocatorTest.java | 30 +++++++++---------- .../util/resource/UrlResourceStreamTest.java | 3 +- .../CachingResourceStreamLocatorTest.java | 7 +++-- .../locator/ResourceNameIteratorTest.java | 6 ++-- .../DefaultMarkupCacheKeyProviderTest.java | 16 +++++----- .../html/form/LocalizedErrorMessageTest.java | 10 +++---- .../html/form/ValidatorPropertiesTest.java | 2 +- .../markup/html/form/imagebutton/Home.java | 8 ++--- .../form/imagebutton/ImageButtonTest.java | 2 +- .../apache/wicket/markup/html/image/Home.java | 8 ++--- .../wicket/markup/html/image/ImageTest.java | 2 +- .../pageStore/AsynchronousPageStoreTest.java | 3 +- .../InSessionPageStoreConcurrencyTest.java | 2 +- .../protocol/http/WicketFilterTest.java | 2 +- .../StringResourceLoaderTestBase.java | 4 +-- .../locator/LocaleResourceNameIterator.java | 4 +-- .../wicket/markup/html/include/Include.java | 6 ++-- .../http/mock/MockHttpServletRequest.java | 4 +-- .../request/resource/PartWriterCallback.java | 13 ++++---- .../apache/wicket/resource/ResourceUtil.java | 6 ++-- .../forminput/FormInputApplication.java | 8 ++--- .../org/apache/wicket/examples/pub/Home.java | 12 ++++---- .../org/apache/wicket/examples/pub2/Home.java | 12 ++++---- .../examples/requestmapper/LocaleHelper.java | 4 +-- .../org/apache/wicket/util/lang/Threads.java | 2 +- .../wicket/util/resource/ResourceUtils.java | 2 +- .../convert/converters/ConvertersTest.java | 2 +- .../apache/wicket/util/file/FilesTest.java | 3 +- .../wicket/util/io/ConnectionsTest.java | 4 ++- .../wicket/util/io/LastModifiedTest.java | 5 ++-- 37 files changed, 118 insertions(+), 109 deletions(-) diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java index 2f2d1d34d6a..c097242034c 100644 --- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java +++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java @@ -324,9 +324,9 @@ public LocaleDropDownChoice(String id) } /** Relevant locales wrapped in a list. */ - private static final List LOCALES = Arrays.asList(Locale.ENGLISH, new Locale("nl"), - Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, new Locale("pt", "BR"), - new Locale("fa", "IR"), new Locale("da", "DK")); + private static final List LOCALES = Arrays.asList(Locale.ENGLISH, Locale.of("nl"), + Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, Locale.of("pt", "BR"), + Locale.of("fa", "IR"), Locale.of("da", "DK")); /** available sites for the multiple select. */ private static final List SITES = Arrays.asList("The Server Side", "Java Lobby", diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java index 40b92cbb975..fd461d8e383 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java @@ -179,7 +179,7 @@ void testTwoComponents() assertEquals("value 1", localizer.getString("null", page.drop1)); assertEquals("value 2", localizer.getString("null", page.drop2)); - Session.get().setLocale(new Locale("nl")); + Session.get().setLocale(Locale.of("nl")); assertEquals("waarde 1", localizer.getString("null", page.drop1)); assertEquals("waarde 2", localizer.getString("null", page.drop2)); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java index 05486cd4355..b5ba6e38c59 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java @@ -49,7 +49,7 @@ void english() throws Exception @Test void dutch() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_nl_expected.html"); @@ -63,7 +63,7 @@ void dutch() throws Exception @Test void testDutchMyStyle() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); @@ -78,7 +78,7 @@ void testDutchMyStyle() throws Exception @Test void dutchMyStyleMyVar() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page2.class); tester.assertRenderedPage(Page2.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java index ee667929b4c..13339496e37 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java @@ -133,7 +133,7 @@ public IResource getResource() }; ResourceReference reference2 = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), null, null) { private static final long serialVersionUID = 1L; @@ -146,7 +146,7 @@ public IResource getResource() }; private ResourceReference reference2_a = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), "style", null) { private static final long serialVersionUID = 1L; diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java index 550424ecfcc..6acd50cfefc 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java @@ -162,7 +162,7 @@ void decode3() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -180,7 +180,7 @@ void decode3A() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertEquals("style", h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -210,7 +210,7 @@ void decode4() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals("v1", h.getPageParameters().get("p1").toString()); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java index 8b7e05aac38..3e230660255 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java @@ -70,7 +70,7 @@ class PackageResourceReferenceTest extends WicketTestCase { private static Class scope = PackageResourceReferenceTest.class; private static final Locale defaultLocale = Locale.CHINA; - private static final Locale[] locales = { null, new Locale("en"), new Locale("en", "US") }; + private static final Locale[] locales = { null, Locale.of("en"), Locale.of("en", "US") }; private static final String[] styles = { null, "style" }; private static final String[] variations = { null, "var" }; @@ -173,7 +173,7 @@ void resourceResponse() @Test void sessionAttributesRelevance() { - for (Locale locale : new Locale[] { new Locale("en"), new Locale("en", "US") }) + for (Locale locale : new Locale[] { Locale.of("en"), Locale.of("en", "US") }) { tester.getSession().setLocale(locale); for (String style : styles) @@ -198,10 +198,10 @@ void sessionAttributesRelevance() @Test void userAttributesPreference() { - tester.getSession().setLocale(new Locale("en")); + tester.getSession().setLocale(Locale.of("en")); tester.getSession().setStyle("style"); - Locale[] userLocales = { null, new Locale("pt"), new Locale("pt", "BR") }; + Locale[] userLocales = { null, Locale.of("pt"), Locale.of("pt", "BR") }; String userStyle = "style2"; for (Locale userLocale : userLocales) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java index d8badb3812a..e1642de1507 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import java.net.URI; import java.net.URL; import jakarta.servlet.ServletContext; @@ -35,7 +36,7 @@ class WebApplicationPathTest @Test void doNotServeResourcesFromWebInf() throws Exception { - URL webUrl = new URL("file://dummyFile"); + URL webUrl = URI.create("file://dummyFile").toURL(); ServletContext context = Mockito.mock(ServletContext.class); Mockito.when(context.getResource(ArgumentMatchers.any(String.class))).thenReturn(webUrl); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java index cb9a7242f6c..89be4a22764 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java @@ -44,21 +44,21 @@ */ public class ResourceStreamLocatorTest extends WicketTestCase { - private final Locale locale_de = new Locale("de"); - private final Locale locale_de_DE = new Locale("de", "DE"); - private final Locale locale_de_DE_POSIX = new Locale("de", "DE", "POSIX"); - private final Locale locale_de_POSIX = new Locale("de", "", "POSIX"); - private final Locale locale_de_CH = new Locale("de", "CH"); - - private final Locale locale_en = new Locale("en"); - private final Locale locale_en_US = new Locale("en", "US"); - private final Locale locale_en_US_WIN = new Locale("en", "US", "WIN"); - private final Locale locale_en_WIN = new Locale("en", "", "WIN"); - - private final Locale locale_fr = new Locale("fr"); - private final Locale locale_fr_FR = new Locale("fr", "FR"); - private final Locale locale_fr_FR_WIN = new Locale("fr", "FR", "WIN"); - private final Locale locale_fr_WIN = new Locale("fr", "", "WIN"); + private final Locale locale_de = Locale.of("de"); + private final Locale locale_de_DE = Locale.of("de", "DE"); + private final Locale locale_de_DE_POSIX = Locale.of("de", "DE", "POSIX"); + private final Locale locale_de_POSIX = Locale.of("de", "", "POSIX"); + private final Locale locale_de_CH = Locale.of("de", "CH"); + + private final Locale locale_en = Locale.of("en"); + private final Locale locale_en_US = Locale.of("en", "US"); + private final Locale locale_en_US_WIN = Locale.of("en", "US", "WIN"); + private final Locale locale_en_WIN = Locale.of("en", "", "WIN"); + + private final Locale locale_fr = Locale.of("fr"); + private final Locale locale_fr_FR = Locale.of("fr", "FR"); + private final Locale locale_fr_FR_WIN = Locale.of("fr", "FR", "WIN"); + private final Locale locale_fr_WIN = Locale.of("fr", "", "WIN"); /** * diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java index 60829c9b05d..f6725f37947 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -66,7 +67,7 @@ void loadJustOnce() throws IOException, ResourceStreamNotFoundException { final AtomicInteger connectCounter = new AtomicInteger(0); final AtomicInteger streamCounter = new AtomicInteger(0); - URL url = new URL(null, "test://anything", new CountingURLStreamHandler(realURL, + URL url = URL.of(URI.create("test://anything"), new CountingURLStreamHandler(realURL, connectCounter, streamCounter)); UrlResourceStream countingStream = new UrlResourceStream(url); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java index fd15e29cb3c..0ede019f760 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java @@ -24,6 +24,7 @@ import static org.mockito.Mockito.when; import java.io.File; +import java.net.URI; import java.net.URL; import java.util.Locale; @@ -108,7 +109,7 @@ void strictMatchingDoesntInvalidateNonStrictMatching() String style = null; String variation = null; - Locale locale = new Locale("nl", "NL"); + Locale locale = Locale.of("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; @@ -138,7 +139,7 @@ void nonStrictMatchingDoesntResultInInvalidStrictMatch() String style = null; String variation = null; - Locale locale = new Locale("nl", "NL"); + Locale locale = Locale.of("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; @@ -218,7 +219,7 @@ void urlResource() throws Exception { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); - UrlResourceStream urs = new UrlResourceStream(new URL("file:///")); + UrlResourceStream urs = new UrlResourceStream(URI.create("file:///").toURL()); when(resourceStreamLocator.locate(String.class, "path")).thenReturn(urs); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java index 487c19a8e15..fdecd6feab2 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java @@ -39,7 +39,7 @@ class ResourceNameIteratorTest extends WicketTestCase @Test void localeResourceNameIterator() { - Locale locale = new Locale("a", "b", "c"); + Locale locale = Locale.of("a", "b", "c"); LocaleResourceNameIterator iterator = new LocaleResourceNameIterator(locale, false); HashSet variations = new HashSet(); while (iterator.hasNext()) @@ -52,7 +52,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = new Locale("a", "b"); + locale = Locale.of("a", "b"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) @@ -64,7 +64,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = new Locale("a"); + locale = Locale.of("a"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java index c369d2aa2b6..b0b7e6dc249 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java @@ -40,36 +40,36 @@ void localeLanguageCountryVariant() Foo foo = new Foo("foo"); assertEquals("org.apache.wicket.markup.Foo.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale(""); + foo.locale = Locale.of(""); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("language"); + foo.locale = Locale.of("language"); assertEquals("org.apache.wicket.markup.Foo_language.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("", "COUNTRY"); + foo.locale = Locale.of("", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY.html", provider.getCacheKey(foo, foo.getClass())); // variant only is ignored - foo.locale = new Locale("", "", "variant"); + foo.locale = Locale.of("", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("language", "COUNTRY"); + foo.locale = Locale.of("language", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("language", "", "variant"); + foo.locale = Locale.of("language", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_language__variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("", "COUNTRY", "variant"); + foo.locale = Locale.of("", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY_variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("language", "COUNTRY", "variant"); + foo.locale = Locale.of("language", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY_variant.html", provider.getCacheKey(foo, foo.getClass())); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java index 9d7e45b7596..0e389171ca7 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java @@ -33,7 +33,7 @@ class LocalizedErrorMessageTest extends WicketTestCase @Test void wicket891() { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -42,7 +42,7 @@ void wicket891() tester.submitForm(page.form); tester.assertErrorMessages("'Number' moet een getal zijn. "); - tester.getSession().setLocale(new Locale("us")); + tester.getSession().setLocale(Locale.of("us")); tester.clearFeedbackMessages(); @@ -62,7 +62,7 @@ void wicket891() @Test void testConvertedVars() { - tester.getSession().setLocale(new Locale("de")); + tester.getSession().setLocale(Locale.of("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -84,7 +84,7 @@ void testConvertedVars() void wicket_1927() { tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); - tester.getSession().setLocale(new Locale("de")); + tester.getSession().setLocale(Locale.of("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -94,7 +94,7 @@ void wicket_1927() tester.submitForm(page.form); tester.assertErrorMessages("Der Wert von 'Number' ist kein g\u00FCltiger Wert f\u00FCr 'Double'."); - tester.getSession().setLocale(new Locale("pl")); + tester.getSession().setLocale(Locale.of("pl")); tester.clearFeedbackMessages(); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java index d23decda38b..bc77c7eab0a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java @@ -183,7 +183,7 @@ void test1() // now test Dutch - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); page = new TestPage(); form = (Form)page.get("form1"); assertNotNull(form); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java index 4cebe01c9bf..eec70162e8a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java @@ -74,7 +74,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("nl", "NL")); + getSession().setLocale(Locale.of("nl", "NL")); } }); add(new Link("goGerman") @@ -84,7 +84,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("de", "DE")); + getSession().setLocale(Locale.of("de", "DE")); } }); add(new Link("goChinese") @@ -94,7 +94,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("zh", "CN")); + getSession().setLocale(Locale.of("zh", "CN")); } }); add(new Link("goDanish") @@ -104,7 +104,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("da", "DK")); + getSession().setLocale(Locale.of("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java index 7e7ffae0304..0035d417975 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java @@ -33,7 +33,7 @@ class ImageButtonTest extends WicketTestCase @Test void imageButton() throws Exception { - Locale.setDefault(new Locale("en", "US")); + Locale.setDefault(Locale.of("en", "US")); tester.startPage(Home.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java index c9516c3be94..dd51c547dff 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java @@ -73,7 +73,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("nl", "NL")); + getSession().setLocale(Locale.of("nl", "NL")); } }); add(new Link("goGerman") @@ -83,7 +83,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("de", "DE")); + getSession().setLocale(Locale.of("de", "DE")); } }); add(new Link("goChinese") @@ -93,7 +93,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("zh", "CN")); + getSession().setLocale(Locale.of("zh", "CN")); } }); add(new Link("goDanish") @@ -103,7 +103,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("da", "DK")); + getSession().setLocale(Locale.of("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java index 04e8ad94e6b..256cc372c71 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java @@ -34,7 +34,7 @@ public class ImageTest extends WicketTestCase @Test void test_1() throws Exception { - Locale.setDefault(new Locale("en", "US")); + Locale.setDefault(Locale.of("en", "US")); tester.startPage(Home.class); tester.clickLink("goCanadian"); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java index ffd85e5020e..5c1577ee10a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java @@ -26,7 +26,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.lang3.RandomUtils; @@ -534,6 +533,6 @@ public IManageablePage getPage(IPageContext context, int id) { private long around(long target) { - return RandomUtils.nextLong((long)(target * .9), (long)(target * 1.1)); + return RandomUtils.secure().randomLong((long)(target * .9), (long)(target * 1.1)); } } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java index 75594096e25..acd43f8dad4 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java @@ -96,7 +96,7 @@ public MockHttpSession getHttpSession() }; Callable serializeSessionTask = () -> { - final NullOutputStream nullOutputStream = NullOutputStream.NULL_OUTPUT_STREAM; + final NullOutputStream nullOutputStream = NullOutputStream.INSTANCE; try(final ObjectOutputStream objectOutputStream = new ObjectOutputStream(nullOutputStream)) { objectOutputStream.writeObject(wicketTester.getSession()); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java index f289a4cf790..7ba32cc75a4 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java @@ -535,7 +535,7 @@ void ignorePaths() throws Exception filter.init(new FilterTestingConfig()); HttpServletRequest request = mock(HttpServletRequest.class); - when(request.getLocale()).thenReturn(new Locale("bg", "BG")); + when(request.getLocale()).thenReturn(Locale.of("bg", "BG")); when(request.getRequestURI()).thenReturn("/contextPath/js/bla.js") .thenReturn("/contextPath/css/bla.css") .thenReturn("/contextPath/images/bla.img") diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java index 186515d8611..8d9d300fd99 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java @@ -106,7 +106,7 @@ void loaderInvalidKeyNoStyleDefaultLocale() @Test void loaderValidKeyNoStyleAlternativeLocale() { - String s = loader.loadStringResource(component.getClass(), "test.string", new Locale("zz"), + String s = loader.loadStringResource(component.getClass(), "test.string", Locale.of("zz"), null, null); assertEquals("Flib flob", s, "Resource should be loaded"); } @@ -118,7 +118,7 @@ void loaderValidKeyNoStyleAlternativeLocale() void loaderInvalidKeyNoStyleAlternativeLocale() { assertNull(loader.loadStringResource(component.getClass(), "unknown.string", - new Locale("zz"), null, null), "Missing key should return null"); + Locale.of("zz"), null, null), "Missing key should return null"); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java index a2d2763e3ca..3faedccda6f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java @@ -63,11 +63,11 @@ public Locale getLocale() } else if (state == 2) { - return new Locale(locale.getLanguage(), locale.getCountry()); + return Locale.of(locale.getLanguage(), locale.getCountry()); } else if (state == 3) { - return new Locale(locale.getLanguage()); + return Locale.of(locale.getLanguage()); } return null; } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java index 1d1ee4bd4d3..ee44fd3b877 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java @@ -17,6 +17,8 @@ package org.apache.wicket.markup.html.include; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; @@ -187,9 +189,9 @@ private String importAbsoluteUrl(CharSequence url) { try { - return importUrl(new URL(url.toString())); + return importUrl(new URI(url.toString()).toURL()); } - catch (MalformedURLException e) + catch (URISyntaxException | MalformedURLException e) { throw new WicketRuntimeException(e); } diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java index 362fb1dd8db..3594200481e 100755 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java @@ -650,11 +650,11 @@ private Locale getLocale(final String value) if (bits.length > 1) { final String country = bits[1].toUpperCase(Locale.ROOT); - return new Locale(language, country); + return Locale.of(language, country); } else { - return new Locale(language); + return Locale.of(language); } } diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java index 6b6b4c9a6a8..8e2ce385452 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java @@ -141,12 +141,13 @@ public void writeData(Attributes attributes) throws IOException { // Stream is going to be read from the starting point next to the skipped bytes // till the end byte computed by the range between startbyte / endbyte - boundedInputStream = new BoundedInputStream(inputStream, - (endbyte - startbyte) + 1); - - // The original input stream is going to be closed by the end of the request - // so set propagate close to false - boundedInputStream.setPropagateClose(false); + boundedInputStream = BoundedInputStream.builder() + .setInputStream(inputStream) + .setMaxCount((endbyte - startbyte) + 1) + // The original input stream is going to be closed by the end of the request + // so set propagate close to false + .setPropagateClose(false) + .get(); // The read bytes in the current buffer int readBytes; diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java index 28ed7e2562e..2ef46d1957e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java @@ -196,15 +196,15 @@ public static Locale parseLocale(String locale) String parts[] = locale.toLowerCase(Locale.ROOT).split("_", 3); if (parts.length == 1) { - return new Locale(parts[0]); + return Locale.of(parts[0]); } else if (parts.length == 2) { - return new Locale(parts[0], parts[1]); + return Locale.of(parts[0], parts[1]); } else if (parts.length == 3) { - return new Locale(parts[0], parts[1], parts[2]); + return Locale.of(parts[0], parts[1], parts[2]); } else { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java index 8833c456ee3..4bab3e24177 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java @@ -40,9 +40,9 @@ public class FormInputApplication extends WicketExampleApplication { /** Relevant locales wrapped in a list. */ public static final List LOCALES = Arrays.asList(Locale.ENGLISH, - new Locale("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, - new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"), - new Locale("th", "TH"), new Locale("ru"), new Locale("ko", "KR")); + Locale.of("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, + Locale.of("pt", "BR"), Locale.of("fa", "IR"), Locale.of("da", "DK"), + Locale.of("th", "TH"), Locale.of("ru"), Locale.of("ko", "KR")); @Override public Class getHomePage() @@ -92,7 +92,7 @@ protected void init() // Persian buttons Font fontFa = new Font("Serif", Font.BOLD, 16); - Locale farsi = new Locale("fa", "IR"); + Locale farsi = Locale.of("fa", "IR"); DefaultButtonImageResource imgSaveFa = new DefaultButtonImageResource( "\u0630\u062e\u064a\u0631\u0647"); imgSaveFa.setFont(fontFa); diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java index 6d6d3f111c8..c4bcdbb9d8c 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java @@ -68,12 +68,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); - add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); - add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); - add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); - add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); - add(new SetLocaleLink("goHungarian", new Locale("hu"))); + add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); + add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); + add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); + add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); + add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); + add(new SetLocaleLink("goHungarian", Locale.of("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java index 088400c9235..13d7010836f 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java @@ -64,12 +64,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); - add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); - add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); - add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); - add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); - add(new SetLocaleLink("goHungarian", new Locale("hu"))); + add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); + add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); + add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); + add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); + add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); + add(new SetLocaleLink("goHungarian", Locale.of("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java index e16399aadba..040c4da7e90 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java @@ -37,13 +37,13 @@ static Locale parseLocale(final String localeAsString, final Locale defaultLocal { String lang = localeAsString.substring(0, idxOfUnderbar); String country = localeAsString.substring(idxOfUnderbar + 1); - result = new Locale(lang, country); + result = Locale.of(lang, country); } else { String lang = localeAsString; - result = new Locale(lang); + result = Locale.of(lang); } return result; diff --git a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java index 7f0ffdc1276..1d1e765551e 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java @@ -106,7 +106,7 @@ private static void dumpSingleThread(Logger logger, Thread thread, StackTraceEle variables.put("name", thread.getName()); variables.put("isDaemon", thread.isDaemon() ? " daemon" : ""); variables.put("priority", thread.getPriority()); - variables.put("threadIdDec", thread.getId()); + variables.put("threadIdDec", thread.threadId()); variables.put("state", thread.getState()); ThreadDump throwable = new ThreadDump(); diff --git a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java index 59ee9dda870..30446adaf39 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java @@ -138,7 +138,7 @@ public static PathLocale getLocaleFromFilename(String path) String basePath = path.substring(0, languagePos) + (min == null ? "" : min) + extension; - Locale locale = new Locale(language, country != null ? country : "", + Locale locale = Locale.of(language, country != null ? country : "", variant != null ? variant : ""); return new PathLocale(basePath, locale); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java index e09c64523e7..01141650f0b 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java @@ -50,7 +50,7 @@ final class ConvertersTest { /** Dutch locale for localized testing. */ - private static final Locale DUTCH_LOCALE = new Locale("nl", "NL"); + private static final Locale DUTCH_LOCALE = Locale.of("nl", "NL"); @Test void thousandSeparator() { diff --git a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java index 30de8724ce8..f4c42967881 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import java.io.IOException; +import java.net.URI; import java.net.URL; import static java.lang.System.currentTimeMillis; @@ -233,7 +234,7 @@ public void removeFolderAsync() throws Exception @Test public void fileWithWhitespace() throws Exception { - URL url = new URL("file:/file%20with%20whitespace"); + URL url = URI.create("file:/file%20with%20whitespace").toURL(); assertEquals(java.io.File.separator + "file with whitespace", Files.getLocalFileFromUrl(url).getPath()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java index 02601b371f8..0ac25887fef 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java @@ -18,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.WicketTestTag; @@ -36,7 +38,7 @@ class ConnectionsTest @Test void getLastModified() throws Exception { - URL url = new URL("https://wicket.apache.org/learn/books/wia.png"); + URL url = URI.create("https://wicket.apache.org/learn/books/wia.png").toURL(); Instant lastModified = Connections.getLastModified(url); assertNotNull(lastModified); assertNotEquals(0L, lastModified.toEpochMilli()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java index 2ed37103acf..55b5df4a287 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.file.Files; @@ -43,7 +44,7 @@ public void getTimestampForMissingFile() throws IOException { File file = new File("/does/not/exists/4iorp4opergere.txt"); assertNull(Files.getLastModified(file)); - assertNull(Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); + assertNull(Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); } /** @@ -85,7 +86,7 @@ public void getLastModified() throws IOException final Instant expected = Instant.ofEpochMilli(lm); assertEquals(expected, Files.getLastModified(file)); assertEquals(expected, - Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); + Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); } } finally From 4bc04483d6efb7890bbe1a7e765295044f51852c Mon Sep 17 00:00:00 2001 From: Andrea Del Bene Date: Wed, 4 Dec 2024 12:11:24 +0100 Subject: [PATCH 14/15] Revert "Setting Java 21 as minimum version" This reverts commit a5e43aeed041e0366d01a1a35aa48ed1bf62a581. --- .github/workflows/maven.yml | 1 + pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 20dc2cf68b5..bec22356235 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,6 +16,7 @@ jobs: strategy: matrix: java: + - '17' - '21' - '23' diff --git a/pom.xml b/pom.xml index 6eb2ebbf95e..556953b51e5 100644 --- a/pom.xml +++ b/pom.xml @@ -136,8 +136,8 @@ true true - 21 - 21 + 17 + 17 9.7.1 From 9b5d6b87a7ec5b124886096fe79470115d75dd23 Mon Sep 17 00:00:00 2001 From: Andrea Del Bene Date: Wed, 4 Dec 2024 12:31:36 +0100 Subject: [PATCH 15/15] Revert "WICKET-7135 Work on deprecation warnings (#1049)" This reverts commit da01909263cc6b48d7e082ac2fc4bcd0dda75e8a. --- .../wicket/threadtest/apps/app1/Home.java | 6 ++-- .../java/org/apache/wicket/LocalizerTest.java | 2 +- .../apache/wicket/PageMarkupLoadingTest.java | 6 ++-- .../AbstractResourceReferenceMapperTest.java | 4 +-- .../BasicResourceReferenceMapperTest.java | 6 ++-- .../PackageResourceReferenceTest.java | 8 ++--- .../util/file/WebApplicationPathTest.java | 3 +- .../resource/ResourceStreamLocatorTest.java | 30 +++++++++---------- .../util/resource/UrlResourceStreamTest.java | 3 +- .../CachingResourceStreamLocatorTest.java | 7 ++--- .../locator/ResourceNameIteratorTest.java | 6 ++-- .../DefaultMarkupCacheKeyProviderTest.java | 16 +++++----- .../html/form/LocalizedErrorMessageTest.java | 10 +++---- .../html/form/ValidatorPropertiesTest.java | 2 +- .../markup/html/form/imagebutton/Home.java | 8 ++--- .../form/imagebutton/ImageButtonTest.java | 2 +- .../apache/wicket/markup/html/image/Home.java | 8 ++--- .../wicket/markup/html/image/ImageTest.java | 2 +- .../pageStore/AsynchronousPageStoreTest.java | 3 +- .../InSessionPageStoreConcurrencyTest.java | 2 +- .../protocol/http/WicketFilterTest.java | 2 +- .../StringResourceLoaderTestBase.java | 4 +-- .../locator/LocaleResourceNameIterator.java | 4 +-- .../wicket/markup/html/include/Include.java | 6 ++-- .../http/mock/MockHttpServletRequest.java | 4 +-- .../request/resource/PartWriterCallback.java | 13 ++++---- .../apache/wicket/resource/ResourceUtil.java | 6 ++-- .../forminput/FormInputApplication.java | 8 ++--- .../org/apache/wicket/examples/pub/Home.java | 12 ++++---- .../org/apache/wicket/examples/pub2/Home.java | 12 ++++---- .../examples/requestmapper/LocaleHelper.java | 4 +-- .../org/apache/wicket/util/lang/Threads.java | 2 +- .../wicket/util/resource/ResourceUtils.java | 2 +- .../convert/converters/ConvertersTest.java | 2 +- .../apache/wicket/util/file/FilesTest.java | 3 +- .../wicket/util/io/ConnectionsTest.java | 4 +-- .../wicket/util/io/LastModifiedTest.java | 5 ++-- 37 files changed, 109 insertions(+), 118 deletions(-) diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java index c097242034c..2f2d1d34d6a 100644 --- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java +++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java @@ -324,9 +324,9 @@ public LocaleDropDownChoice(String id) } /** Relevant locales wrapped in a list. */ - private static final List LOCALES = Arrays.asList(Locale.ENGLISH, Locale.of("nl"), - Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, Locale.of("pt", "BR"), - Locale.of("fa", "IR"), Locale.of("da", "DK")); + private static final List LOCALES = Arrays.asList(Locale.ENGLISH, new Locale("nl"), + Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, new Locale("pt", "BR"), + new Locale("fa", "IR"), new Locale("da", "DK")); /** available sites for the multiple select. */ private static final List SITES = Arrays.asList("The Server Side", "Java Lobby", diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java index fd461d8e383..40b92cbb975 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java @@ -179,7 +179,7 @@ void testTwoComponents() assertEquals("value 1", localizer.getString("null", page.drop1)); assertEquals("value 2", localizer.getString("null", page.drop2)); - Session.get().setLocale(Locale.of("nl")); + Session.get().setLocale(new Locale("nl")); assertEquals("waarde 1", localizer.getString("null", page.drop1)); assertEquals("waarde 2", localizer.getString("null", page.drop2)); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java index b5ba6e38c59..05486cd4355 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java @@ -49,7 +49,7 @@ void english() throws Exception @Test void dutch() throws Exception { - tester.getSession().setLocale(Locale.of("nl")); + tester.getSession().setLocale(new Locale("nl")); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_nl_expected.html"); @@ -63,7 +63,7 @@ void dutch() throws Exception @Test void testDutchMyStyle() throws Exception { - tester.getSession().setLocale(Locale.of("nl")); + tester.getSession().setLocale(new Locale("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); @@ -78,7 +78,7 @@ void testDutchMyStyle() throws Exception @Test void dutchMyStyleMyVar() throws Exception { - tester.getSession().setLocale(Locale.of("nl")); + tester.getSession().setLocale(new Locale("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page2.class); tester.assertRenderedPage(Page2.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java index 13339496e37..ee667929b4c 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java @@ -133,7 +133,7 @@ public IResource getResource() }; ResourceReference reference2 = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), null, null) { private static final long serialVersionUID = 1L; @@ -146,7 +146,7 @@ public IResource getResource() }; private ResourceReference reference2_a = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), "style", null) { private static final long serialVersionUID = 1L; diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java index 6acd50cfefc..550424ecfcc 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java @@ -162,7 +162,7 @@ void decode3() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(Locale.of("en", "en"), h.getLocale()); + assertEquals(new Locale("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -180,7 +180,7 @@ void decode3A() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(Locale.of("en", "en"), h.getLocale()); + assertEquals(new Locale("en", "en"), h.getLocale()); assertEquals("style", h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -210,7 +210,7 @@ void decode4() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(Locale.of("en", "en"), h.getLocale()); + assertEquals(new Locale("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals("v1", h.getPageParameters().get("p1").toString()); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java index 3e230660255..8b7e05aac38 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java @@ -70,7 +70,7 @@ class PackageResourceReferenceTest extends WicketTestCase { private static Class scope = PackageResourceReferenceTest.class; private static final Locale defaultLocale = Locale.CHINA; - private static final Locale[] locales = { null, Locale.of("en"), Locale.of("en", "US") }; + private static final Locale[] locales = { null, new Locale("en"), new Locale("en", "US") }; private static final String[] styles = { null, "style" }; private static final String[] variations = { null, "var" }; @@ -173,7 +173,7 @@ void resourceResponse() @Test void sessionAttributesRelevance() { - for (Locale locale : new Locale[] { Locale.of("en"), Locale.of("en", "US") }) + for (Locale locale : new Locale[] { new Locale("en"), new Locale("en", "US") }) { tester.getSession().setLocale(locale); for (String style : styles) @@ -198,10 +198,10 @@ void sessionAttributesRelevance() @Test void userAttributesPreference() { - tester.getSession().setLocale(Locale.of("en")); + tester.getSession().setLocale(new Locale("en")); tester.getSession().setStyle("style"); - Locale[] userLocales = { null, Locale.of("pt"), Locale.of("pt", "BR") }; + Locale[] userLocales = { null, new Locale("pt"), new Locale("pt", "BR") }; String userStyle = "style2"; for (Locale userLocale : userLocales) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java index e1642de1507..d8badb3812a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import java.net.URI; import java.net.URL; import jakarta.servlet.ServletContext; @@ -36,7 +35,7 @@ class WebApplicationPathTest @Test void doNotServeResourcesFromWebInf() throws Exception { - URL webUrl = URI.create("file://dummyFile").toURL(); + URL webUrl = new URL("file://dummyFile"); ServletContext context = Mockito.mock(ServletContext.class); Mockito.when(context.getResource(ArgumentMatchers.any(String.class))).thenReturn(webUrl); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java index 89be4a22764..cb9a7242f6c 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java @@ -44,21 +44,21 @@ */ public class ResourceStreamLocatorTest extends WicketTestCase { - private final Locale locale_de = Locale.of("de"); - private final Locale locale_de_DE = Locale.of("de", "DE"); - private final Locale locale_de_DE_POSIX = Locale.of("de", "DE", "POSIX"); - private final Locale locale_de_POSIX = Locale.of("de", "", "POSIX"); - private final Locale locale_de_CH = Locale.of("de", "CH"); - - private final Locale locale_en = Locale.of("en"); - private final Locale locale_en_US = Locale.of("en", "US"); - private final Locale locale_en_US_WIN = Locale.of("en", "US", "WIN"); - private final Locale locale_en_WIN = Locale.of("en", "", "WIN"); - - private final Locale locale_fr = Locale.of("fr"); - private final Locale locale_fr_FR = Locale.of("fr", "FR"); - private final Locale locale_fr_FR_WIN = Locale.of("fr", "FR", "WIN"); - private final Locale locale_fr_WIN = Locale.of("fr", "", "WIN"); + private final Locale locale_de = new Locale("de"); + private final Locale locale_de_DE = new Locale("de", "DE"); + private final Locale locale_de_DE_POSIX = new Locale("de", "DE", "POSIX"); + private final Locale locale_de_POSIX = new Locale("de", "", "POSIX"); + private final Locale locale_de_CH = new Locale("de", "CH"); + + private final Locale locale_en = new Locale("en"); + private final Locale locale_en_US = new Locale("en", "US"); + private final Locale locale_en_US_WIN = new Locale("en", "US", "WIN"); + private final Locale locale_en_WIN = new Locale("en", "", "WIN"); + + private final Locale locale_fr = new Locale("fr"); + private final Locale locale_fr_FR = new Locale("fr", "FR"); + private final Locale locale_fr_FR_WIN = new Locale("fr", "FR", "WIN"); + private final Locale locale_fr_WIN = new Locale("fr", "", "WIN"); /** * diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java index f6725f37947..60829c9b05d 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -67,7 +66,7 @@ void loadJustOnce() throws IOException, ResourceStreamNotFoundException { final AtomicInteger connectCounter = new AtomicInteger(0); final AtomicInteger streamCounter = new AtomicInteger(0); - URL url = URL.of(URI.create("test://anything"), new CountingURLStreamHandler(realURL, + URL url = new URL(null, "test://anything", new CountingURLStreamHandler(realURL, connectCounter, streamCounter)); UrlResourceStream countingStream = new UrlResourceStream(url); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java index 0ede019f760..fd15e29cb3c 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java @@ -24,7 +24,6 @@ import static org.mockito.Mockito.when; import java.io.File; -import java.net.URI; import java.net.URL; import java.util.Locale; @@ -109,7 +108,7 @@ void strictMatchingDoesntInvalidateNonStrictMatching() String style = null; String variation = null; - Locale locale = Locale.of("nl", "NL"); + Locale locale = new Locale("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; @@ -139,7 +138,7 @@ void nonStrictMatchingDoesntResultInInvalidStrictMatch() String style = null; String variation = null; - Locale locale = Locale.of("nl", "NL"); + Locale locale = new Locale("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; @@ -219,7 +218,7 @@ void urlResource() throws Exception { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); - UrlResourceStream urs = new UrlResourceStream(URI.create("file:///").toURL()); + UrlResourceStream urs = new UrlResourceStream(new URL("file:///")); when(resourceStreamLocator.locate(String.class, "path")).thenReturn(urs); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java index fdecd6feab2..487c19a8e15 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java @@ -39,7 +39,7 @@ class ResourceNameIteratorTest extends WicketTestCase @Test void localeResourceNameIterator() { - Locale locale = Locale.of("a", "b", "c"); + Locale locale = new Locale("a", "b", "c"); LocaleResourceNameIterator iterator = new LocaleResourceNameIterator(locale, false); HashSet variations = new HashSet(); while (iterator.hasNext()) @@ -52,7 +52,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = Locale.of("a", "b"); + locale = new Locale("a", "b"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) @@ -64,7 +64,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = Locale.of("a"); + locale = new Locale("a"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java index b0b7e6dc249..c369d2aa2b6 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java @@ -40,36 +40,36 @@ void localeLanguageCountryVariant() Foo foo = new Foo("foo"); assertEquals("org.apache.wicket.markup.Foo.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = Locale.of(""); + foo.locale = new Locale(""); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = Locale.of("language"); + foo.locale = new Locale("language"); assertEquals("org.apache.wicket.markup.Foo_language.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = Locale.of("", "COUNTRY"); + foo.locale = new Locale("", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY.html", provider.getCacheKey(foo, foo.getClass())); // variant only is ignored - foo.locale = Locale.of("", "", "variant"); + foo.locale = new Locale("", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = Locale.of("language", "COUNTRY"); + foo.locale = new Locale("language", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = Locale.of("language", "", "variant"); + foo.locale = new Locale("language", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_language__variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = Locale.of("", "COUNTRY", "variant"); + foo.locale = new Locale("", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY_variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = Locale.of("language", "COUNTRY", "variant"); + foo.locale = new Locale("language", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY_variant.html", provider.getCacheKey(foo, foo.getClass())); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java index 0e389171ca7..9d7e45b7596 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java @@ -33,7 +33,7 @@ class LocalizedErrorMessageTest extends WicketTestCase @Test void wicket891() { - tester.getSession().setLocale(Locale.of("nl")); + tester.getSession().setLocale(new Locale("nl")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -42,7 +42,7 @@ void wicket891() tester.submitForm(page.form); tester.assertErrorMessages("'Number' moet een getal zijn. "); - tester.getSession().setLocale(Locale.of("us")); + tester.getSession().setLocale(new Locale("us")); tester.clearFeedbackMessages(); @@ -62,7 +62,7 @@ void wicket891() @Test void testConvertedVars() { - tester.getSession().setLocale(Locale.of("de")); + tester.getSession().setLocale(new Locale("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -84,7 +84,7 @@ void testConvertedVars() void wicket_1927() { tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); - tester.getSession().setLocale(Locale.of("de")); + tester.getSession().setLocale(new Locale("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -94,7 +94,7 @@ void wicket_1927() tester.submitForm(page.form); tester.assertErrorMessages("Der Wert von 'Number' ist kein g\u00FCltiger Wert f\u00FCr 'Double'."); - tester.getSession().setLocale(Locale.of("pl")); + tester.getSession().setLocale(new Locale("pl")); tester.clearFeedbackMessages(); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java index bc77c7eab0a..d23decda38b 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java @@ -183,7 +183,7 @@ void test1() // now test Dutch - tester.getSession().setLocale(Locale.of("nl")); + tester.getSession().setLocale(new Locale("nl")); page = new TestPage(); form = (Form)page.get("form1"); assertNotNull(form); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java index eec70162e8a..4cebe01c9bf 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java @@ -74,7 +74,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("nl", "NL")); + getSession().setLocale(new Locale("nl", "NL")); } }); add(new Link("goGerman") @@ -84,7 +84,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("de", "DE")); + getSession().setLocale(new Locale("de", "DE")); } }); add(new Link("goChinese") @@ -94,7 +94,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("zh", "CN")); + getSession().setLocale(new Locale("zh", "CN")); } }); add(new Link("goDanish") @@ -104,7 +104,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("da", "DK")); + getSession().setLocale(new Locale("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java index 0035d417975..7e7ffae0304 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java @@ -33,7 +33,7 @@ class ImageButtonTest extends WicketTestCase @Test void imageButton() throws Exception { - Locale.setDefault(Locale.of("en", "US")); + Locale.setDefault(new Locale("en", "US")); tester.startPage(Home.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java index dd51c547dff..c9516c3be94 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java @@ -73,7 +73,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("nl", "NL")); + getSession().setLocale(new Locale("nl", "NL")); } }); add(new Link("goGerman") @@ -83,7 +83,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("de", "DE")); + getSession().setLocale(new Locale("de", "DE")); } }); add(new Link("goChinese") @@ -93,7 +93,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("zh", "CN")); + getSession().setLocale(new Locale("zh", "CN")); } }); add(new Link("goDanish") @@ -103,7 +103,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(Locale.of("da", "DK")); + getSession().setLocale(new Locale("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java index 256cc372c71..04e8ad94e6b 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java @@ -34,7 +34,7 @@ public class ImageTest extends WicketTestCase @Test void test_1() throws Exception { - Locale.setDefault(Locale.of("en", "US")); + Locale.setDefault(new Locale("en", "US")); tester.startPage(Home.class); tester.clickLink("goCanadian"); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java index 5c1577ee10a..ffd85e5020e 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.lang3.RandomUtils; @@ -533,6 +534,6 @@ public IManageablePage getPage(IPageContext context, int id) { private long around(long target) { - return RandomUtils.secure().randomLong((long)(target * .9), (long)(target * 1.1)); + return RandomUtils.nextLong((long)(target * .9), (long)(target * 1.1)); } } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java index acd43f8dad4..75594096e25 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java @@ -96,7 +96,7 @@ public MockHttpSession getHttpSession() }; Callable serializeSessionTask = () -> { - final NullOutputStream nullOutputStream = NullOutputStream.INSTANCE; + final NullOutputStream nullOutputStream = NullOutputStream.NULL_OUTPUT_STREAM; try(final ObjectOutputStream objectOutputStream = new ObjectOutputStream(nullOutputStream)) { objectOutputStream.writeObject(wicketTester.getSession()); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java index 7ba32cc75a4..f289a4cf790 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java @@ -535,7 +535,7 @@ void ignorePaths() throws Exception filter.init(new FilterTestingConfig()); HttpServletRequest request = mock(HttpServletRequest.class); - when(request.getLocale()).thenReturn(Locale.of("bg", "BG")); + when(request.getLocale()).thenReturn(new Locale("bg", "BG")); when(request.getRequestURI()).thenReturn("/contextPath/js/bla.js") .thenReturn("/contextPath/css/bla.css") .thenReturn("/contextPath/images/bla.img") diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java index 8d9d300fd99..186515d8611 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java @@ -106,7 +106,7 @@ void loaderInvalidKeyNoStyleDefaultLocale() @Test void loaderValidKeyNoStyleAlternativeLocale() { - String s = loader.loadStringResource(component.getClass(), "test.string", Locale.of("zz"), + String s = loader.loadStringResource(component.getClass(), "test.string", new Locale("zz"), null, null); assertEquals("Flib flob", s, "Resource should be loaded"); } @@ -118,7 +118,7 @@ void loaderValidKeyNoStyleAlternativeLocale() void loaderInvalidKeyNoStyleAlternativeLocale() { assertNull(loader.loadStringResource(component.getClass(), "unknown.string", - Locale.of("zz"), null, null), "Missing key should return null"); + new Locale("zz"), null, null), "Missing key should return null"); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java index 3faedccda6f..a2d2763e3ca 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java @@ -63,11 +63,11 @@ public Locale getLocale() } else if (state == 2) { - return Locale.of(locale.getLanguage(), locale.getCountry()); + return new Locale(locale.getLanguage(), locale.getCountry()); } else if (state == 3) { - return Locale.of(locale.getLanguage()); + return new Locale(locale.getLanguage()); } return null; } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java index ee44fd3b877..1d1ee4bd4d3 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java @@ -17,8 +17,6 @@ package org.apache.wicket.markup.html.include; import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; @@ -189,9 +187,9 @@ private String importAbsoluteUrl(CharSequence url) { try { - return importUrl(new URI(url.toString()).toURL()); + return importUrl(new URL(url.toString())); } - catch (URISyntaxException | MalformedURLException e) + catch (MalformedURLException e) { throw new WicketRuntimeException(e); } diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java index 3594200481e..362fb1dd8db 100755 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java @@ -650,11 +650,11 @@ private Locale getLocale(final String value) if (bits.length > 1) { final String country = bits[1].toUpperCase(Locale.ROOT); - return Locale.of(language, country); + return new Locale(language, country); } else { - return Locale.of(language); + return new Locale(language); } } diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java index 8e2ce385452..6b6b4c9a6a8 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java @@ -141,13 +141,12 @@ public void writeData(Attributes attributes) throws IOException { // Stream is going to be read from the starting point next to the skipped bytes // till the end byte computed by the range between startbyte / endbyte - boundedInputStream = BoundedInputStream.builder() - .setInputStream(inputStream) - .setMaxCount((endbyte - startbyte) + 1) - // The original input stream is going to be closed by the end of the request - // so set propagate close to false - .setPropagateClose(false) - .get(); + boundedInputStream = new BoundedInputStream(inputStream, + (endbyte - startbyte) + 1); + + // The original input stream is going to be closed by the end of the request + // so set propagate close to false + boundedInputStream.setPropagateClose(false); // The read bytes in the current buffer int readBytes; diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java index 2ef46d1957e..28ed7e2562e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java @@ -196,15 +196,15 @@ public static Locale parseLocale(String locale) String parts[] = locale.toLowerCase(Locale.ROOT).split("_", 3); if (parts.length == 1) { - return Locale.of(parts[0]); + return new Locale(parts[0]); } else if (parts.length == 2) { - return Locale.of(parts[0], parts[1]); + return new Locale(parts[0], parts[1]); } else if (parts.length == 3) { - return Locale.of(parts[0], parts[1], parts[2]); + return new Locale(parts[0], parts[1], parts[2]); } else { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java index 4bab3e24177..8833c456ee3 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java @@ -40,9 +40,9 @@ public class FormInputApplication extends WicketExampleApplication { /** Relevant locales wrapped in a list. */ public static final List LOCALES = Arrays.asList(Locale.ENGLISH, - Locale.of("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, - Locale.of("pt", "BR"), Locale.of("fa", "IR"), Locale.of("da", "DK"), - Locale.of("th", "TH"), Locale.of("ru"), Locale.of("ko", "KR")); + new Locale("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, + new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"), + new Locale("th", "TH"), new Locale("ru"), new Locale("ko", "KR")); @Override public Class getHomePage() @@ -92,7 +92,7 @@ protected void init() // Persian buttons Font fontFa = new Font("Serif", Font.BOLD, 16); - Locale farsi = Locale.of("fa", "IR"); + Locale farsi = new Locale("fa", "IR"); DefaultButtonImageResource imgSaveFa = new DefaultButtonImageResource( "\u0630\u062e\u064a\u0631\u0647"); imgSaveFa.setFont(fontFa); diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java index c4bcdbb9d8c..6d6d3f111c8 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java @@ -68,12 +68,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); - add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); - add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); - add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); - add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); - add(new SetLocaleLink("goHungarian", Locale.of("hu"))); + add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); + add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); + add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); + add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); + add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); + add(new SetLocaleLink("goHungarian", new Locale("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java index 13d7010836f..088400c9235 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java @@ -64,12 +64,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); - add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); - add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); - add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); - add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); - add(new SetLocaleLink("goHungarian", Locale.of("hu"))); + add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); + add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); + add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); + add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); + add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); + add(new SetLocaleLink("goHungarian", new Locale("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java index 040c4da7e90..e16399aadba 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java @@ -37,13 +37,13 @@ static Locale parseLocale(final String localeAsString, final Locale defaultLocal { String lang = localeAsString.substring(0, idxOfUnderbar); String country = localeAsString.substring(idxOfUnderbar + 1); - result = Locale.of(lang, country); + result = new Locale(lang, country); } else { String lang = localeAsString; - result = Locale.of(lang); + result = new Locale(lang); } return result; diff --git a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java index 1d1e765551e..7f0ffdc1276 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java @@ -106,7 +106,7 @@ private static void dumpSingleThread(Logger logger, Thread thread, StackTraceEle variables.put("name", thread.getName()); variables.put("isDaemon", thread.isDaemon() ? " daemon" : ""); variables.put("priority", thread.getPriority()); - variables.put("threadIdDec", thread.threadId()); + variables.put("threadIdDec", thread.getId()); variables.put("state", thread.getState()); ThreadDump throwable = new ThreadDump(); diff --git a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java index 30446adaf39..59ee9dda870 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java @@ -138,7 +138,7 @@ public static PathLocale getLocaleFromFilename(String path) String basePath = path.substring(0, languagePos) + (min == null ? "" : min) + extension; - Locale locale = Locale.of(language, country != null ? country : "", + Locale locale = new Locale(language, country != null ? country : "", variant != null ? variant : ""); return new PathLocale(basePath, locale); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java index 01141650f0b..e09c64523e7 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java @@ -50,7 +50,7 @@ final class ConvertersTest { /** Dutch locale for localized testing. */ - private static final Locale DUTCH_LOCALE = Locale.of("nl", "NL"); + private static final Locale DUTCH_LOCALE = new Locale("nl", "NL"); @Test void thousandSeparator() { diff --git a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java index f4c42967881..30de8724ce8 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test; import java.io.IOException; -import java.net.URI; import java.net.URL; import static java.lang.System.currentTimeMillis; @@ -234,7 +233,7 @@ public void removeFolderAsync() throws Exception @Test public void fileWithWhitespace() throws Exception { - URL url = URI.create("file:/file%20with%20whitespace").toURL(); + URL url = new URL("file:/file%20with%20whitespace"); assertEquals(java.io.File.separator + "file with whitespace", Files.getLocalFileFromUrl(url).getPath()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java index 0ac25887fef..02601b371f8 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java @@ -18,8 +18,6 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.WicketTestTag; @@ -38,7 +36,7 @@ class ConnectionsTest @Test void getLastModified() throws Exception { - URL url = URI.create("https://wicket.apache.org/learn/books/wia.png").toURL(); + URL url = new URL("https://wicket.apache.org/learn/books/wia.png"); Instant lastModified = Connections.getLastModified(url); assertNotNull(lastModified); assertNotEquals(0L, lastModified.toEpochMilli()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java index 55b5df4a287..2ed37103acf 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java @@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; -import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.file.Files; @@ -44,7 +43,7 @@ public void getTimestampForMissingFile() throws IOException { File file = new File("/does/not/exists/4iorp4opergere.txt"); assertNull(Files.getLastModified(file)); - assertNull(Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); + assertNull(Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); } /** @@ -86,7 +85,7 @@ public void getLastModified() throws IOException final Instant expected = Instant.ofEpochMilli(lm); assertEquals(expected, Files.getLastModified(file)); assertEquals(expected, - Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); + Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); } } finally