Search in sources :

Example 1 with FormTester

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);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 2 with FormTester

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());
}
Also used : Cookie(javax.servlet.http.Cookie) FormTester(org.apache.wicket.util.tester.FormTester) Page(org.apache.wicket.Page) Test(org.junit.Test)

Example 3 with FormTester

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());
}
Also used : Cookie(javax.servlet.http.Cookie) FormTester(org.apache.wicket.util.tester.FormTester) Page(org.apache.wicket.Page) Test(org.junit.Test)

Example 4 with FormTester

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);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 5 with FormTester

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());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) TextField(org.apache.wicket.markup.html.form.TextField) Test(org.junit.Test)

Aggregations

FormTester (org.apache.wicket.util.tester.FormTester)207 Test (org.junit.Test)122 Test (org.junit.jupiter.api.Test)54 Component (org.apache.wicket.Component)50 WicketTester (org.apache.wicket.util.tester.WicketTester)14 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Test (org.testng.annotations.Test)9 List (java.util.List)8 ListModel (org.apache.wicket.model.util.ListModel)7 ArrayList (java.util.ArrayList)6 File (org.apache.wicket.util.file.File)4 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)3 ButtonAjaxBehavior (com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior)3 LocalDate (java.time.LocalDate)3 Cookie (javax.servlet.http.Cookie)3 Page (org.apache.wicket.Page)3 LocalDateConverter (org.apache.wicket.util.convert.converter.LocalDateConverter)3 Ignore (org.junit.Ignore)3 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)2