Search in sources :

Example 86 with FormTester

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

the class TestInstall method testInstall.

@Test
public void testInstall() {
    InstallWizardPage page = tester.startPage(InstallWizardPage.class);
    tester.assertRenderedPage(InstallWizardPage.class);
    InstallWizard wiz = (InstallWizard) page.get(WIZARD_PATH);
    assertNull("Model should be null", wiz.getWizardModel().getActiveStep());
    // welcome step
    tester.executeBehavior((AbstractAjaxBehavior) page.getBehaviorById(0));
    assertNotNull("Model should NOT be null", wiz.getWizardModel().getActiveStep());
    ButtonAjaxBehavior prev = getButtonBehavior(tester, WIZARD_PATH, "PREV");
    // check enabled, add check for other buttons on other steps
    assertFalse("Prev button should be disabled", prev.getButton().isEnabled());
    ButtonAjaxBehavior next = getButtonBehavior(tester, WIZARD_PATH, "NEXT");
    ButtonAjaxBehavior finish = getButtonBehavior(tester, WIZARD_PATH, SUBMIT);
    // DB step
    tester.executeBehavior(next);
    FormTester wizardTester = tester.newFormTester("wizard:form");
    wizardTester.select("view:form:dbType", 1);
    checkErrors(tester, 0);
    // user step
    tester.executeBehavior(next);
    checkErrors(tester, 0);
    wizardTester.setValue("view:username", adminUsername);
    wizardTester.setValue("view:password", userpass);
    wizardTester.setValue("view:email", email);
    String[] tzIds = TimeZone.getAvailableIDs();
    wizardTester.select("view:timeZone", rnd.nextInt(tzIds.length));
    wizardTester.setValue("view:group", group);
    // cfg+smtp step
    tester.executeBehavior(next);
    checkErrors(tester, 0);
    wizardTester.setValue("view:smtpPort", "25");
    wizardTester.select("view:defaultLangId", 0);
    // converters step
    tester.executeBehavior(next);
    checkErrors(tester, 0);
    wizardTester.setValue("view:docDpi", "150");
    wizardTester.setValue("view:docQuality", "90");
    // crypt step
    tester.executeBehavior(next);
    // not checking errors
    if (countErrors(tester) > 0) {
        tester.cleanupFeedbackMessages();
        wizardTester.setValue("view:docDpi", "150");
        wizardTester.setValue("view:docQuality", "90");
        // skip errors
        tester.executeBehavior(next);
    }
    wizardTester.setValue("view:cryptClassName", SCryptImplementation.class.getName());
    // install step
    tester.executeBehavior(next);
    checkErrors(tester, 0);
    tester.executeBehavior(finish);
    checkErrors(tester, 0);
}
Also used : SCryptImplementation(org.apache.openmeetings.util.crypt.SCryptImplementation) FormTester(org.apache.wicket.util.tester.FormTester) ButtonAjaxBehavior(com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior) AbstractSpringTest(org.apache.openmeetings.AbstractSpringTest) Test(org.junit.Test)

Example 87 with FormTester

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

the class FormMethodMismatchTest method formSubmittedContinuesByDefaultWithMismatchingMethod.

@Test
public void formSubmittedContinuesByDefaultWithMismatchingMethod() {
    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");
    tester.getRequest().setMethod("GET");
    formTester.submit();
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 88 with FormTester

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

the class FormMethodMismatchTest method formSubmittedContinuesByWithCorrectMethodWhenDesired.

@Test
public void formSubmittedContinuesByWithCorrectMethodWhenDesired() {
    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 PlainFormPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    formTester.submit();
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 89 with FormTester

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

the class FormMethodMismatchTest method withButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired.

@Test
public void withButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired() {
    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 FormWithButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    formTester.submit("button");
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 90 with FormTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.

@Test
public void withAjaxButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
    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");
    tester.getRequest().setMethod("GET");
    formTester.submit("button");
    assertFalse(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) 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