use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class InterceptTest method formSubmit.
/**
*/
@Test
public void formSubmit() {
// same as above but uses different technique to login
tester.startPage(tester.getApplication().getHomePage());
MockLoginPage loginPage = (MockLoginPage) tester.getLastRenderedPage();
assertEquals(((MyMockWebApplication) tester.getApplication()).getLoginPage(), loginPage.getClass());
FormTester form = tester.newFormTester("form");
form.setValue("username", "admin");
form.submit();
assertEquals(tester.getApplication().getHomePage(), tester.getLastRenderedPage().getClass());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class InterceptTest method clickLink2.
/**
*/
@Test
public void clickLink2() {
// same as above but uses different technique to login
tester.startPage(tester.getApplication().getHomePage());
MockLoginPage loginPage = (MockLoginPage) tester.getLastRenderedPage();
assertEquals(((MyMockWebApplication) tester.getApplication()).getLoginPage(), loginPage.getClass());
// bypass formTester completely to login but continue to intercept page
FormTester formTester = tester.newFormTester("form");
formTester.setValue("username", "admin");
formTester.submit();
tester.startPage(tester.getApplication().getHomePage());
assertEquals(tester.getApplication().getHomePage(), tester.getLastRenderedPage().getClass());
tester.clickLink(tester.getLastRenderedPage().get("link"));
assertEquals(PageA.class, tester.getLastRenderedPage().getClass());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class AjaxFormSubmitBehaviorTest method innerFormSubmit.
/**
* https://issues.apache.org/jira/browse/WICKET-6455
*/
@Test
public void innerFormSubmit() {
tester.startPage(NestedFormTestPage.class);
NestedFormTestPage homePage = (NestedFormTestPage) tester.getLastRenderedPage();
assertFalse(homePage.innerSubmitted);
FormTester formTester = tester.newFormTester("outer:inner");
formTester.submit("submit");
assertTrue(homePage.innerSubmitted);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class AjaxFormSubmitTest method submit.
@Test
public void submit() {
AjaxFormSubmitTestPage page = new AjaxFormSubmitTestPage(true);
tester.startPage(page);
tester.assertRenderedPage(page.getClass());
FormTester form = tester.newFormTester("form");
form.setValue("txt1", "txt1");
form.setValue("txt2", "txt2");
// mark the button as the one being pressed. there is a 'p::' infront of name because wicket
// escapes "submit" input names as they break browsers
tester.getRequest().getPostParameters().setParameterValue("p::submit", "x");
tester.submitForm(form.getForm());
tester.assertRenderedPage(page.getClass());
assertTrue((page.getFormSubmitted() & AjaxFormSubmitTestPage.FORM_SUBMIT) > 0);
assertFalse((page.getFormSubmitted() & AjaxFormSubmitTestPage.FORM_ERROR) > 0);
assertTrue((page.getFormSubmitted() & AjaxFormSubmitTestPage.BUTTON_SUBMIT) > 0);
assertFalse((page.getFormSubmitted() & AjaxFormSubmitTestPage.BUTTON_ERROR) > 0);
assertEquals("txt1", tester.getComponentFromLastRenderedPage("form:txt1").getDefaultModelObject());
assertEquals("txt2", tester.getComponentFromLastRenderedPage("form:txt2").getDefaultModelObject());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TestHomePage method testRenderMyPage.
@Test
public void testRenderMyPage() {
// start and render the test page
tester.startPage(HomePage.class);
// assert rendered page class
tester.assertRenderedPage(HomePage.class);
FormTester formTester = tester.newFormTester("bookingForm");
formTester.submit();
tester.assertErrorMessages("Name is required");
}
Aggregations