use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method formSubmittedContinuesByDefaultWithMismatchingMethod.
@Test
public void formSubmittedContinuesByDefaultWithMismatchingMethod() {
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 PlainFormPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit();
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method formSubmittedContinuesByWithCorrectMethodWhenDesired.
@Test
public void formSubmittedContinuesByWithCorrectMethodWhenDesired() {
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");
formTester.submit();
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired.
@Test
public void withButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired() {
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");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.
@Test
public void withAjaxButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
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 FormWithAjaxButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertFalse(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester 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]);
}
Aggregations