From richfaces-svn-commits at lists.jboss.org Thu Sep 3 08:19:04 2009 Content-Type: multipart/mixed; boundary="===============7414164623547284859==" 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: r15448 - in branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test: resources/org/jboss/richfaces/integrationTest/graphValidator and 1 other directory. Date: Thu, 03 Sep 2009 08:19:04 -0400 Message-ID: <200909031219.n83CJ435023760@svn01.web.mwc.hst.phx2.redhat.com> --===============7414164623547284859== 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 08:19:04 -0400 (Thu, 03 Sep 2009) New Revision: 15448 Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfte= rModelUpdateTestCase.java branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTest= Case.java branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /resources/org/jboss/richfaces/integrationTest/graphValidator/locators.prop= erties branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test= /resources/org/jboss/richfaces/integrationTest/graphValidator/messages.prop= erties Log: - refactored Graph 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/graphValidator/GraphValida= torAfterModelUpdateTestCase.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/graphValidator/GraphValidatorAft= erModelUpdateTestCase.java 2009-09-03 11:46:29 UTC (rev 15447) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAft= erModelUpdateTestCase.java 2009-09-03 12:19:04 UTC (rev 15448) @@ -1,103 +1,126 @@ +/** + * 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.graphValidator; = -import junit.framework.Assert; +import static org.testng.Assert.*; = import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCa= se; import org.jboss.test.selenium.waiting.Condition; import org.jboss.test.selenium.waiting.Wait; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = /** * @author Lukas Fryc * @version $Revision$ */ -public class GraphValidatorAfterModelUpdateTestCase extends - AbstractSeleniumRichfacesTestCase { +public class GraphValidatorAfterModelUpdateTestCase extends AbstractSeleni= umRichfacesTestCase { + private final String LOC_FIELDSET_HEADER_ACTIVITIES =3D getLoc("LOC_FIELD= SET_HEADER_ACTIVITIES"); + private final String LOC_BUTTON_SUBMIT_ACTIVITIES =3D getLoc("BUTTON_SUBM= IT_ACTIVITIES"); + private final String LOC_OUTPUT_VALIDATION_MESSAGE =3D getLoc("OUTPUT_VAL= IDATION_MESSAGE"); + private final String LOC_CLASS_VALIDATION_MESSAGE =3D getLoc("CLASS_VALID= ATION_MESSAGE"); + private final String LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED =3D getLoc("IN= PUT_ACTIVITY_HOURS_PREFORMATTED"); + + private final String MSG_CLASS_VALID =3D getMsg("CLASS_VALID"); + private final String MSG_CLASS_INVALID =3D getMsg("CLASS_INVALID"); + private final String MSG_INPUT_VALID =3D getMsg("INPUT_VALID"); + private final String MSG_INPUT_INVALID_TOO_GREAT =3D getMsg("INPUT_INVALI= D_TOO_GREAT"); + private final String MSG_INPUT_INVALID_SUM_TOO_GREAT =3D getMsg("INPUT_IN= VALID_SUM_TOO_GREAT"); + private final String MSG_OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY =3D getMsg= ("OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY"); + private final String MSG_OUTPUT_CHANGES_STORED_SUCCESSFULLY =3D getMsg("O= UTPUT_CHANGES_STORED_SUCCESSFULLY"); + private final String MSG_OUTPUT_INVALID_VALUES =3D getMsg("OUTPUT_INVALID= _VALUES"); + private final String MSG_OUTPUT_INVALID_SUM_TOO_GREAT =3D getMsg("OUTPUT_= INVALID_SUM_TOO_GREAT"); + /** - * Opens specified page + * Do no changes to form and checks that validate message 'Please fill at + * least one entry' appear */ - public void openPage() { - selenium.open(contextPath - + "/richfaces/graphValidator.jsf?c=3DgraphValidator&tab=3Dusage"); - scrollIntoView(header, true); - } - - private String header =3D getLoc("graph-validator--header2"); - private String buttonSubmit =3D getLoc("graph-validator--button--submit2"= ); - private String validationMessage =3D getLoc("graph-validator--output--val= idation-message"); - private String validationMessageClass =3D getLoc("graph-validator--attrib= ute--validation-message-class"); - private String activityTimes =3D getLoc("graph-validator--input--activity= -times"); - private String validMessageClass =3D getMess("graph-validator--attribute-= -class-valid"); - private String invalidMessageClass =3D getMess("graph-validator--attribut= e--class-invalid"); - @Test - public void noChangeIntoFormTest() { - openPage(); - + public void testNoChangeIntoForm() { submitAndWaitForMessageAppears(); = - validateMessages( - invalidMessageClass, - getMess("graph-validator--message--please-fill-at-least-one-entry")); + validateMessages(MSG_CLASS_INVALID, MSG_OUTPUT_PLEASE_FILL_AT_LEAST_ONE_= ENTRY); } = + /** + * Enter first input and checks that changes will store successfully + */ @Test - public void changeStoredSuccessfullyTest() { - openPage(); + public void testChangeStoredSuccessfully() { + typeAndSubmit(format(LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED, 1), MSG_INPU= T_VALID); = - typeAndSubmit(format(activityTimes, 1), - getMess("graph-validator--input--ok")); - - validateMessages( - validMessageClass, - getMess("graph-validator--message--changes-stored-successfully")); + validateMessages(MSG_CLASS_VALID, MSG_OUTPUT_CHANGES_STORED_SUCCESSFULLY= ); } = + /** + * Enter only one value that is too great and checks that validation mess= age + * appear + */ @Test - public void oneValueTooGreatTest() { - openPage(); + public void testOneValueTooGreat() { + typeAndSubmit(format(LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED, 1), MSG_INPU= T_INVALID_TOO_GREAT); = - typeAndSubmit(format(activityTimes, 1), - getMess("graph-validator--input--too-great")); - - validateMessages(invalidMessageClass, - getMess("graph-validator--message--invalid-values")); + validateMessages(MSG_CLASS_INVALID, MSG_OUTPUT_INVALID_VALUES); } = + /** + * Enter several values, which is in sum greater than allow maximum and + * checks that validation message appear. + */ @Test - public void sumOfValuesTooGreatTest() { - openPage(); - + public void testSumOfValuesTooGreat() { for (int i =3D 1; i <=3D 3; i++) { - selenium.type(format(activityTimes, i), - getMess("graph-validator--input--sum-too-great")); + selenium.type(format(LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED, i), MSG_INP= UT_INVALID_SUM_TOO_GREAT); } submitAndWaitForMessageAppears(); = - validateMessages(invalidMessageClass, - getMess("graph-validator--message--sum-too-great")); + validateMessages(MSG_CLASS_INVALID, MSG_OUTPUT_INVALID_SUM_TOO_GREAT); } = - /* HELP METHODS */ - private void typeAndSubmit(String locator, String text) { selenium.type(locator, text); submitAndWaitForMessageAppears(); } = private void submitAndWaitForMessageAppears() { - selenium.click(buttonSubmit); + selenium.click(LOC_BUTTON_SUBMIT_ACTIVITIES); = - Wait.until(new Condition() { + Wait.failWith("Validation message never appeared").until(new Condition()= { public boolean isTrue() { - return selenium.isElementPresent(validationMessage); + return selenium.isElementPresent(LOC_OUTPUT_VALIDATION_MESSAGE); } }); } = private void validateMessages(String className, String text) { - Assert.assertEquals(className, selenium - .getAttribute(validationMessageClass)); - Assert.assertEquals(text, selenium.getText(validationMessage)); + assertEquals(selenium.getAttribute(LOC_CLASS_VALIDATION_MESSAGE), classN= ame, + "Validation message's class is invalid"); + assertEquals(selenium.getText(LOC_OUTPUT_VALIDATION_MESSAGE), text, "Giv= en validation message isn't expected"); } + + @SuppressWarnings("unused") + @BeforeMethod + private void loadPage() { + openComponent("Graph Validator"); + + scrollIntoView(LOC_FIELDSET_HEADER_ACTIVITIES, true); + } } Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValida= torTestCase.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/graphValidator/GraphValidatorTes= tCase.java 2009-09-03 11:46:29 UTC (rev 15447) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTes= tCase.java 2009-09-03 12:19:04 UTC (rev 15448) @@ -1,6 +1,27 @@ +/** + * 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.graphValidator; = import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCa= se; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = /** @@ -8,144 +29,208 @@ * @version $Revision$ */ public class GraphValidatorTestCase extends AbstractSeleniumRichfacesTestC= ase { + + private String LOC_FIELDSET_HEADER_USEF_INFO =3D getLoc("FIELDSET_HEADER_= USEF_INFO"); + private String LOC_BUTTON_SUBMIT_USER_INFO =3D getLoc("BUTTON_SUBMIT_USER= _INFO"); + private String LOC_VALIDATION_MESSAGE_RELATIVE =3D getLoc("VALIDATION_MES= SAGE_RELATIVE"); + private String LOC_INPUT_NAME =3D getLoc("INPUT_NAME"); + private String LOC_INPUT_AGE =3D getLoc("INPUT_AGE"); + private String LOC_INPUT_EMAIL =3D getLoc("INPUT_EMAIL"); + + 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_VALID_NAME =3D getMsg("INPUT_VALID_NAME"); + 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_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"); + /** - * Opens specified page + * Try type no chars in input name and checks that value required message + * will appear. */ - public void openPage() { - selenium.open(contextPath - + "/richfaces/graphValidator.jsf?c=3DgraphValidator&tab=3Dusage"); - scrollIntoView(header, true); + @Test + public void testNameValueRequired() { + final String validationMessage =3D format(MSG_OUTPUT_MAY_NOT_BE_NULL_OR_= EMPTY, LOC_INPUT_NAME); + typeAndSubmit(LOC_INPUT_NAME, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), validationMessage); } = - private String header =3D getLoc("graph-validator--header1"); - private String buttonSubmit =3D getLoc("graph-validator--button--submit1"= ); - private String inputName =3D getLoc("graph-validator--input--name"); - private String inputEmail =3D getLoc("graph-validator--input--email"); - private String inputAge =3D getLoc("graph-validator--input--age"); - private String relativeValidationMessage =3D getLoc("graph-validator--rel= ative--validation-message"); - - private void typeAndSubmit(String locator, String value) { - selenium.type(locator, value); - selenium.click(buttonSubmit); + /** + * Try type string of length less than minimum length in name input and + * checks that validation message will appear. + */ + @Test + public void testNameMinimumLength() { + typeAndSubmit(LOC_INPUT_NAME, MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), MSG_OUTPUT_LENGTH_MUST_= BE_BETWEEN); } = - public String getMessageFor(String locator) { - return format(relativeValidationMessage, locator); + /** + * Try type string of length greater than maximum length in name input and + * checks that validation message will appear. + */ + @Test + public void testNameMaximumLength() { + typeAndSubmit(LOC_INPUT_NAME, MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), MSG_OUTPUT_LENGTH_MUST_= BE_BETWEEN); } = + /** + * Enter only one space to name input and checks that validation message + * will appear. + */ @Test - public void nameValueRequired() { - openPage(); - typeAndSubmit(inputName, ""); - waitForTextEquals(getMessageFor(inputName), - getMess("may-not-be-null-or-empty")); + public void testNameOnlySpacesPattern() { + typeAndSubmit(LOC_INPUT_NAME, " "); + waitForTextEquals(getMessageFor(LOC_INPUT_NAME), MSG_OUTPUT_STRING_CONTA= IN_ONLY_SPACES); } = + /** + * Try type the invalid name input and checks that after typing valid inp= ut + * will validation message disappear. + */ @Test - public void nameMinimumLength() { - openPage(); - typeAndSubmit(inputName, getMess("less-than-minimum--enter")); - waitForTextEquals(getMessageFor(inputName), - getMess("bean-name--length")); + public void testNameMessageDisappers() { + // first violate validation error + testNameValueRequired(); + // then try valid input + typeAndSubmit(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 nameMaximumLength() { - openPage(); - typeAndSubmit(inputName, getMess("greater-than-maximum--enter")); - waitForTextEquals(getMessageFor(inputName), - getMess("bean-name--length")); + public void testAgeValueRequired() { + typeAndSubmit(LOC_INPUT_AGE, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), MSG_OUTPUT_MAY_NOT_BE_NU= LL); } = + /** + * Try input age less than minimum and checks that the validation message + * will appear. + */ @Test - public void nameOnlySpacesPattern() { - openPage(); - typeAndSubmit(inputName, " "); - waitForTextEquals(getMessageFor(inputName), formatMess( - "less-than-minimum-of-2", selenium.getAttribute(format( - "{0}/@id", inputName)))); + public void testAgeMinimumValue() { + typeAndSubmit(LOC_INPUT_AGE, MSG_INPUT_MUST_BE_LESS_THAN_OR_EQUAL); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), MSG_OUTPUT_MUST_BE_LESS_= THAN_OR_EQUAL); } = + /** + * Try input age greater than maximum and checks that the validation mess= age + * will appear. + */ @Test - public void nameMessageDisappers() { - nameValueRequired(); - typeAndSubmit(inputName, getMess("bean-name--valid-input")); - waitForTextEquals(getMessageFor(inputName), ""); + public void testAgeMaximumValue() { + typeAndSubmit(LOC_INPUT_AGE, MSG_INPUT_MUST_BE_GREATER_THAN_OR_EQUAL); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), MSG_OUTPUT_MUST_BE_GREAT= ER_THAN_OR_EQUAL); } = + /** + * Try input age as non-Integer (alphabetical chars) and checks that + * validation message will appear. + */ @Test - public void ageValueRequired() { - openPage(); - typeAndSubmit(inputAge, ""); - waitForTextEquals(getMessageFor(inputAge), getMess("may-not-be-null")); + public void testAgeIntegerOnly() { + final String validationMessage =3D format(MSG_OUTPUT_MUST_BE_A_NUMBER, L= OC_INPUT_AGE); + typeAndSubmit(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 ageMinimumValue() { - openPage(); - typeAndSubmit(inputAge, getMess("long-range--bellow")); - waitForTextEquals(getMessageFor(inputAge), getMess("bean-age--min")); + public void testAgeMessageDisappers() { + // first violate validation error + testAgeValueRequired(); + // then try valid input + typeAndSubmit(LOC_INPUT_AGE, MSG_INPUT_VALID_AGE); + waitForTextEquals(getMessageFor(LOC_INPUT_AGE), ""); } = + /** + * Try to enter empty email address and checks that validation message + * appears. + */ @Test - public void ageMaximumValue() { - openPage(); - typeAndSubmit(inputAge, getMess("bean-age--max--enter")); - waitForTextEquals(getMessageFor(inputAge), getMess("bean-age--max")); + public void testEmailMayNotBeNullOrEmpty() { + typeAndSubmit(LOC_INPUT_EMAIL, ""); + waitForTextEquals(getMessageFor(LOC_INPUT_EMAIL), MSG_OUTPUT_MAY_NOT_BE_= NULL_OR_EMPTY); } = + /** + * Try to enter one space like a email address and checks that validation + * message appears. + */ @Test - public void ageIntegerOnly() { - openPage(); - typeAndSubmit(inputAge, formatMess("age-integer-only--enter", inputAge)); - waitForTextEquals(getMessageFor(inputAge), formatMess( - "bean-age--integer-only", selenium.getAttribute(format( - "{0}/@id", inputAge)))); + public void testEmailOnlySpaces() { + typeAndSubmit(LOC_INPUT_EMAIL, " "); + waitForTextEquals(getMessageFor(LOC_INPUT_EMAIL), MSG_OUTPUT_NOT_WELL_FO= RMED_EMAIL); } = + /** + * Enter bad email address (only domain name suffix) and checks that + * validation message appears. + */ @Test - public void ageMessageDisappers() { - ageValueRequired(); - typeAndSubmit(inputAge, getMess("valid-age")); - waitForTextEquals(getMessageFor(inputAge), ""); + public void testEmailBad1() { + typeAndSubmit(LOC_INPUT_EMAIL, MSG_INPUT_NOT_WELL_FORMED_EMAIL_1); + waitForTextEquals(getMessageFor(LOC_INPUT_EMAIL), MSG_OUTPUT_NOT_WELL_FO= RMED_EMAIL); } = + /** + * Enter bad email address (only @ char with domain name suffix) and chec= ks + * that testValidation message appears. + */ @Test - public void emailMayNotBeNullOrEmpty() { - openPage(); - typeAndSubmit(inputEmail, ""); - waitForTextEquals(getMessageFor(inputEmail), - getMess("may-not-be-null-or-empty")); + public void testEmailBad2() { + typeAndSubmit(LOC_INPUT_EMAIL, MSG_INPUT_NOT_WELL_FORMED_EMAIL_2); + waitForTextEquals(getMessageFor(LOC_INPUT_EMAIL), MSG_OUTPUT_NOT_WELL_FO= RMED_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 emailOnlySpaces() { - openPage(); - typeAndSubmit(inputEmail, " "); - waitForTextEquals(getMessageFor(inputEmail), - getMess("not-well-formed-email")); + public void testEmailMessageDisappers() { + // first violate validation error + testEmailMayNotBeNullOrEmpty(); + // then try valid input + typeAndSubmit(LOC_INPUT_EMAIL, MSG_INPUT_WELL_FORMED_EMAIL); + waitForTextEquals(getMessageFor(LOC_INPUT_EMAIL), ""); } = - @Test - public void emailBad1() { - openPage(); - typeAndSubmit(inputEmail, getMess("bad-email-1")); - waitForTextEquals(getMessageFor(inputEmail), - getMess("not-well-formed-email")); + private void typeAndSubmit(String locator, String value) { + selenium.type(locator, value); + selenium.click(LOC_BUTTON_SUBMIT_USER_INFO); } = - @Test - public void emailBad2() { - openPage(); - typeAndSubmit(inputEmail, getMess("bad-email-2")); - waitForTextEquals(getMessageFor(inputEmail), - getMess("not-well-formed-email")); + private String getMessageFor(String locator) { + return format(LOC_VALIDATION_MESSAGE_RELATIVE, locator); } = - @Test - public void emailMessageDisappers() { - emailMayNotBeNullOrEmpty(); - typeAndSubmit(inputEmail, getMess("well-formed-email")); - waitForTextEquals(getMessageFor(inputEmail), ""); + @SuppressWarnings("unused") + @BeforeMethod + private void loadPage() { + openComponent("Graph Validator"); + + scrollIntoView(LOC_FIELDSET_HEADER_USEF_INFO, true); } } Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locato= rs.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/graphValidator/locators.pro= perties 2009-09-03 11:46:29 UTC (rev 15447) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.pro= perties 2009-09-03 12:19:04 UTC (rev 15448) @@ -1,11 +1,11 @@ -graph-validator--header1=3D//fieldset[1]//legend[text()\=3D'Title'] -graph-validator--input--name=3D//input[@id\=3D'graphValidatorForm\:name'] -graph-validator--input--email=3D//input[@id\=3D'graphValidatorForm\:email'] -graph-validator--input--age=3D//input[@id\=3D'graphValidatorForm\:age'] -graph-validator--relative--validation-message=3D{0}/../../td[3]/*[1][@clas= s\=3D'rich-message'] -graph-validator--button--submit1=3D//input[@type\=3D'button' and @value\= =3D'Store changes'] -graph-validator--header2=3D//fieldset[2]//legend[text()\=3D'Title'] -graph-validator--button--submit2=3D//input[@type\=3D'button' and @value\= =3D'Store my details'] -graph-validator--output--validation-message=3D//form[@name\=3D"graphValida= torForm2"]//*[@class\=3D"rich-messages-label"] -graph-validator--attribute--validation-message-class=3D//form[@name\=3D"gr= aphValidatorForm2"]/*[@class\=3D"rich-messages"]/*/@class -graph-validator--input--activity-times=3D//form[@id\=3D'graphValidatorForm= 2']/table/tbody/tr[{0}]//input[@type\=3D'text'] +FIELDSET_HEADER_USEF_INFO=3D//fieldset[1]//legend[text()\=3D'Title'] +BUTTON_SUBMIT_USER_INFO=3D//input[@type\=3D'button' and @value\=3D'Store c= hanges'] +INPUT_NAME=3DgraphValidatorForm\:name +INPUT_AGE=3DgraphValidatorForm\:age +INPUT_EMAIL=3DgraphValidatorForm\:email +VALIDATION_MESSAGE_RELATIVE=3D//input[@id\=3D'{0}']/../../td[3]/*[1][@clas= s\=3D'rich-message'] +LOC_FIELDSET_HEADER_ACTIVITIES=3D//fieldset[2]//legend[text()\=3D'Title'] +BUTTON_SUBMIT_ACTIVITIES=3D//input[@type\=3D'button' and @value\=3D'Store = my details'] +OUTPUT_VALIDATION_MESSAGE=3D//form[@name\=3D"graphValidatorForm2"]//*[@cla= ss\=3D"rich-messages-label"] +CLASS_VALIDATION_MESSAGE=3D//form[@name\=3D"graphValidatorForm2"]/*[@class= \=3D"rich-messages"]/*/@class +INPUT_ACTIVITY_HOURS_PREFORMATTED=3D//form[@id\=3D'graphValidatorForm2']/t= able/tbody/tr[{0}]//input[@type\=3D'text'] Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/s= rc/test/resources/org/jboss/richfaces/integrationTest/graphValidator/messag= es.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/graphValidator/messages.pro= perties 2009-09-03 11:46:29 UTC (rev 15447) +++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/tes= t/resources/org/jboss/richfaces/integrationTest/graphValidator/messages.pro= perties 2009-09-03 12:19:04 UTC (rev 15448) @@ -1,27 +1,27 @@ -graph-validator--attribute--class-valid=3Dgreen -graph-validator--attribute--class-invalid=3Dred -graph-validator--message--please-fill-at-least-one-entry=3DInvalid values\= : Please feel at list one entry -graph-validator--message--changes-stored-successfully=3DChanges Stored Suc= cessfully -graph-validator--message--invalid-values=3DInvalid values\: -graph-validator--message--sum-too-great=3DInvalid values\: Only 24h in a d= ay\! -graph-validator--input--ok=3D1 -graph-validator--input--too-great=3D13 -graph-validator--input--sum-too-great=3D9 -may-not-be-null-or-empty=3Dmay not be null or empty -less-than-minimum--enter=3D12 -bean-name--length=3Dlength must be between 3 and 12 -greater-than-maximum--enter=3D1234567890123 -less-than-minimum-of-2=3D{0}\: Validation Error\: Value is less than allow= able minimum of '2' -bean-name--valid-input=3DSam Hawkings -may-not-be-null=3Dmay not be null -long-range--bellow=3D17 -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 -bean-age--integer-only=3D{0}\: 'abc' must be a number between -2147483648 = and 2147483647 Example\: 9346 -valid-age=3D18 -not-well-formed-email=3Dnot a well-formed email address -well-formed-email=3Demail(a)corporation.com -bad-email-1=3Dcorporation.com -bad-email-2=3D@corporation.com +CLASS_VALID=3Dgreen +CLASS_INVALID=3Dred +OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY=3DInvalid values\: Please feel at li= st one entry +OUTPUT_CHANGES_STORED_SUCCESSFULLY=3DChanges Stored Successfully +OUTPUT_INVALID_VALUES=3DInvalid values\: +OUTPUT_INVALID_SUM_TOO_GREAT=3DInvalid values\: Only 24h in a day\! +INPUT_VALID=3D1 +INPUT_INVALID_TOO_GREAT=3D13 +INPUT_INVALID_SUM_TOO_GREAT=3D9 +INPUT_VALUE_IS_LESS_THAN_MINIMUM=3D12 +INPUT_VALUE_IS_GREATER_THAN_MAXIMUM=3D1234567890123 +INPUT_IS_NOT_NUMBER=3Dabc +INPUT_VALID_AGE=3D18 +INPUT_VALID_NAME=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_STRING_CONTAIN_ONLY_SPACES=3DThis string contain only spaces +OUTPUT_LENGTH_MUST_BE_BETWEEN=3Dlength must be between 3 and 12 +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 --===============7414164623547284859==--