use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class OnValidateModelObjectsTest method onValidateModelObjects.
/**
* Asserts that submitting the outer form will call {@link Form#onValidateModelObjects()}
* for both the outer form and the inner form(s)
*/
@Test
public void onValidateModelObjects() {
tester.startPage(OnFormValidateModelObjectsPage.class);
FormTester formTester = tester.newFormTester("parentForm");
formTester.submit("parentSubmitBtn");
Page page = tester.getLastRenderedPage();
OnFormValidateModelObjectsPage.ParentModel parentModel = (OnFormValidateModelObjectsPage.ParentModel) page.getDefaultModelObject();
assertThat(parentModel.isParentValidated(), is(true));
AddressFormPanel.ChildModel childPanel = (AddressFormPanel.ChildModel) page.get("parentForm:addressInfo").getDefaultModelObject();
assertThat(childPanel.isChildValidated(), is(true));
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TextFieldTest method emptyInputConvertedToNull.
/**
*/
@Test
public void emptyInputConvertedToNull() {
TestPage testPage = new TestPage();
testPage.textField.setType(String.class);
testPage.textField.setConvertEmptyInputStringToNull(true);
tester.startPage(testPage);
FormTester formTester = tester.newFormTester(testPage.form.getId());
formTester.setValue(testPage.textField.getId(), "");
formTester.submit();
assertEquals(null, testPage.textField.getDefaultModelObject());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TestHomePage method testWithBorder2.
@Test
public void testWithBorder2() {
FormTester formTester = tester.newFormTester("border:form");
// formTester.setValue("..:textfield1", "testxxx");
@SuppressWarnings("unchecked") TextField<String> textfield = (TextField<String>) tester.getLastRenderedPage().get("border:form:border_body:textfield");
tester.getRequest().getPostParameters().setParameterValue(textfield.getInputName(), "abcde");
MyTextField datefield = (MyTextField) tester.getLastRenderedPage().get("border:form:border_body:datefield");
tester.getRequest().getPostParameters().setParameterValue(datefield.getInputName(), "aaabbb");
MyDateField datefield2 = (MyDateField) tester.getLastRenderedPage().get("border:form:border_body:datefield2");
@SuppressWarnings("unchecked") TextField<String> date = (TextField<String>) datefield2.get("date");
tester.getRequest().getPostParameters().setParameterValue(date.getInputName(), "abcdef");
formTester.submit();
tester.assertNoErrorMessage();
HomePage page = (HomePage) tester.getLastRenderedPage();
assertEquals("abcde", page.getTextfield());
assertEquals("aaabbb-converted", page.getDatefield());
assertEquals("abcdef-converted", page.getDatefield2());
assertEquals("abcde", page.get("border:form:border_body:lbltextfield").getDefaultModelObjectAsString());
assertEquals("aaabbb-converted", page.get("border:form:border_body:lbldatefield").getDefaultModelObjectAsString());
assertEquals("abcdef-converted", page.get("border:form:border_body:lbldatefield2").getDefaultModelObjectAsString());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TestHomePage_2134 method testRenderMyPage.
/**
* WICKET-2134: two forms inside a border throw a ConversionException error
*/
@Test
public void testRenderMyPage() {
// start and render the test page
tester.startPage(CommonModelPage.class);
// assert rendered page class
tester.assertRenderedPage(CommonModelPage.class);
FormTester formTester = tester.newFormTester("border:border_body:form1");
formTester.submit();
CommonModelPage page = (CommonModelPage) tester.getLastRenderedPage();
assertEquals(0, page.quantity1);
assertEquals(0, page.quantity2);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TestHomePage_2134 method testRenderMyPage2.
/**
* WICKET-2134: two forms inside a border throw a ConversionException error
*/
@Test
public void testRenderMyPage2() {
// start and render the test page
tester.startPage(CommonModelPage.class);
// assert rendered page class
tester.assertRenderedPage(CommonModelPage.class);
FormTester formTester = tester.newFormTester("border:border_body:form1");
formTester.setValue("quantity1", "123");
// formTester.setValue("quantity2", "44");
formTester.submit();
CommonModelPage page = (CommonModelPage) tester.getLastRenderedPage();
assertEquals(123, page.quantity1);
assertEquals(0, page.quantity2);
}
Aggregations