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);
}
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]);
}
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]);
}
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]);
}
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]);
}
Aggregations