You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2024/02/09 21:48:18 UTC
(wicket) branch master updated: WICKET-7099 Validate FormTester constructor parameter workingForm
This is an automated email from the ASF dual-hosted git repository.
adelbene pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new db6136e1b6 WICKET-7099 Validate FormTester constructor parameter workingForm
db6136e1b6 is described below
commit db6136e1b6b18e430792950b55f487cade0b3c4c
Author: andrea <an...@andrea-Standard>
AuthorDate: Fri Feb 9 22:48:12 2024 +0100
WICKET-7099 Validate FormTester constructor parameter workingForm
---
.../java/org/apache/wicket/util/tester/FormTester.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/wicket-tester/src/main/java/org/apache/wicket/util/tester/FormTester.java b/wicket-tester/src/main/java/org/apache/wicket/util/tester/FormTester.java
index 81550bdd23..b01326a3a0 100644
--- a/wicket-tester/src/main/java/org/apache/wicket/util/tester/FormTester.java
+++ b/wicket-tester/src/main/java/org/apache/wicket/util/tester/FormTester.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
@@ -52,14 +53,17 @@ import org.apache.wicket.util.visit.IVisitor;
/**
* A helper class for testing validation and submission of <code>FormComponent</code>s.
- *
+ *
* @author Ingram Chen
* @author Frank Bille (frankbille)
* @since 1.2.6
*/
public class FormTester
{
- /**
+ private static final String NO_FORM_FOR_PATH = "No Form componet found for path '%s'. Check if path value is correct and "
+ + "if form component is visible and active.";
+
+ /**
* An auto incrementing index used as a suffix for MultiFileUploadField's inputName
*/
private int multiFileUploadIndex = 0;
@@ -380,9 +384,9 @@ public class FormTester
protected FormTester(final String path, final Form<?> workingForm,
final BaseWicketTester wicketTester, final boolean fillBlankString)
{
- this.path = path;
- this.workingForm = workingForm;
- tester = wicketTester;
+ this.workingForm = Objects.requireNonNull(workingForm, String.format(NO_FORM_FOR_PATH, path));
+ this.tester = wicketTester;
+ this.path = path;
// fill blank String for Text Component.
workingForm.visitFormComponents(new IVisitor<FormComponent<?>, Void>()