use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class StatelessFormTest method login.
/**
* Login through the login page.
*/
@Test
public void login() {
tester.startPage(LOGIN);
tester.assertRenderedPage(LOGIN);
FormTester form = tester.newFormTester("signInPanel:signInForm");
form.setValue("username", "test");
form.setValue("password", "test");
form.submit();
tester.assertRenderedPage(HOME);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class SetCookieAndRedirectTest method statelessPage.
/**
* Validate proper cookie value set with stateless page
*/
@Test
public void statelessPage() {
tester.startPage(SetCookieAndRedirectStatelessTestPage.class);
FormTester formTester = tester.newFormTester("form");
formTester.setValue("input", cookieValue);
formTester.submit();
Page page = tester.getLastRenderedPage();
List<Cookie> cookies = tester.getLastResponse().getCookies();
assertEquals(1, cookies.size());
assertEquals(cookieValue, cookies.get(0).getValue());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class SetCookieAndRedirectTest method statefulPage.
/**
* Validate proper cookie value set with stateful page
*/
@Test
public void statefulPage() {
tester.startPage(SetCookieAndRedirectStatefullTestPage.class);
FormTester formTester = tester.newFormTester("form");
formTester.setValue("input", cookieValue);
formTester.submit();
Page page = tester.getLastRenderedPage();
List<Cookie> cookies = tester.getLastResponse().getCookies();
assertEquals(1, cookies.size());
assertEquals(cookieValue, cookies.get(0).getValue());
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TemporarySessionTest method sessionIsTemporary.
/**
* Test if we can keep a session temporary.
*/
@Test
public void sessionIsTemporary() {
tester.startPage(LoginPage.class);
assertTrue(tester.getSession().isTemporary());
tester.startPage(LoginPage.class);
FormTester form = tester.newFormTester("signInPanel:signInForm");
form.setValue("username", "test");
form.setValue("password", "test");
tester.getSession().bind();
form.submit();
tester.assertRenderedPage(HomePage.class);
assertFalse(Session.get().isTemporary());
tester.startPage(LoginPage.class);
}
use of org.apache.wicket.util.tester.FormTester in project wicket by apache.
the class TestHomePage method testWithBorder2.
@Test
public void testWithBorder2() {
tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);
FormTester formTester = tester.newFormTester("border:form");
// formTester.setValue("..:textfield1", "testxxx");
@SuppressWarnings("unchecked") TextField<String> textfield = (TextField<String>) tester.getLastRenderedPage().get("border:form:body:textfield");
tester.getRequest().getPostParameters().setParameterValue(textfield.getInputName(), "abcde");
MyTextField datefield = (MyTextField) tester.getLastRenderedPage().get("border:form:body:datefield");
tester.getRequest().getPostParameters().setParameterValue(datefield.getInputName(), "aaabbb");
MyDateField datefield2 = (MyDateField) tester.getLastRenderedPage().get("border:form:body:datefield2");
@SuppressWarnings("unchecked") TextField<String> date = (TextField<String>) datefield2.get("date");
tester.getRequest().getPostParameters().setParameterValue(date.getInputName(), "abcdef");
formTester.submit();
tester.assertNoErrorMessage();
HomePage page = (HomePage) tester.getLastRenderedPage();
assertEquals("abcde", page.getTextfield());
assertEquals("aaabbb-converted", page.getDatefield());
assertEquals("abcdef-converted", page.getDatefield2());
assertEquals("abcde", page.get("border:form:body:lbltextfield").getDefaultModelObjectAsString());
assertEquals("aaabbb-converted", page.get("border:form:body:lbldatefield").getDefaultModelObjectAsString());
assertEquals("abcdef-converted", page.get("border:form:body:lbldatefield2").getDefaultModelObjectAsString());
}
Aggregations