wicket-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thran...@apache.org
Subject svn commit: r722112 - in /wicket/trunk/wicket/src: main/java/org/apache/wicket/util/tester/FormTester.java test/java/org/apache/wicket/util/tester/FormTesterTest.java
Date Mon, 01 Dec 2008 16:12:38 GMT
Author: thrantal
Date: Mon Dec  1 08:12:38 2008
New Revision: 722112

URL: http://svn.apache.org/viewvc?rev=722112&view=rev
Log:
WICKET-1893 : added an overloaded version of setValue() that takes a boolean, because this
makes discovering how to use FormTester with CheckBoxes easier.

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java?rev=722112&r1=722111&r2=722112&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java Mon Dec
 1 08:12:38 2008
@@ -27,8 +27,8 @@
 import java.util.Map;
 
 import org.apache.wicket.Component;
-import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.Component.IVisitor;
+import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.html.form.AbstractTextComponent;
 import org.apache.wicket.markup.html.form.Check;
 import org.apache.wicket.markup.html.form.CheckBox;
@@ -579,6 +579,11 @@
 		}
 	}
 
+	public void setValue(String checkBoxId, boolean value)
+	{
+		setValue(checkBoxId, Boolean.toString(value));
+	}
+
 	/**
 	 * Sets the <code>File</code> on a {@link FileUploadField}.
 	 * 

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java?rev=722112&r1=722111&r2=722112&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java Mon
Dec  1 08:12:38 2008
@@ -68,6 +68,25 @@
 		assertTrue(domainObject.isCheckbox());
 	}
 
+	public void testCheckboxValuesCanBeSelectedWithBoolean()
+	{
+		tester.startPage(MockFormPage.class);
+		MockFormPage page = (MockFormPage)tester.getLastRenderedPage();
+		MockDomainObject domainObject = page.getDomainObject();
+		assertFalse(domainObject.isCheckbox());
+
+		FormTester formTester = tester.newFormTester("form");
+		formTester.setValue("checkbox", true);
+		formTester.submit();
+		assertTrue(domainObject.isCheckbox());
+
+		formTester = tester.newFormTester("form");
+		formTester.setValue("checkbox", false);
+		formTester.submit();
+		assertFalse(domainObject.isCheckbox());
+	}
+
+
 	/**
 	 * Test that the user can use
 	 * {@link FormTester#setFile(String, org.apache.wicket.util.file.File, String)} to test
that



Mime
View raw message