use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormMethodMismatchTest method formSubmittedAbortsByWithMismatchingMethodWhenDesired.
@Test
public void formSubmittedAbortsByWithMismatchingMethodWhenDesired() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
@Override
protected MethodMismatchResponse onMethodMismatch() {
return MethodMismatchResponse.ABORT;
}
};
tester.startPage(new PlainFormPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit();
assertFalse(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormMethodMismatchTest method withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.
@Test
public void withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
@Override
protected MethodMismatchResponse onMethodMismatch() {
return MethodMismatchResponse.ABORT;
}
};
tester.startPage(new FormWithButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertFalse(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesWithCorrectMethod.
@Test
public void withAjaxButtonFormSubmittedContinuesWithCorrectMethod() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
};
tester.startPage(new FormWithAjaxButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.
@Test
public void withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
};
tester.startPage(new FormWithAjaxButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class FormSubmitTest method allFormsEnabledSubmitOuterForm.
/**
*/
@Test
public void allFormsEnabledSubmitOuterForm() {
assertEnabledState(true, true, true);
FormTester formTester = tester.newFormTester("outerForm");
formTester.submit("submit");
assertOnSubmitCalled(true, true, true);
assertOnErrorCalled(false, false, false);
assertSubmitOrder(innerForm, middleForm, outerForm);
}
Aggregations