From richfaces-svn-commits at lists.jboss.org Thu Sep 3 07:15:22 2009 Content-Type: multipart/mixed; boundary="===============6565832361066880731==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r15446 - in branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test: resources/org/jboss/richfaces/integrationTest/ajaxValidator and 1 other directory. Date: Thu, 03 Sep 2009 07:15:21 -0400 Message-ID: <200909031115.n83BFL0a008273@svn01.web.mwc.hst.phx2.redhat.com> --===============6565832361066880731== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: lfryc(a)redhat.com Date: 2009-09-03 07:15:21 -0400 (Thu, 03 Sep 2009) New Revision: 15446 Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidat= orTestCase.java branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHibern= atePartTestCase.java branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestCa= se.java branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.prope= rties branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.prope= rties Log: - refactored Ajax Validator test cases to follow conventions Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjax= ValidatorTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValida= torTestCase.java 2009-09-03 11:13:01 UTC (rev 15445) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValida= torTestCase.java 2009-09-03 11:15:21 UTC (rev 15446) @@ -1,21 +1,43 @@ +/** + * License Agreement. + * + * JBoss RichFaces + * + * Copyright (C) 2009 Red Hat, Inc. + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this test suite; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA + */ package org.jboss.richfaces.integrationTest.ajaxValidator; = import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCa= se; -import org.testng.Assert; +import org.jboss.test.selenium.dom.Event; +import org.testng.annotations.BeforeMethod; = /** * @author Lukas Fryc * @version $Revision$ */ -public class AbstractAjaxValidatorTestCase extends - AbstractSeleniumRichfacesTestCase { +public class AbstractAjaxValidatorTestCase extends AbstractSeleniumRichfac= esTestCase { = + private final String LOC_VALIDATION_MESSAGE_RELATIVE =3D getLoc("VALIDATI= ON_MESSAGE_RELATIVE"); + /** - * Opens specified page + * Opens specified component's page before each test method */ - public void openPage() { - selenium.open(contextPath - + "/richfaces/ajaxValidator.jsf?c=3DajaxValidator&tab=3Dusage"); + @BeforeMethod + protected void loadPage() { + openComponent("Ajax Validator"); } = /** @@ -27,9 +49,11 @@ * @param value * the value which should be typed in "type input" action */ - public void typeAndBlur(String locator, String value) { + protected void typeAndBlur(String locator, String value) { + scrollIntoView(locator, true); + = selenium.type(locator, value); - selenium.fireEvent(locator, "blur"); + selenium.fireEvent(locator, Event.BLUR); } = /** @@ -39,7 +63,9 @@ * for which element should be find message box * @return locator of message box for element given by locator */ - public String getMessageFor(String locator) { - return String.format(getLoc("relativeMessageLink"), locator); + protected String getMessageFor(String locator) { + scrollIntoView(locator, true); + = + return format(LOC_VALIDATION_MESSAGE_RELATIVE, locator); } } Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidato= rHibernatePartTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHiber= natePartTestCase.java 2009-09-03 11:13:01 UTC (rev 15445) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHiber= natePartTestCase.java 2009-09-03 11:15:21 UTC (rev 15446) @@ -1,3 +1,23 @@ +/** + * License Agreement. + * + * JBoss RichFaces + * + * Copyright (C) 2009 Red Hat, Inc. + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this test suite; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA + */ package org.jboss.richfaces.integrationTest.ajaxValidator; = import org.testng.annotations.Test; @@ -6,125 +26,190 @@ * @author Lukas Fryc * @version $Revision$ */ -public class AjaxValidatorHibernatePartTestCase extends - AbstractAjaxValidatorTestCase { +public class AjaxValidatorHibernatePartTestCase extends AbstractAjaxValida= torTestCase { = - /* COMPONENTS */ + private final String LOC_INPUT_HIBERNATE_NAME =3D getLoc("INPUT_HIBERNATE= _NAME"); + private final String LOC_INPUT_HIBERNATE_AGE =3D getLoc("INPUT_HIBERNATE_= AGE"); + private final String LOC_INPUT_HIBERNATE_EMAIL =3D getLoc("INPUT_HIBERNAT= E_EMAIL"); = - private final String name =3D getLoc("hibernateName"); - private final String age =3D getLoc("hibernateAge"); - private final String email =3D getLoc("hibernateEmail"); + private final String MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM =3D getMsg("INP= UT_VALUE_IS_LESS_THAN_MINIMUM"); + private final String MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM =3D getMsg("= INPUT_VALUE_IS_GREATER_THAN_MAXIMUM"); + private final String MSG_INPUT_HIBERNATE_VALID_INPUT =3D getMsg("INPUT_HI= BERNATE_VALID_INPUT"); + private final String MSG_INPUT_MUST_BE_GREATER_THAN_OR_EQUAL =3D getMsg("= INPUT_MUST_BE_GREATER_THAN_OR_EQUAL"); + private final String MSG_INPUT_MUST_BE_LESS_THAN_OR_EQUAL =3D getMsg("INP= UT_MUST_BE_LESS_THAN_OR_EQUAL"); + private final String MSG_INPUT_IS_NOT_NUMBER =3D getMsg("INPUT_IS_NOT_NUM= BER"); + private final String MSG_INPUT_VALID_AGE =3D getMsg("INPUT_VALID_AGE"); + private final String MSG_INPUT_NOT_WELL_FORMED_EMAIL_1 =3D getMsg("INPUT_= NOT_WELL_FORMED_EMAIL_1"); + private final String MSG_INPUT_NOT_WELL_FORMED_EMAIL_2 =3D getMsg("INPUT_= NOT_WELL_FORMED_EMAIL_2"); + private final String MSG_INPUT_WELL_FORMED_EMAIL =3D getMsg("INPUT_WELL_F= ORMED_EMAIL"); + private final String MSG_OUTPUT_VALUE_REQUIRED_PREFORMATTED =3D getMsg("O= UTPUT_VALUE_REQUIRED"); + private final String MSG_OUTPUT_LENGTH_MUST_BE_BETWEEN =3D getMsg("OUTPUT= _LENGTH_MUST_BE_BETWEEN"); + private final String MSG_OUTPUT_STRING_CONTAIN_ONLY_SPACES =3D getMsg("OU= TPUT_STRING_CONTAIN_ONLY_SPACES"); + private final String MSG_OUTPUT_MAY_NOT_BE_NULL =3D getMsg("OUTPUT_MAY_NO= T_BE_NULL"); + private final String MSG_OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL =3D getMsg(= "OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL"); + private final String MSG_OUTPUT_MUST_BE_LESS_THAN_OR_EQUAL =3D getMsg("OU= TPUT_MUST_BE_LESS_THAN_OR_EQUAL"); + private final String MSG_OUTPUT_MUST_BE_A_NUMBER =3D getMsg("OUTPUT_MUST_= BE_A_NUMBER"); + private final String MSG_OUTPUT_MAY_NOT_BE_NULL_OR_EMPTY =3D getMsg("OUTP= UT_MAY_NOT_BE_NULL_OR_EMPTY"); + private final String MSG_OUTPUT_NOT_WELL_FORMED_EMAIL =3D getMsg("OUTPUT_= NOT_WELL_FORMED_EMAIL"); = - /* TESTS */ - + /** + * Try type no chars in input name and checks that value required message + * will appear. + */ @Test - public void nameValueRequired() { - openPage(); - typeAndBlur(name, ""); - waitForTextEquals(getMessageFor(name), formatMess("value-required", - name)); + public void testNameValueRequired() { + final String validationMessage =3D format(MSG_OUTPUT_VALUE_REQUIRED_PREF= ORMATTED, LOC_INPUT_HIBERNATE_NAME); + typeAndBlur(LOC_INPUT_HIBERNATE_NAME, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME), validationMes= sage); } = + /** + * Try type string of length less than minimum length in name input and + * checks that validation message will appear. + */ @Test - public void nameMinimumLength() { - openPage(); - typeAndBlur(name, getMess("less-than-minimum--enter")); - waitForTextEquals(getMessageFor(name), getMess("bean-name--length")); + public void testNameMinimumLength() { + typeAndBlur(LOC_INPUT_HIBERNATE_NAME, MSG_INPUT_VALUE_IS_LESS_THAN_MINIM= UM); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME), MSG_OUTPUT_LE= NGTH_MUST_BE_BETWEEN); } = + /** + * Try type string of length greater than maximum length in name input and + * checks that validation message will appear. + */ @Test - public void nameMaximumLength() { - openPage(); - typeAndBlur(name, getMess("greater-than-maximum--enter")); - waitForTextEquals(getMessageFor(name), getMess("bean-name--length")); + public void testNameMaximumLength() { + typeAndBlur(LOC_INPUT_HIBERNATE_NAME, MSG_INPUT_VALUE_IS_GREATER_THAN_MA= XIMUM); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME), MSG_OUTPUT_LE= NGTH_MUST_BE_BETWEEN); } = + /** + * Enter only one space to name input and checks that validation message + * will appear. + */ @Test - public void nameOnlySpacesPattern() { - openPage(); - typeAndBlur(name, " "); - waitForTextEquals(getMessageFor(name), getMess("bean-name--not-empty")); + public void testNameOnlySpacesPattern() { + typeAndBlur(LOC_INPUT_HIBERNATE_NAME, " "); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME), MSG_OUTPUT_ST= RING_CONTAIN_ONLY_SPACES); } = + /** + * Try type the invalid name input and checks that after typing valid inp= ut + * will validation message disappear. + */ @Test - public void nameMessageDisappers() { - nameValueRequired(); - typeAndBlur(name, getMess("bean-name--valid-input")); - waitForTextEquals(getMessageFor(name), ""); + public void testNameMessageDisappers() { + // first violate validation error + testNameValueRequired(); + // then try valid input + typeAndBlur(LOC_INPUT_HIBERNATE_NAME, MSG_INPUT_HIBERNATE_VALID_INPUT); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME), ""); } = + /** + * Try type no chars in age input and checks that the validation message + * value required will appear. + */ @Test - public void ageValueRequired() { - openPage(); - typeAndBlur(age, ""); - waitForTextEquals(getMessageFor(age), getMess("may-not-be-null")); + public void testAgeValueRequired() { + typeAndBlur(LOC_INPUT_HIBERNATE_AGE, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_AGE), MSG_OUTPUT_MAY= _NOT_BE_NULL); } = + /** + * Try input age less than minimum and checks that the validation message + * will appear. + */ @Test - public void ageMinimumValue() { - openPage(); - typeAndBlur(age, getMess("long-range--bellow")); - waitForTextEquals(getMessageFor(age), getMess("bean-age--min")); + public void testAgeMinimumValue() { + typeAndBlur(LOC_INPUT_HIBERNATE_AGE, MSG_INPUT_MUST_BE_LESS_THAN_OR_EQUA= L); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_AGE), MSG_OUTPUT_MUS= T_BE_LESS_THAN_OR_EQUAL); } = + /** + * Try input age greater than maximum and checks that the validation mess= age + * will appear. + */ @Test - public void ageMaximumValue() { - openPage(); - typeAndBlur(age, getMess("bean-age--max--enter")); - waitForTextEquals(getMessageFor(age), getMess("bean-age--max")); + public void testAgeMaximumValue() { + typeAndBlur(LOC_INPUT_HIBERNATE_AGE, MSG_INPUT_MUST_BE_GREATER_THAN_OR_E= QUAL); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_AGE), MSG_OUTPUT_MUS= T_BE_GREATER_THAN_OR_EQUAL); } = + /** + * Try input age as non-Integer (alphabetical chars) and checks that + * validation message will appear. + */ @Test - public void ageIntegerOnly() { - openPage(); - typeAndBlur(age, formatMess("age-integer-only--enter", age)); - waitForTextEquals(getMessageFor(age), formatMess( - "bean-age--integer-only", age)); + public void testAgeIntegerOnly() { + final String validationMessage =3D format(MSG_OUTPUT_MUST_BE_A_NUMBER, L= OC_INPUT_HIBERNATE_AGE); + typeAndBlur(LOC_INPUT_HIBERNATE_AGE, MSG_INPUT_IS_NOT_NUMBER); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_AGE), validationMess= age); } = + /** + * Try input no input first and wait for validation message appears and t= hen + * type a valid input and checks that validation message will disappear. + */ @Test - public void ageMessageDisappers() { - ageValueRequired(); - typeAndBlur(age, getMess("valid-age")); - waitForTextEquals(getMessageFor(age), ""); + public void testAgeMessageDisappers() { + // first violate validation error + testAgeValueRequired(); + // then try valid input + typeAndBlur(LOC_INPUT_HIBERNATE_AGE, MSG_INPUT_VALID_AGE); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_AGE), ""); } = + /** + * Try to enter empty email address and checks that validation message + * appears. + */ @Test - public void emailMayNotBeNullOrEmpty() { - openPage(); - typeAndBlur(email, ""); - waitForTextEquals(getMessageFor(email), - getMess("may-not-be-null-or-empty")); + public void testEmailMayNotBeNullOrEmpty() { + typeAndBlur(LOC_INPUT_HIBERNATE_EMAIL, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_EMAIL), MSG_OUTPUT_M= AY_NOT_BE_NULL_OR_EMPTY); } = + /** + * Try to enter one space like a email address and checks that validation + * message appears. + */ @Test - public void emailOnlySpaces() { - openPage(); - typeAndBlur(email, " "); - waitForTextEquals(getMessageFor(email), - getMess("not-well-formed-email")); + public void testEmailOnlySpaces() { + typeAndBlur(LOC_INPUT_HIBERNATE_EMAIL, " "); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_EMAIL), MSG_OUTPUT_N= OT_WELL_FORMED_EMAIL); } = + /** + * Enter bad email address (only domain name suffix) and checks that + * validation message appears. + */ @Test - public void emailBad1() { - openPage(); - typeAndBlur(email, getMess("bad-email-1")); - waitForTextEquals(getMessageFor(email), - getMess("not-well-formed-email")); + public void testEmailBad1() { + typeAndBlur(LOC_INPUT_HIBERNATE_EMAIL, MSG_INPUT_NOT_WELL_FORMED_EMAIL_1= ); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_EMAIL), MSG_OUTPUT_N= OT_WELL_FORMED_EMAIL); } = + /** + * Enter bad email address (only @ char with domain name suffix) and chec= ks + * that testValidation message appears. + */ @Test - public void emailBad2() { - openPage(); - typeAndBlur(email, getMess("bad-email-2")); - waitForTextEquals(getMessageFor(email), - getMess("not-well-formed-email")); + public void testEmailBad2() { + typeAndBlur(LOC_INPUT_HIBERNATE_EMAIL, MSG_INPUT_NOT_WELL_FORMED_EMAIL_2= ); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_EMAIL), MSG_OUTPUT_N= OT_WELL_FORMED_EMAIL); } = + /** + * Enter bad email address, wait for validation message appear and then t= ry + * to enter valid email address and checks that validation message appear. + */ @Test - public void emailMessageDisappers() { - emailMayNotBeNullOrEmpty(); - typeAndBlur(email, getMess("well-formed-email")); - waitForTextEquals(getMessageFor(email), ""); + public void testEmailMessageDisappers() { + // first violate validation error + testEmailMayNotBeNullOrEmpty(); + // then try valid input + typeAndBlur(LOC_INPUT_HIBERNATE_EMAIL, MSG_INPUT_WELL_FORMED_EMAIL); + waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_EMAIL), ""); } } Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidato= rTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestC= ase.java 2009-09-03 11:13:01 UTC (rev 15445) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestC= ase.java 2009-09-03 11:15:21 UTC (rev 15446) @@ -1,86 +1,149 @@ +/** +* License Agreement. +* +* JBoss RichFaces +* +* Copyright (C) 2009 Red Hat, Inc. +* +* This code is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1 as published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this test suite; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301= USA +*/ package org.jboss.richfaces.integrationTest.ajaxValidator; = -import java.text.MessageFormat; - import org.testng.annotations.Test; = /** * @author Lukas Fryc - * @version $Revision$ + * @version test$Revision$ */ public class AjaxValidatorTestCase extends AbstractAjaxValidatorTestCase { = - /* COMPONENTS */ + private final String LOC_INPUT_NAME =3D getLoc("INPUT_NAME"); + private final String LOC_INPUT_AGE =3D getLoc("INPUT_AGE"); = - private final String name =3D getLoc("name"); - private final String age =3D getLoc("age"); + private final String MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM =3D getMsg("= INPUT_VALUE_IS_GREATER_THAN_MAXIMUM"); + private final String MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM =3D getMsg("INP= UT_VALUE_IS_LESS_THAN_MINIMUM"); + private final String MSG_INPUT_VALID_NAME =3D getMsg("INPUT_VALID_NAME"); + private final String MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW =3D get= Msg("INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW"); + private final String MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE =3D getM= sg("INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE"); + private final String MSG_INPUT_IS_NOT_NUMBER =3D getMsg("INPUT_IS_NOT_NUM= BER"); + private final String MSG_INPUT_VALID_AGE =3D getMsg("INPUT_VALID_AGE"); + private final String MSG_OUTPUT_VALUE_REQUIRED_PREFORMATTED =3D getMsg("O= UTPUT_VALUE_REQUIRED"); + private final String MSG_OUTPUT_VALUE_IS_LESS_THAN_MINIMUM =3D getMsg("OU= TPUT_VALUE_IS_LESS_THAN_MINIMUM"); + private final String MSG_OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTE= D =3D getMsg("OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTED"); + private final String MSG_OUTPUT_IS_NOT_NUMBER_PREFORMATTED =3D getMsg("OU= TPUT_IS_NOT_NUMBER_PREFORMATTED"); + private final String MSG_OUTPUT_NOT_BETWEEN_EXPECTED_VALUES_PREFORMATTED = =3D getMsg("OUTPUT_NOT_BETWEEN_EXPECTED_VALUES_PREFORMATTED"); = - /* TESTS */ - + /** + * Try type no chars in input name and checks that value required message + * will appear. + */ @Test - public void nameValueRequired() { - openPage(); - typeAndBlur(name, ""); - waitForTextEquals(getMessageFor(name), formatMess("value-required", - name)); + public void testNameValueRequired() { + final String validationMessage =3D format(MSG_OUTPUT_VALUE_REQUIRED_PREF= ORMATTED, LOC_INPUT_NAME); + typeAndBlur(LOC_INPUT_NAME, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), validationMessage); } = + /** + * Try type string of length less than minimum length in name input and + * checks that validation message will appear. + */ @Test - public void nameMinimumLength() { - openPage(); - typeAndBlur(name, getMess("less-than-minimum--enter")); - waitForTextEquals(getMessageFor(name), formatMess("less-than-minimum", - name)); + public void testNameMinimumLength() { + final String validationMessage =3D format(MSG_OUTPUT_VALUE_IS_LESS_THAN_= MINIMUM, LOC_INPUT_NAME); + typeAndBlur(LOC_INPUT_NAME, MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), validationMessage); } = + /** + * Try type string of length greater than maximum length in name input and + * checks that validation message will appear. + */ @Test - public void nameMaximumLength() { - openPage(); - typeAndBlur(name, getMess("greater-than-maximum--enter")); - waitForTextEquals(getMessageFor(name), formatMess( - "greater-than-maximum", name)); + public void testNameMaximumLength() { + final String validationMessage =3D format(MSG_OUTPUT_VALUE_IS_GREATER_TH= AN_MAXIMUM_PREFORMATTED, LOC_INPUT_NAME); + typeAndBlur(LOC_INPUT_NAME, MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), validationMessage); } = + /** + * Try type the invalid name input and checks that after typing valid inp= ut + * will validation message disappear. + */ @Test - public void nameMessageDisappers() { - nameValueRequired(); // violates validation message - typeAndBlur(name, getMess("valid-name")); - waitForTextEquals(getMessageFor(name), ""); + public void testNameMessageDisappers() { + // first violate validation error + testNameValueRequired(); + // then try valid input + typeAndBlur(LOC_INPUT_NAME, MSG_INPUT_VALID_NAME); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), ""); } = + /** + * Try type no chars in age input and checks that the validation message + * value required will appear. + */ @Test - public void ageValueRequired() { - openPage(); - typeAndBlur(age, ""); - waitForTextEquals(getMessageFor(age), formatMess("value-required", age)); + public void testAgeValueRequired() { + final String validationMessage =3D format(MSG_OUTPUT_VALUE_REQUIRED_PREF= ORMATTED, LOC_INPUT_AGE); + typeAndBlur(LOC_INPUT_AGE, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), validationMessage); } = + /** + * Try input age less than minimum and checks that the validation message + * will appear. + */ @Test - public void ageMinimumValue() { - openPage(); - typeAndBlur(age, getMess("long-range--bellow")); - waitForTextEquals(getMessageFor(age), formatMess("long-range", age)); + public void testAgeMinimumValue() { + final String validationMessage =3D format(MSG_OUTPUT_NOT_BETWEEN_EXPECTE= D_VALUES_PREFORMATTED, LOC_INPUT_AGE); + typeAndBlur(LOC_INPUT_AGE, MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), validationMessage); } = + /** + * Try input age greater than maximum and checks that the validation mess= age + * will appear. + */ @Test - public void ageMaximumValue() { - openPage(); - typeAndBlur(age, getMess("long-range--above")); - waitForTextEquals(getMessageFor(age), formatMess("long-range", age)); + public void testAgeMaximumValue() { + final String validationMessage =3D format(MSG_OUTPUT_NOT_BETWEEN_EXPECTE= D_VALUES_PREFORMATTED, LOC_INPUT_AGE); + typeAndBlur(LOC_INPUT_AGE, MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), validationMessage); } = + /** + * Try input age as non-Integer (alphabetical chars) and checks that + * validation message will appear. + */ @Test - public void ageIntegerOnly() { - openPage(); - typeAndBlur(age, getMess("age-integer-only--enter")); - waitForTextEquals(getMessageFor(age), formatMess("age-integer-only", - age)); + public void testAgeIntegerOnly() { + final String validationMessage =3D format(MSG_OUTPUT_IS_NOT_NUMBER_PREFO= RMATTED, LOC_INPUT_AGE); + typeAndBlur(LOC_INPUT_AGE, MSG_INPUT_IS_NOT_NUMBER); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), validationMessage); } = + /** + * Try input no input first and wait for validation message appears and t= hen + * type a valid input and checks that validation message will disappear. + */ @Test - public void ageMessageDisappers() { - ageValueRequired(); - typeAndBlur(age, getMess("valid-age")); - waitForTextEquals(getMessageFor(age), ""); + public void testAgeMessageDisappers() { + // first violate validation error + testAgeValueRequired(); + // then try valid input + typeAndBlur(LOC_INPUT_AGE, MSG_INPUT_VALID_AGE); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), ""); } } Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locator= s.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.prop= erties 2009-09-03 11:13:01 UTC (rev 15445) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.prop= erties 2009-09-03 11:15:21 UTC (rev 15446) @@ -1,6 +1,6 @@ -name=3DajaxValidatorForm\:name -age=3DajaxValidatorForm\:age -hibernateName=3DajaxValidatorForm2\:name -hibernateAge=3DajaxValidatorForm2\:age -hibernateEmail=3DajaxValidatorForm2\:email -relativeMessageLink=3D//input[@id\=3D'%s']/../../td[3]/*[1][@class\=3D'ric= h-message'] +VALIDATION_MESSAGE_RELATIVE=3D//input[@id\=3D'{0}']/../../td[3]/*[1][@clas= s\=3D'rich-message'] +INPUT_NAME=3DajaxValidatorForm\:name +INPUT_AGE=3DajaxValidatorForm\:age +INPUT_HIBERNATE_NAME=3DajaxValidatorForm2\:name +INPUT_HIBERNATE_AGE=3DajaxValidatorForm2\:age +INPUT_HIBERNATE_EMAIL=3DajaxValidatorForm2\:email Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/message= s.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.prop= erties 2009-09-03 11:13:01 UTC (rev 15445) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.prop= erties 2009-09-03 11:15:21 UTC (rev 15446) @@ -1,25 +1,26 @@ -value-required=3D{0}\: Validation Error\: Value is required. -less-than-minimum=3D{0}\: Validation Error\: Value is less than allowable = minimum of '3' -less-than-minimum--enter=3D12 -greater-than-maximum=3D{0}\: Validation Error\: Value is greater than allo= wable maximum of '12' -greater-than-maximum--enter=3D1234567890123 -valid-name=3DSam -long-range--bellow=3D17 -long-range--above=3D100 -long-range=3D{0}\: Validation Error\: Specified attribute is not between t= he expected values of 18 and 99. -valid-age=3D18 -bean-name--length=3Dlength must be between 3 and 12 -bad-email-1=3Dcorporation.com -bad-email-2=3D@corporation.com -well-formed-email=3Demail(a)corporation.com -bean-name--not-empty=3DThis string contain only spaces -bean-name--valid-input=3DSam Hawkings -bean-age--min=3Dmust be greater than or equal to 18 -bean-age--max--enter=3D101 -bean-age--max=3Dmust be less than or equal to 100 -age-integer-only--enter=3Dabc -age-integer-only=3D{0}\: 'abc' is not a number. Example\: 99 -bean-age--integer-only=3D{0}\: 'abc' must be a number between -2147483648 = and 2147483647 Example\: 9346 -may-not-be-null-or-empty=3Dmay not be null or empty -not-well-formed-email=3Dnot a well-formed email address -may-not-be-null=3Dmay not be null +INPUT_VALUE_IS_LESS_THAN_MINIMUM=3D12 +INPUT_VALUE_IS_GREATER_THAN_MAXIMUM=3D1234567890123 +INPUT_VALID_NAME=3DSam +INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW=3D17 +INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE=3D100 +INPUT_IS_NOT_NUMBER=3Dabc +INPUT_VALID_AGE=3D18 +OUTPUT_VALUE_REQUIRED=3D{0}\: Validation Error\: Value is required. +OUTPUT_VALUE_IS_LESS_THAN_MINIMUM=3D{0}\: Validation Error\: Value is less= than allowable minimum of '3' +OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTED=3D{0}\: Validation Error= \: Value is greater than allowable maximum of '12' +OUTPUT_NOT_BETWEEN_EXPECTED_VALUES_PREFORMATTED=3D{0}\: Validation Error\:= Specified attribute is not between the expected values of 18 and 99. +OUTPUT_IS_NOT_NUMBER_PREFORMATTED=3D{0}\: 'abc' is not a number. Example\:= 99 +OUTPUT_LENGTH_MUST_BE_BETWEEN=3Dlength must be between 3 and 12 +OUTPUT_STRING_CONTAIN_ONLY_SPACES=3DThis string contain only spaces +INPUT_HIBERNATE_VALID_INPUT=3DSam Hawkings +INPUT_NOT_WELL_FORMED_EMAIL_1=3Dcorporation.com +INPUT_NOT_WELL_FORMED_EMAIL_2=3D@corporation.com +INPUT_WELL_FORMED_EMAIL=3Demail(a)corporation.com +INPUT_MUST_BE_GREATER_THAN_OR_EQUAL=3D17 +INPUT_MUST_BE_LESS_THAN_OR_EQUAL=3D101 +OUTPUT_MAY_NOT_BE_NULL=3Dmay not be null +OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL=3Dmust be greater than or equal to 18 +OUTPUT_MUST_BE_LESS_THAN_OR_EQUAL=3Dmust be less than or equal to 100 +OUTPUT_MUST_BE_A_NUMBER=3D{0}\: 'abc' must be a number between -2147483648= and 2147483647 Example\: 9346 +OUTPUT_MAY_NOT_BE_NULL_OR_EMPTY=3Dmay not be null or empty +OUTPUT_NOT_WELL_FORMED_EMAIL=3Dnot a well-formed email address --===============6565832361066880731==--