Search in sources :

Example 41 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class StatelessAjaxSubmitLinkTest method testSubmitForm.

@Test
public void testSubmitForm() throws Exception {
    tester.startPage(StatelessPage.class);
    FormTester formTester = tester.newFormTester("inputForm");
    formTester.setValue("name", "myname");
    formTester.setValue("surname", "mysurname");
    tester.executeAjaxEvent("inputForm:submit", "click");
    String response = tester.getLastResponseAsString();
    boolean isAjaxResponse = response.contains(XmlPartialPageUpdate.START_ROOT_ELEMENT) && response.contains(XmlPartialPageUpdate.END_ROOT_ELEMENT);
    assertTrue(isAjaxResponse);
    boolean formAjaxSubmit = response.contains(StatelessPage.FORM_SUBMIT) && response.contains(StatelessPage.AJAX_SUBMIT);
    assertTrue(formAjaxSubmit);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 42 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class MarkupVariationTest method changeVariationBeforeRendering.

/**
 * https://issues.apache.org/jira/browse/WICKET-6231
 */
@Test
public void changeVariationBeforeRendering() throws Exception {
    tester.startPage(new VariationPage());
    FormTester formTester = tester.newFormTester("p:a_form");
    formTester.submit();
    tester.assertContainsNot("One");
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 43 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class EnclosureTest method testRender9a.

/**
 * @throws Exception
 */
@Test
public void testRender9a() throws Exception {
    Class<? extends Page> clazz = EnclosurePage_9.class;
    executePage(new EnclosurePage_9(), "EnclosurePageExpectedResult_9.html");
    EnclosurePage_9 page = (EnclosurePage_9) tester.getLastRenderedPage();
    page.reset();
    FormTester formTester = tester.newFormTester("form");
    tester.getRequest().getPostParameters().setParameterValue(((CheckBox) page.get("form:input")).getInputName(), "true");
    page.get("form:label").setVisible(true);
    formTester.submit();
    tester.assertRenderedPage(clazz);
    assertResultPage("EnclosurePageExpectedResult_9-4.html");
    assertTrue(page.inputOnBeforeRender);
    assertTrue(page.inputValidate);
    assertTrue(page.labelOnBeforeRender);
    page.reset();
    tester.getRequest().getPostParameters().setParameterValue(((CheckBox) page.get("form:input")).getInputName(), "true");
    page.get("form:label").setVisible(false);
    tester.submitForm("form");
    tester.assertRenderedPage(clazz);
    assertResultPage("EnclosurePageExpectedResult_9-2-1.html");
    // It should be FALSE, but because of auto-component etc. it doesn't
    // assertFalse(page.inputOnBeforeRender);
    assertTrue(page.inputOnBeforeRender);
    // It should be FALSE, but because of auto-component etc. it doesn't
    // assertFalse(page.inputValidate);
    assertTrue(page.inputValidate);
    assertFalse(page.labelOnBeforeRender);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 44 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormPage2Test method formAndLinkAreSubmitted.

/**
 */
@Test
public void formAndLinkAreSubmitted() {
    tester.startPage(FormPage2.class);
    FormPage2 page = (FormPage2) tester.getLastRenderedPage();
    Assert.assertFalse(page.isSubmitLinkSubmitted());
    Assert.assertFalse(page.isFormSubmitted());
    FormTester formTester = tester.newFormTester("form");
    formTester.submitLink("link", false);
    page = (FormPage2) tester.getLastRenderedPage();
    Assert.assertTrue(page.isFormSubmitted());
    Assert.assertTrue(page.isSubmitLinkSubmitted());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 45 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormPage2Test method formIsSubmitted.

/**
 */
@Test
public void formIsSubmitted() {
    tester.startPage(FormPage2.class);
    FormPage2 page = (FormPage2) tester.getLastRenderedPage();
    Assert.assertFalse(page.isSubmitLinkSubmitted());
    Assert.assertFalse(page.isFormSubmitted());
    FormTester formTester = tester.newFormTester("form");
    formTester.submit();
    page = (FormPage2) tester.getLastRenderedPage();
    Assert.assertTrue(page.isFormSubmitted());
    Assert.assertFalse(page.isSubmitLinkSubmitted());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) 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