use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormSubmitTest method allFormsEnabledSubmitMiddleForm.
/**
*/
@Test
public void allFormsEnabledSubmitMiddleForm() {
assertEnabledState(true, true, true);
FormTester formTester = tester.newFormTester("outerForm:middleForm");
formTester.submit("submit");
assertOnSubmitCalled(false, true, true);
assertOnErrorCalled(false, false, false);
assertSubmitOrder(innerForm, middleForm);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormSubmitTest method middleFormDisabledSubmitOuterForm.
/**
*/
@Test
public void middleFormDisabledSubmitOuterForm() {
// disable middle form
middleForm.setEnabled(false);
assertEnabledState(true, false, true);
// submit outer form
FormTester formTester = tester.newFormTester("outerForm");
formTester.submit("submit");
assertOnSubmitCalled(true, false, false);
assertOnErrorCalled(false, false, false);
assertSubmitOrder(outerForm);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormSubmitTest method submitDisabledOuterForm.
/**
*/
@Test
public void submitDisabledOuterForm() {
outerForm.setEnabled(false);
assertEnabledState(false, true, true);
FormTester formTester = tester.newFormTester("outerForm");
try {
formTester.submit("submit");
fail("Executing the listener on disabled component is not allowed.");
} catch (ListenerInvocationNotAllowedException expected) {
;
}
assertOnSubmitCalled(false, false, false);
assertOnErrorCalled(false, false, false);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormValidationDisabledFormComponentTest method formSubmitsEvenWithInvalidButDisabledFormComponent.
@Test
public void formSubmitsEvenWithInvalidButDisabledFormComponent() {
TestPage page = tester.startPage(TestPage.class);
assertFalse(page.onSubmitCalled.get());
assertFalse(page.onErrorCalled.get());
FormTester formTester = tester.newFormTester(page.form.getPageRelativePath());
formTester.submit();
assertTrue(page.field1.hasErrorMessage());
assertFalse(page.onSubmitCalled.get());
assertTrue(page.onErrorCalled.get());
page.onErrorCalled.set(false);
page.field1.setEnabled(false);
formTester = tester.newFormTester(page.form.getPageRelativePath());
formTester.submit();
assertTrue(page.field1.hasErrorMessage());
assertTrue(page.onSubmitCalled.get());
assertFalse(page.onErrorCalled.get());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormValidationTest method renderedFeedbackMessages.
/**
* Tests validation of form components when all errors are rendered using a feedback panel.
*
* Validation status depends on whether or not a form component has error messages, here we test
* submission roundtrip in a usecase where all error messages are rendered and cleared at the
* end of the request.
*/
@Test
public void renderedFeedbackMessages() {
// start the page
TestPage page = new TestPage();
scope.getTester().startPage(page);
// submit the form without filling out any values
FormTester formTester = scope.getTester().newFormTester(page.form.getPageRelativePath());
formTester.setClearFeedbackMessagesBeforeSubmit(true);
formTester.submit();
// the first required form component should fail and so should the form
assertTrue(page.form.hasError());
assertFalse(page.field1.isValid());
// fill out a value and submit again
formTester = scope.getTester().newFormTester(page.form.getPageRelativePath());
formTester.setValue(page.field1, "hi");
formTester.setClearFeedbackMessagesBeforeSubmit(true);
formTester.submit();
// now the form and the form component should be valid
assertFalse(page.form.hasError());
assertTrue(page.field1.isValid());
}
Aggregations