You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/03/08 14:59:40 UTC

svn commit: r516045 - in /incubator/wicket: branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/ branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ trunk/wicket/src/main/java/wicket/util/tester/ trunk/wicket/src/test/java/wicke...

Author: jbq
Date: Thu Mar  8 05:59:39 2007
New Revision: 516045

URL: http://svn.apache.org/viewvc?view=rev&rev=516045
Log:
WICKET-258 FormTester doesn't pass form components default values

Modified:
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/FormTester.java
    incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html
    incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java
    incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java
    incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
    incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html
    incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java
    incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/FormTester.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/FormTester.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/FormTester.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/tester/FormTester.java Thu Mar  8 05:59:39 2007
@@ -19,6 +19,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -30,6 +31,7 @@
 import wicket.Component.IVisitor;
 import wicket.markup.html.form.AbstractTextComponent;
 import wicket.markup.html.form.Check;
+import wicket.markup.html.form.CheckBox;
 import wicket.markup.html.form.CheckGroup;
 import wicket.markup.html.form.DropDownChoice;
 import wicket.markup.html.form.Form;
@@ -352,7 +354,7 @@
 		// fill blank String for Text Component.
 		workingForm.visitFormComponents(new FormComponent.AbstractVisitor()
 		{
-			public void onFormComponent(FormComponent formComponent)
+			public void onFormComponent(final FormComponent formComponent)
 			{
 				// do nothing for invisible component
 				if (!formComponent.isVisibleInHierarchy())
@@ -375,6 +377,35 @@
 					{
 						setFormComponentValue(formComponent, formComponent.getValue());
 					}
+				}
+				else if ( (formComponent instanceof DropDownChoice) ||
+						  (formComponent instanceof RadioChoice) ||
+						  (formComponent instanceof CheckBox))
+				{
+					setFormComponentValue(formComponent, formComponent.getValue());
+				}
+				else if (formComponent instanceof ListMultipleChoice)
+				{
+					final String[] modelValues = formComponent.getValue().split(FormComponent.VALUE_SEPARATOR);
+					for (int i = 0; i < modelValues.length; i++)
+					{
+						addFormComponentValue(formComponent, modelValues[i]);
+					}
+				}
+				else if (formComponent instanceof CheckGroup)
+				{
+					final Collection checkGroupValues = (Collection) formComponent.getModelObject();
+					formComponent.visitChildren(Check.class, new IVisitor()
+					{
+						public Object component(Component component)
+						{
+							if (checkGroupValues.contains(component.getModelObject()))
+							{
+								addFormComponentValue(formComponent, ((Check) component).getValue());
+							}
+							return CONTINUE_TRAVERSAL;
+						}
+					});
 				}
 			}
 

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html Thu Mar  8 05:59:39 2007
@@ -7,11 +7,15 @@
   	<select wicket:id="listChoice"><option>1</option></select><br/>
     <span wicket:id="radioChoice"><input type="radio" />1</span><br/>
 	<span wicket:id="radioGroup"><span wicket:id="loop"><input type="radio" wicket:id="radio" />1</span></span><br/>
+	<input wicket:id="checkBox" type="checkbox"/>
 
-  	<select wicket:id="listMultipleChoice" ><option>1</option></select><br/>
+	<select wicket:id="initialListMultipleChoice" ><option>1</option></select><br/>
+	<select wicket:id="initialCheckBoxMultipleChoice" ><option>1</option></select><br/>
+	<span wicket:id="initialCheckGroup"><span wicket:id="loop"><input type="checkbox" wicket:id="check" />1</span></span><br/>
+	<select wicket:id="listMultipleChoice" ><option>1</option></select><br/>
     <span wicket:id="checkBoxMultipleChoice"><input type="checkbox"/>1</span><br/>
 	<span wicket:id="checkGroup"><span wicket:id="loop"><input type="checkbox" wicket:id="check" />1</span></span><br/>
 	<input wicket:id="anotherButton" type="submit" />
   </form>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java Thu Mar  8 05:59:39 2007
@@ -22,6 +22,7 @@
 import wicket.markup.html.WebPage;
 import wicket.markup.html.form.Button;
 import wicket.markup.html.form.Check;
+import wicket.markup.html.form.CheckBox;
 import wicket.markup.html.form.CheckBoxMultipleChoice;
 import wicket.markup.html.form.CheckGroup;
 import wicket.markup.html.form.ChoiceRenderer;
@@ -47,22 +48,34 @@
 
 	/** test DropDownChoice */
 	public Book dropDownChoice;
-	
+
 	/** test ListChoice */
 	public Book listChoice;
-	
+
 	/** test RadioChoice */
 	public Book radioChoice;
 
 	/** test RadioChoice */
 	public Book radioGroup;
 
+	/** test CheckBox initial value */
+	public boolean checkBox;
+
+	/** test CheckGroup initial value */
+	public final List initialCheckGroup = new ArrayList();
+
+	/** test ListMultipleChoice initial values */
+	public final List initialListMultipleChoice = new ArrayList();
+
+	/** test CheckBoxMultipleChoice initial values */
+	public List initialCheckBoxMultipleChoice = new ArrayList();
+
 	/** test CheckBoxMultipleChoice */
 	public List checkBoxMultipleChoice = new ArrayList();
 
 	/** test CheckGroup */
 	public List checkGroup = new ArrayList();
-	
+
 	/** test ListMultipleChoice */
 	public List listMultipleChoice = new ArrayList();
 
@@ -83,18 +96,34 @@
 
 		form.setModel(new CompoundPropertyModel(this));
 
+		// setting initial values
+		dropDownChoice = (Book) candidateChoices.get(1);
+		listChoice = (Book) candidateChoices.get(3);
+		radioChoice = (Book) candidateChoices.get(2);
+		checkBox = true;
+		initialListMultipleChoice.add(candidateChoices.get(1));
+		initialListMultipleChoice.add(candidateChoices.get(2));
+		initialCheckBoxMultipleChoice.add(candidateChoices.get(0));
+		initialCheckBoxMultipleChoice.add(candidateChoices.get(3));
+		initialCheckGroup.add(candidateChoices.get(2));
+		initialCheckGroup.add(candidateChoices.get(3));
+
 		// single select family
 		form.add(new DropDownChoice("dropDownChoice", candidateChoices, bookChoiceRenderer));
 		form.add(new ListChoice("listChoice", candidateChoices, bookChoiceRenderer).setMaxRows(4));
 		form.add(new RadioChoice("radioChoice", candidateChoices, bookChoiceRenderer));
+		form.add(new CheckBox("checkBox"));
 		form.add(newRadioGroup(candidateChoices));
 
-		// mulitple select family
+		// multiple select family
+		form.add(new ListMultipleChoice("initialListMultipleChoice", candidateChoices, bookChoiceRenderer));
+		form.add(new CheckBoxMultipleChoice("initialCheckBoxMultipleChoice", candidateChoices, bookChoiceRenderer));
+		form.add(newCheckGroup("initialCheckGroup", candidateChoices));
 		form.add(new ListMultipleChoice("listMultipleChoice", candidateChoices, bookChoiceRenderer)
 				.setMaxRows(4));
 		form.add(new CheckBoxMultipleChoice("checkBoxMultipleChoice", candidateChoices,
 				bookChoiceRenderer));
-		form.add(newCheckGroup(candidateChoices));
+		form.add(newCheckGroup("checkGroup", candidateChoices));
 		form.add(new Button("anotherButton")
 		{
 			private static final long serialVersionUID = 1L;
@@ -106,9 +135,9 @@
 		});
 	}
 
-	private CheckGroup newCheckGroup(List candidateChoices)
+	private CheckGroup newCheckGroup(final String id, List candidateChoices)
 	{
-		CheckGroup checkGroupComponent = new CheckGroup("checkGroup");
+		CheckGroup checkGroupComponent = new CheckGroup(id);
 		ListView listView = new ListView("loop", candidateChoices)
 		{
 			private static final long serialVersionUID = 1L;

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java Thu Mar  8 05:59:39 2007
@@ -71,6 +71,10 @@
 	 */
 	public void testSingleChoice() throws Exception
 	{
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(books[3], choicePage.listChoice);
+		assertSame(books[2], choicePage.radioChoice);
+		assertSame(null, choicePage.radioGroup);
 		formTester.select("dropDownChoice", 0);
 		formTester.select("listChoice", 2);
 		formTester.select("radioChoice", 1);
@@ -87,6 +91,8 @@
 	 */
 	public void testSingleChoice_toggle() throws Exception
 	{
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(null, choicePage.radioGroup);
 		formTester.select("dropDownChoice", 0);
 		formTester.select("dropDownChoice", 1);// toggle to 1
 		formTester.select("radioGroup", 3);
@@ -125,6 +131,9 @@
 	 */
 	public void testSelectMultiple() throws Exception
 	{
+		assertBooksEquals(new Book[0], choicePage.listMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkBoxMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkGroup);
 		formTester.selectMultiple("listMultipleChoice", new int[] { 0, 3 });
 		formTester.selectMultiple("checkBoxMultipleChoice", new int[] { 1, 0, 3 });
 		formTester.selectMultiple("checkGroup", new int[] { 0, 1, 2, 3 });
@@ -141,6 +150,8 @@
 	 */
 	public void testMultipleChoiceComponent_cumulate() throws Exception
 	{
+		assertBooksEquals(new Book[0], choicePage.listMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkGroup);
 		formTester.select("listMultipleChoice", 0);
 		formTester.selectMultiple("listMultipleChoice", new int[] { 0, 3 });
 		formTester.selectMultiple("listMultipleChoice", new int[] { 1 });
@@ -172,5 +183,21 @@
 		formTester = tester.newFormTester("choiceForm");
 		formTester.submit("anotherButton");
 		assertTrue(choicePage.anotherButtonPressed);
+	}
+
+	public void testInitialValues()
+	{
+		assertInitialValues();
+		formTester.submit();
+		assertInitialValues();
+	}
+	private void assertInitialValues() {
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(books[3], choicePage.listChoice);
+		assertSame(books[2], choicePage.radioChoice);
+		assertEquals(true, choicePage.checkBox);
+		assertBooksEquals(new Book[]{books[2], books[1]}, choicePage.initialListMultipleChoice);
+		assertBooksEquals(new Book[]{books[3], books[0]}, choicePage.initialCheckBoxMultipleChoice);
+		assertBooksEquals(new Book[]{books[3], books[2]}, choicePage.initialCheckGroup);
 	}
 }

Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/util/tester/FormTester.java Thu Mar  8 05:59:39 2007
@@ -19,6 +19,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -30,6 +31,7 @@
 import wicket.Component.IVisitor;
 import wicket.markup.html.form.AbstractTextComponent;
 import wicket.markup.html.form.Check;
+import wicket.markup.html.form.CheckBox;
 import wicket.markup.html.form.CheckGroup;
 import wicket.markup.html.form.DropDownChoice;
 import wicket.markup.html.form.Form;
@@ -356,7 +358,7 @@
 		workingForm.visitFormComponents(new FormComponent.AbstractVisitor()
 		{
 			@Override
-			public void onFormComponent(FormComponent formComponent)
+			public void onFormComponent(final FormComponent formComponent)
 			{
 				// do nothing for invisible component
 				if (!formComponent.isVisibleInHierarchy())
@@ -379,6 +381,35 @@
 					{
 						setFormComponentValue(formComponent, formComponent.getValue());
 					}
+				}
+				else if ( (formComponent instanceof DropDownChoice) ||
+						  (formComponent instanceof RadioChoice) ||
+						  (formComponent instanceof CheckBox))
+				{
+					setFormComponentValue(formComponent, formComponent.getValue());
+				}
+				else if (formComponent instanceof ListMultipleChoice)
+				{
+					final String[] modelValues = formComponent.getValue().split(FormComponent.VALUE_SEPARATOR);
+					for (int i = 0; i < modelValues.length; i++)
+					{
+						addFormComponentValue(formComponent, modelValues[i]);
+					}
+				}
+				else if (formComponent instanceof CheckGroup)
+				{
+					final Collection checkGroupValues = (Collection) formComponent.getModelObject();
+					formComponent.visitChildren(Check.class, new IVisitor()
+					{
+						public Object component(Component component)
+						{
+							if (checkGroupValues.contains(component.getModelObject()))
+							{
+								addFormComponentValue(formComponent, ((Check) component).getValue());
+							}
+							return CONTINUE_TRAVERSAL;
+						}
+					});
 				}
 			}
 

Modified: incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html (original)
+++ incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.html Thu Mar  8 05:59:39 2007
@@ -7,11 +7,15 @@
   	<select wicket:id="listChoice"><option>1</option></select><br/>
     <span wicket:id="radioChoice"><input type="radio" />1</span><br/>
 	<span wicket:id="radioGroup"><span wicket:id="loop"><input type="radio" wicket:id="radio" />1</span></span><br/>
+	<input wicket:id="checkBox" type="checkbox"/>
 
-  	<select wicket:id="listMultipleChoice" ><option>1</option></select><br/>
+	<select wicket:id="initialListMultipleChoice" ><option>1</option></select><br/>
+	<select wicket:id="initialCheckBoxMultipleChoice" ><option>1</option></select><br/>
+	<span wicket:id="initialCheckGroup"><span wicket:id="loop"><input type="checkbox" wicket:id="check" />1</span></span><br/>
+	<select wicket:id="listMultipleChoice" ><option>1</option></select><br/>
     <span wicket:id="checkBoxMultipleChoice"><input type="checkbox"/>1</span><br/>
 	<span wicket:id="checkGroup"><span wicket:id="loop"><input type="checkbox" wicket:id="check" />1</span></span><br/>
 	<input wicket:id="anotherButton" type="submit" />
   </form>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java (original)
+++ incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/ChoicePage.java Thu Mar  8 05:59:39 2007
@@ -22,6 +22,7 @@
 import wicket.markup.html.WebPage;
 import wicket.markup.html.form.Button;
 import wicket.markup.html.form.Check;
+import wicket.markup.html.form.CheckBox;
 import wicket.markup.html.form.CheckBoxMultipleChoice;
 import wicket.markup.html.form.CheckGroup;
 import wicket.markup.html.form.ChoiceRenderer;
@@ -58,6 +59,18 @@
 	/** test RadioChoice */
 	public Book radioGroup;
 
+	/** test CheckBox initial value */
+	public boolean checkBox;
+
+	/** test CheckGroup initial value */
+	public final List initialCheckGroup = new ArrayList();
+
+	/** test ListMultipleChoice initial values */
+	public final List initialListMultipleChoice = new ArrayList();
+
+	/** test CheckBoxMultipleChoice initial values */
+	public List initialCheckBoxMultipleChoice = new ArrayList();
+
 	/** test CheckBoxMultipleChoice */
 	public List<String> checkBoxMultipleChoice = new ArrayList<String>();
 
@@ -83,19 +96,35 @@
 
 		form.setModel(new CompoundPropertyModel<ChoicePage>(this));
 
+		// setting initial values
+		dropDownChoice = (Book) candidateChoices.get(1);
+		listChoice = (Book) candidateChoices.get(3);
+		radioChoice = (Book) candidateChoices.get(2);
+		checkBox = true;
+		initialListMultipleChoice.add(candidateChoices.get(1));
+		initialListMultipleChoice.add(candidateChoices.get(2));
+		initialCheckBoxMultipleChoice.add(candidateChoices.get(0));
+		initialCheckBoxMultipleChoice.add(candidateChoices.get(3));
+		initialCheckGroup.add(candidateChoices.get(2));
+		initialCheckGroup.add(candidateChoices.get(3));
+
 		// single select family
 		new DropDownChoice<Book>(form, "dropDownChoice", candidateChoices, bookChoiceRenderer);
 		new ListChoice<Book>(form, "listChoice", candidateChoices, bookChoiceRenderer)
 				.setMaxRows(4);
 		new RadioChoice<Book>(form, "radioChoice", candidateChoices, bookChoiceRenderer);
+		new CheckBox(form, "checkBox");
 		newRadioGroup(form, candidateChoices);
 
-		// mulitple select family
-		new ListMultipleChoice<Book>(form, "listMultipleChoice", candidateChoices,
-				bookChoiceRenderer).setMaxRows(4);
-		new CheckBoxMultipleChoice<Book>(form, "checkBoxMultipleChoice", candidateChoices,
+		// multiple select family
+		new ListMultipleChoice(form, "initialListMultipleChoice", candidateChoices, bookChoiceRenderer);
+		new CheckBoxMultipleChoice(form, "initialCheckBoxMultipleChoice", candidateChoices, bookChoiceRenderer);
+		newCheckGroup(form, "initialCheckGroup", candidateChoices);
+		new ListMultipleChoice(form, "listMultipleChoice", candidateChoices, bookChoiceRenderer)
+				.setMaxRows(4);
+		new CheckBoxMultipleChoice(form, "checkBoxMultipleChoice", candidateChoices,
 				bookChoiceRenderer);
-		newCheckGroup(form, candidateChoices);
+		newCheckGroup(form, "checkGroup", candidateChoices);
 		new Button(form, "anotherButton")
 		{
 			private static final long serialVersionUID = 1L;
@@ -108,9 +137,9 @@
 		};
 	}
 
-	private CheckGroup newCheckGroup(Form parent, List<Book> candidateChoices)
+	private CheckGroup newCheckGroup(Form parent, String id, List<Book> candidateChoices)
 	{
-		CheckGroup checkGroupComponent = new CheckGroup(parent, "checkGroup");
+		CheckGroup checkGroupComponent = new CheckGroup(parent, id);
 		new ListView<Book>(checkGroupComponent, "loop", candidateChoices)
 		{
 			private static final long serialVersionUID = 1L;

Modified: incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java?view=diff&rev=516045&r1=516044&r2=516045
==============================================================================
--- incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java (original)
+++ incubator/wicket/trunk/wicket/src/test/java/wicket/util/tester/apps_3/FormTesterTest.java Thu Mar  8 05:59:39 2007
@@ -72,6 +72,10 @@
 	 */
 	public void testSingleChoice() throws Exception
 	{
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(books[3], choicePage.listChoice);
+		assertSame(books[2], choicePage.radioChoice);
+		assertSame(null, choicePage.radioGroup);
 		formTester.select("dropDownChoice", 0);
 		formTester.select("listChoice", 2);
 		formTester.select("radioChoice", 1);
@@ -88,6 +92,8 @@
 	 */
 	public void testSingleChoice_toggle() throws Exception
 	{
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(null, choicePage.radioGroup);
 		formTester.select("dropDownChoice", 0);
 		formTester.select("dropDownChoice", 1);// toggle to 1
 		formTester.select("radioGroup", 3);
@@ -126,6 +132,9 @@
 	 */
 	public void testSelectMultiple() throws Exception
 	{
+		assertBooksEquals(new Book[0], choicePage.listMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkBoxMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkGroup);
 		formTester.selectMultiple("listMultipleChoice", new int[] { 0, 3 });
 		formTester.selectMultiple("checkBoxMultipleChoice", new int[] { 1, 0, 3 });
 		formTester.selectMultiple("checkGroup", new int[] { 0, 1, 2, 3 });
@@ -142,6 +151,8 @@
 	 */
 	public void testMultipleChoiceComponent_cumulate() throws Exception
 	{
+		assertBooksEquals(new Book[0], choicePage.listMultipleChoice);
+		assertBooksEquals(new Book[0], choicePage.checkGroup);
 		formTester.select("listMultipleChoice", 0);
 		formTester.selectMultiple("listMultipleChoice", new int[] { 0, 3 });
 		formTester.selectMultiple("listMultipleChoice", new int[] { 1 });
@@ -173,5 +184,21 @@
 		formTester = tester.newFormTester("choiceForm");
 		formTester.submit("anotherButton");
 		assertTrue(choicePage.anotherButtonPressed);
+	}
+
+	public void testInitialValues()
+	{
+		assertInitialValues();
+		formTester.submit();
+		assertInitialValues();
+	}
+	private void assertInitialValues() {
+		assertSame(books[1], choicePage.dropDownChoice);
+		assertSame(books[3], choicePage.listChoice);
+		assertSame(books[2], choicePage.radioChoice);
+		assertEquals(true, choicePage.checkBox);
+		assertBooksEquals(new Book[]{books[2], books[1]}, choicePage.initialListMultipleChoice);
+		assertBooksEquals(new Book[]{books[3], books[0]}, choicePage.initialCheckBoxMultipleChoice);
+		assertBooksEquals(new Book[]{books[3], books[2]}, choicePage.initialCheckGroup);
 	}
 }