formatting
fixed jdk1.5 dep
git-svn-id: https://svn.apache.org/repos/asf/incubator/wicket/trunk@457909 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/wicket/src/test/wicket/markup/html/form/CheckGroupTest.java b/wicket/src/test/wicket/markup/html/form/CheckGroupTest.java
index 44a7627..863d386 100644
--- a/wicket/src/test/wicket/markup/html/form/CheckGroupTest.java
+++ b/wicket/src/test/wicket/markup/html/form/CheckGroupTest.java
@@ -1,6 +1,6 @@
/*
- * $Id$
- * $Revision$ $Date$
+ * $Id$ $Revision:
+ * 1.2 $ $Date$
*
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -35,8 +35,9 @@
/**
* Test for RadioGroup and Radio components
+ *
* @author igor
- *
+ *
*/
public class CheckGroupTest extends WicketTestCase
{
@@ -59,10 +60,10 @@
public static class MockModelObject implements Serializable
{
private static final long serialVersionUID = 1L;
-
- private Set prop1=new HashSet();
+
+ private Set prop1 = new HashSet();
private String prop2;
-
+
/**
* @return prop1
*/
@@ -94,8 +95,7 @@
{
this.prop2 = prop2;
}
-
-
+
}
@@ -110,20 +110,20 @@
MockModelObject modelObject = new MockModelObject();
modelObject.setProp2(check2);
-
+
// test model constructors
- List list=new ArrayList();
- Model model=new Model((Serializable)list);
+ List list = new ArrayList();
+ Model model = new Model((Serializable)list);
- final CheckGroup group2=new CheckGroup("group2", model);
- assertTrue(group2.getModelObject()==list);
+ final CheckGroup group2 = new CheckGroup("group2", model);
+ assertTrue(group2.getModelObject() == list);
- final CheckGroup group3=new CheckGroup("group3", list);
- assertTrue(group3.getModelObject()==list);
+ final CheckGroup group3 = new CheckGroup("group3", list);
+ assertTrue(group3.getModelObject() == list);
-
+
// set up necessary objects to emulate a form submission
-
+
RequestCycle cycle = application.createRequestCycle();
MockPage page = new MockPage(new PageParameters());
@@ -131,7 +131,7 @@
page.getSession().setRequestCycle(cycle);
// create component hierarchy
-
+
final Form form = new Form("form", new CompoundPropertyModel(modelObject));
final CheckGroup group = new CheckGroup("prop1");
@@ -140,7 +140,7 @@
final Check choice1 = new Check("check1", new Model(check1));
final Check choice2 = new Check("prop2");
-
+
page.add(form);
form.add(group);
group.add(container);
@@ -148,42 +148,51 @@
group.add(choice2);
// test mock form submissions
-
+
modelObject.getProp1().add(check1);
-
+
form.onFormSubmitted();
- assertTrue("running with nothing selected - model must be empty", modelObject
- .getProp1().size()==0);
+ assertTrue("running with nothing selected - model must be empty", modelObject.getProp1()
+ .size() == 0);
application.getServletRequest().setParameter(group.getInputName(), choice1.getPath());
form.onFormSubmitted();
assertTrue("running with choice1 selected - model must only contain value of check1",
- modelObject.getProp1().size()==1&&modelObject.getProp1().contains(check1));
+ modelObject.getProp1().size() == 1 && modelObject.getProp1().contains(check1));
application.getServletRequest().setParameter(group.getInputName(), choice2.getPath());
form.onFormSubmitted();
assertTrue("running with choice2 selected - model must only contain value of check2",
- modelObject.getProp1().size()==1&&modelObject.getProp1().contains(check2));
+ modelObject.getProp1().size() == 1 && modelObject.getProp1().contains(check2));
- // throw in some nulls into the request param to make sure they are ignored
- application.getServletRequest().getParameterMap().put(group.getInputName(), new String[] {null, choice1.getPath(),null, choice2.getPath()});
+ // throw in some nulls into the request param to make sure they are
+ // ignored
+ application.getServletRequest().getParameterMap().put(group.getInputName(),
+ new String[] { null, choice1.getPath(), null, choice2.getPath() });
form.onFormSubmitted();
- assertTrue("running with choice1 and choice2 selected - model must only contain values of check1 and check2",
- modelObject.getProp1().size()==2&&modelObject.getProp1().contains(check2)&&modelObject.getProp1().contains(check1));
+ assertTrue(
+ "running with choice1 and choice2 selected - model must only contain values of check1 and check2",
+ modelObject.getProp1().size() == 2 && modelObject.getProp1().contains(check2)
+ && modelObject.getProp1().contains(check1));
- application.getServletRequest().getParameterMap().put(group.getInputName(), new String[] {"some weird path to test error"});
- try {
+ application.getServletRequest().getParameterMap().put(group.getInputName(),
+ new String[] { "some weird path to test error" });
+ try
+ {
form.onFormSubmitted();
fail("running with an invalid choice value in the request param, should fail");
- } catch (WicketRuntimeException e) {
-
+ }
+ catch (WicketRuntimeException e)
+ {
+
}
-
+
}
/**
* test component rendering
+ *
* @throws Exception
*/
public void testRendering() throws Exception
@@ -192,11 +201,16 @@
executeTest(CheckGroupTestPage2.class, "CheckGroupTestPage2_expected.html");
executeTest(CheckGroupTestPage3.class, "CheckGroupTestPage3_expected.html");
executeTest(CheckGroupTestPage4.class, "CheckGroupTestPage4_expected.html");
- try {
+ try
+ {
executeTest(CheckGroupTestPage5.class, "");
fail("this will always fail");
- } catch (WicketRuntimeException e) {
- if (!e.getMessage().contains("Check component [4:form:check2] cannot find its parent CheckGroup")) {
+ }
+ catch (WicketRuntimeException e)
+ {
+ if (e.getMessage().indexOf(
+ "Check component [4:form:check2] cannot find its parent CheckGroup") < 0)
+ {
fail("failed with wrong exception");
}
diff --git a/wicket/src/test/wicket/markup/html/form/RadioGroupTest.java b/wicket/src/test/wicket/markup/html/form/RadioGroupTest.java
index 5661d0b..7709648 100644
--- a/wicket/src/test/wicket/markup/html/form/RadioGroupTest.java
+++ b/wicket/src/test/wicket/markup/html/form/RadioGroupTest.java
@@ -59,7 +59,7 @@
private String prop1;
private String prop2;
-
+
/**
* @return prop1
*/
@@ -156,7 +156,8 @@
form.onFormSubmitted();
assertEquals("group: running with choice1 selected - model must be set to value of radio1",
modelObject.getProp1(), choice1.getModelObject());
- assertEquals("group2: running with choice3 selected - model must be set to value of radio1",
+ assertEquals(
+ "group2: running with choice3 selected - model must be set to value of radio1",
model.getObject(null), choice3.getModelObject());
application.getServletRequest().setParameter(group.getInputName(), choice2.getPath());
@@ -165,13 +166,16 @@
modelObject.getProp1(), choice2.getModelObject());
application.getServletRequest().setParameter(group2.getInputName(), choice1.getPath());
- try {
+ try
+ {
form.onFormSubmitted();
fail("group2: ran with an invalid choice selected but did not fail");
- } catch (WicketRuntimeException e) {
-
}
-
+ catch (WicketRuntimeException e)
+ {
+
+ }
+
}
/**
@@ -182,11 +186,16 @@
public void testRendering() throws Exception
{
executeTest(RadioGroupTestPage1.class, "RadioGroupTestPage1_expected.html");
- try {
+ try
+ {
executeTest(RadioGroupTestPage2.class, "");
fail("the rendering of page above must fail because radio2 component is not under any group");
- } catch (WicketRuntimeException e) {
- if (!e.getMessage().contains("Radio component [1:form:radio2] cannot find its parent RadioGroup")) {
+ }
+ catch (WicketRuntimeException e)
+ {
+ if (e.getMessage().indexOf(
+ "Radio component [1:form:radio2] cannot find its parent RadioGroup") < 0)
+ {
fail("failed with wrong exception");
}
}