use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.
@Test
public void withButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
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 FormWithButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired.
@Test
public void withAjaxButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired() {
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");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method formSubmittedContinuesWithCorrectMethod.
@Test
public void formSubmittedContinuesWithCorrectMethod() {
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");
formTester.submit();
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class ChildFirstHeaderRenderStrategyTest method executeCombinedTestPre1_5.
/**
* @param <T>
* @param pageClass
* @param filename
* @throws Exception
*/
private <T extends Page> void executeCombinedTestPre1_5(final Class<T> pageClass, final String filename) throws Exception {
// Default Config: parent first header render strategy
log.error("=== PARENT first header render strategy ===");
tester.startPage(pageClass);
tester.assertRenderedPage(pageClass);
tester.assertResultPage(getClass(), filename);
// child first header render strategy
log.error("=== CHILD first header render strategy ===");
System.setProperty("Wicket_HeaderRenderStrategy", ChildFirstHeaderRenderStrategy.class.getName());
tester = new WicketTester();
tester.startPage(pageClass);
tester.assertRenderedPage(pageClass);
tester.assertResultPage(getClass(), filename + "_2");
System.setProperty("Wicket_HeaderRenderStrategy", "");
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class PropertiesResolverTest method resolveProperties.
/**
*/
@Test
public void resolveProperties() {
WicketTester tester = new WicketTester(new App());
// all the tests are performed in page
tester.startPage(MyPage.class);
tester.assertRenderedPage(MyPage.class);
}
Aggregations