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/GraphValidatorAfterModelUpdateTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/messages.properties
Log:
- refactored Graph Validator test cases to follow conventions
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java 2009-09-03
11:46:29 UTC (rev 15447)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.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-1301 USA
+ */
package org.jboss.richfaces.integrationTest.graphValidator;
-import junit.framework.Assert;
+import static org.testng.Assert.*;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class GraphValidatorAfterModelUpdateTestCase extends
- AbstractSeleniumRichfacesTestCase {
+public class GraphValidatorAfterModelUpdateTestCase extends
AbstractSeleniumRichfacesTestCase {
+ private final String LOC_FIELDSET_HEADER_ACTIVITIES =
getLoc("LOC_FIELDSET_HEADER_ACTIVITIES");
+ private final String LOC_BUTTON_SUBMIT_ACTIVITIES =
getLoc("BUTTON_SUBMIT_ACTIVITIES");
+ private final String LOC_OUTPUT_VALIDATION_MESSAGE =
getLoc("OUTPUT_VALIDATION_MESSAGE");
+ private final String LOC_CLASS_VALIDATION_MESSAGE =
getLoc("CLASS_VALIDATION_MESSAGE");
+ private final String LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED =
getLoc("INPUT_ACTIVITY_HOURS_PREFORMATTED");
+
+ private final String MSG_CLASS_VALID = getMsg("CLASS_VALID");
+ private final String MSG_CLASS_INVALID = getMsg("CLASS_INVALID");
+ private final String MSG_INPUT_VALID = getMsg("INPUT_VALID");
+ private final String MSG_INPUT_INVALID_TOO_GREAT =
getMsg("INPUT_INVALID_TOO_GREAT");
+ private final String MSG_INPUT_INVALID_SUM_TOO_GREAT =
getMsg("INPUT_INVALID_SUM_TOO_GREAT");
+ private final String MSG_OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY =
getMsg("OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY");
+ private final String MSG_OUTPUT_CHANGES_STORED_SUCCESSFULLY =
getMsg("OUTPUT_CHANGES_STORED_SUCCESSFULLY");
+ private final String MSG_OUTPUT_INVALID_VALUES =
getMsg("OUTPUT_INVALID_VALUES");
+ private final String MSG_OUTPUT_INVALID_SUM_TOO_GREAT =
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=graphValidator&tab=usage");
- scrollIntoView(header, true);
- }
-
- private String header = getLoc("graph-validator--header2");
- private String buttonSubmit = getLoc("graph-validator--button--submit2");
- private String validationMessage =
getLoc("graph-validator--output--validation-message");
- private String validationMessageClass =
getLoc("graph-validator--attribute--validation-message-class");
- private String activityTimes =
getLoc("graph-validator--input--activity-times");
- private String validMessageClass =
getMess("graph-validator--attribute--class-valid");
- private String invalidMessageClass =
getMess("graph-validator--attribute--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_INPUT_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 message
+ * appear
+ */
@Test
- public void oneValueTooGreatTest() {
- openPage();
+ public void testOneValueTooGreat() {
+ typeAndSubmit(format(LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED, 1),
MSG_INPUT_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 = 1; i <= 3; i++) {
- selenium.type(format(activityTimes, i),
- getMess("graph-validator--input--sum-too-great"));
+ selenium.type(format(LOC_INPUT_ACTIVITY_HOURS_PREFORMATTED, i),
MSG_INPUT_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), className,
+ "Validation message's class is invalid");
+ assertEquals(selenium.getText(LOC_OUTPUT_VALIDATION_MESSAGE), text, "Given
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/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java 2009-09-03
11:46:29 UTC (rev 15447)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.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-1301 USA
+ */
package org.jboss.richfaces.integrationTest.graphValidator;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -8,144 +29,208 @@
* @version $Revision$
*/
public class GraphValidatorTestCase extends AbstractSeleniumRichfacesTestCase {
+
+ private String LOC_FIELDSET_HEADER_USEF_INFO =
getLoc("FIELDSET_HEADER_USEF_INFO");
+ private String LOC_BUTTON_SUBMIT_USER_INFO =
getLoc("BUTTON_SUBMIT_USER_INFO");
+ private String LOC_VALIDATION_MESSAGE_RELATIVE =
getLoc("VALIDATION_MESSAGE_RELATIVE");
+ private String LOC_INPUT_NAME = getLoc("INPUT_NAME");
+ private String LOC_INPUT_AGE = getLoc("INPUT_AGE");
+ private String LOC_INPUT_EMAIL = getLoc("INPUT_EMAIL");
+
+ private final String MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM =
getMsg("INPUT_VALUE_IS_LESS_THAN_MINIMUM");
+ private final String MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM =
getMsg("INPUT_VALUE_IS_GREATER_THAN_MAXIMUM");
+ private final String MSG_INPUT_VALID_NAME = getMsg("INPUT_VALID_NAME");
+ private final String MSG_INPUT_MUST_BE_GREATER_THAN_OR_EQUAL =
getMsg("INPUT_MUST_BE_GREATER_THAN_OR_EQUAL");
+ private final String MSG_INPUT_MUST_BE_LESS_THAN_OR_EQUAL =
getMsg("INPUT_MUST_BE_LESS_THAN_OR_EQUAL");
+ private final String MSG_INPUT_IS_NOT_NUMBER = getMsg("INPUT_IS_NOT_NUMBER");
+ private final String MSG_INPUT_VALID_AGE = getMsg("INPUT_VALID_AGE");
+ private final String MSG_INPUT_NOT_WELL_FORMED_EMAIL_1 =
getMsg("INPUT_NOT_WELL_FORMED_EMAIL_1");
+ private final String MSG_INPUT_NOT_WELL_FORMED_EMAIL_2 =
getMsg("INPUT_NOT_WELL_FORMED_EMAIL_2");
+ private final String MSG_INPUT_WELL_FORMED_EMAIL =
getMsg("INPUT_WELL_FORMED_EMAIL");
+ private final String MSG_OUTPUT_LENGTH_MUST_BE_BETWEEN =
getMsg("OUTPUT_LENGTH_MUST_BE_BETWEEN");
+ private final String MSG_OUTPUT_STRING_CONTAIN_ONLY_SPACES =
getMsg("OUTPUT_STRING_CONTAIN_ONLY_SPACES");
+ private final String MSG_OUTPUT_MAY_NOT_BE_NULL =
getMsg("OUTPUT_MAY_NOT_BE_NULL");
+ private final String MSG_OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL =
getMsg("OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL");
+ private final String MSG_OUTPUT_MUST_BE_LESS_THAN_OR_EQUAL =
getMsg("OUTPUT_MUST_BE_LESS_THAN_OR_EQUAL");
+ private final String MSG_OUTPUT_MUST_BE_A_NUMBER =
getMsg("OUTPUT_MUST_BE_A_NUMBER");
+ private final String MSG_OUTPUT_MAY_NOT_BE_NULL_OR_EMPTY =
getMsg("OUTPUT_MAY_NOT_BE_NULL_OR_EMPTY");
+ private final String MSG_OUTPUT_NOT_WELL_FORMED_EMAIL =
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=graphValidator&tab=usage");
- scrollIntoView(header, true);
+ @Test
+ public void testNameValueRequired() {
+ final String validationMessage = 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 = getLoc("graph-validator--header1");
- private String buttonSubmit = getLoc("graph-validator--button--submit1");
- private String inputName = getLoc("graph-validator--input--name");
- private String inputEmail = getLoc("graph-validator--input--email");
- private String inputAge = getLoc("graph-validator--input--age");
- private String relativeValidationMessage =
getLoc("graph-validator--relative--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_CONTAIN_ONLY_SPACES);
}
+ /**
+ * Try type the invalid name input and checks that after typing valid input
+ * 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_NULL);
}
+ /**
+ * 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 message
+ * 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_GREATER_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 = format(MSG_OUTPUT_MUST_BE_A_NUMBER, LOC_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 then
+ * 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_FORMED_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_FORMED_EMAIL);
}
+ /**
+ * Enter bad email address (only @ char with domain name suffix) and checks
+ * 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_FORMED_EMAIL);
}
+ /**
+ * Enter bad email address, wait for validation message appear and then try
+ * 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/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties 2009-09-03
11:46:29 UTC (rev 15447)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties 2009-09-03
12:19:04 UTC (rev 15448)
@@ -1,11 +1,11 @@
-graph-validator--header1=//fieldset[1]//legend[text()\='Title']
-graph-validator--input--name=//input[@id\='graphValidatorForm\:name']
-graph-validator--input--email=//input[@id\='graphValidatorForm\:email']
-graph-validator--input--age=//input[@id\='graphValidatorForm\:age']
-graph-validator--relative--validation-message={0}/../../td[3]/*[1][@class\='rich-message']
-graph-validator--button--submit1=//input[@type\='button' and @value\='Store
changes']
-graph-validator--header2=//fieldset[2]//legend[text()\='Title']
-graph-validator--button--submit2=//input[@type\='button' and @value\='Store
my details']
-graph-validator--output--validation-message=//form[@name\="graphValidatorForm2"]//*[@class\="rich-messages-label"]
-graph-validator--attribute--validation-message-class=//form[@name\="graphValidatorForm2"]/*[@class\="rich-messages"]/*/@class
-graph-validator--input--activity-times=//form[@id\='graphValidatorForm2']/table/tbody/tr[{0}]//input[@type\='text']
+FIELDSET_HEADER_USEF_INFO=//fieldset[1]//legend[text()\='Title']
+BUTTON_SUBMIT_USER_INFO=//input[@type\='button' and @value\='Store
changes']
+INPUT_NAME=graphValidatorForm\:name
+INPUT_AGE=graphValidatorForm\:age
+INPUT_EMAIL=graphValidatorForm\:email
+VALIDATION_MESSAGE_RELATIVE=//input[@id\='{0}']/../../td[3]/*[1][(a)class\='rich-message']
+LOC_FIELDSET_HEADER_ACTIVITIES=//fieldset[2]//legend[text()\='Title']
+BUTTON_SUBMIT_ACTIVITIES=//input[@type\='button' and @value\='Store my
details']
+OUTPUT_VALIDATION_MESSAGE=//form[@name\="graphValidatorForm2"]//*[@class\="rich-messages-label"]
+CLASS_VALIDATION_MESSAGE=//form[@name\="graphValidatorForm2"]/*[@class\="rich-messages"]/*/@class
+INPUT_ACTIVITY_HOURS_PREFORMATTED=//form[@id\='graphValidatorForm2']/table/tbody/tr[{0}]//input[@type\='text']
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/messages.properties 2009-09-03
11:46:29 UTC (rev 15447)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/messages.properties 2009-09-03
12:19:04 UTC (rev 15448)
@@ -1,27 +1,27 @@
-graph-validator--attribute--class-valid=green
-graph-validator--attribute--class-invalid=red
-graph-validator--message--please-fill-at-least-one-entry=Invalid values\: Please feel at
list one entry
-graph-validator--message--changes-stored-successfully=Changes Stored Successfully
-graph-validator--message--invalid-values=Invalid values\:
-graph-validator--message--sum-too-great=Invalid values\: Only 24h in a day\!
-graph-validator--input--ok=1
-graph-validator--input--too-great=13
-graph-validator--input--sum-too-great=9
-may-not-be-null-or-empty=may not be null or empty
-less-than-minimum--enter=12
-bean-name--length=length must be between 3 and 12
-greater-than-maximum--enter=1234567890123
-less-than-minimum-of-2={0}\: Validation Error\: Value is less than allowable minimum of
'2'
-bean-name--valid-input=Sam Hawkings
-may-not-be-null=may not be null
-long-range--bellow=17
-bean-age--min=must be greater than or equal to 18
-bean-age--max--enter=101
-bean-age--max=must be less than or equal to 100
-age-integer-only--enter=abc
-bean-age--integer-only={0}\: 'abc' must be a number between -2147483648 and
2147483647 Example\: 9346
-valid-age=18
-not-well-formed-email=not a well-formed email address
-well-formed-email=email(a)corporation.com
-bad-email-1=corporation.com
-bad-email-2=(a)corporation.com
+CLASS_VALID=green
+CLASS_INVALID=red
+OUTPUT_PLEASE_FILL_AT_LEAST_ONE_ENTRY=Invalid values\: Please feel at list one entry
+OUTPUT_CHANGES_STORED_SUCCESSFULLY=Changes Stored Successfully
+OUTPUT_INVALID_VALUES=Invalid values\:
+OUTPUT_INVALID_SUM_TOO_GREAT=Invalid values\: Only 24h in a day\!
+INPUT_VALID=1
+INPUT_INVALID_TOO_GREAT=13
+INPUT_INVALID_SUM_TOO_GREAT=9
+INPUT_VALUE_IS_LESS_THAN_MINIMUM=12
+INPUT_VALUE_IS_GREATER_THAN_MAXIMUM=1234567890123
+INPUT_IS_NOT_NUMBER=abc
+INPUT_VALID_AGE=18
+INPUT_VALID_NAME=Sam Hawkings
+INPUT_NOT_WELL_FORMED_EMAIL_1=corporation.com
+INPUT_NOT_WELL_FORMED_EMAIL_2=(a)corporation.com
+INPUT_WELL_FORMED_EMAIL=email(a)corporation.com
+INPUT_MUST_BE_GREATER_THAN_OR_EQUAL=17
+INPUT_MUST_BE_LESS_THAN_OR_EQUAL=101
+OUTPUT_STRING_CONTAIN_ONLY_SPACES=This string contain only spaces
+OUTPUT_LENGTH_MUST_BE_BETWEEN=length must be between 3 and 12
+OUTPUT_MAY_NOT_BE_NULL=may not be null
+OUTPUT_MUST_BE_GREATER_THAN_OR_EQUAL=must be greater than or equal to 18
+OUTPUT_MUST_BE_LESS_THAN_OR_EQUAL=must be less than or equal to 100
+OUTPUT_MUST_BE_A_NUMBER={0}\: 'abc' must be a number between -2147483648 and
2147483647 Example\: 9346
+OUTPUT_MAY_NOT_BE_NULL_OR_EMPTY=may not be null or empty
+OUTPUT_NOT_WELL_FORMED_EMAIL=not a well-formed email address