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/AbstractAjaxValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHibernatePartTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.properties
Log:
- refactored Ajax Validator test cases to follow conventions
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java 2009-09-03
11:13:01 UTC (rev 15445)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.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-1301 USA
+ */
package org.jboss.richfaces.integrationTest.ajaxValidator;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
-import org.testng.Assert;
+import org.jboss.test.selenium.dom.Event;
+import org.testng.annotations.BeforeMethod;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class AbstractAjaxValidatorTestCase extends
- AbstractSeleniumRichfacesTestCase {
+public class AbstractAjaxValidatorTestCase extends AbstractSeleniumRichfacesTestCase {
+ private final String LOC_VALIDATION_MESSAGE_RELATIVE =
getLoc("VALIDATION_MESSAGE_RELATIVE");
+
/**
- * Opens specified page
+ * Opens specified component's page before each test method
*/
- public void openPage() {
- selenium.open(contextPath
- + "/richfaces/ajaxValidator.jsf?c=ajaxValidator&tab=usage");
+ @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/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHibernatePartTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHibernatePartTestCase.java 2009-09-03
11:13:01 UTC (rev 15445)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorHibernatePartTestCase.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-1301 USA
+ */
package org.jboss.richfaces.integrationTest.ajaxValidator;
import org.testng.annotations.Test;
@@ -6,125 +26,190 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class AjaxValidatorHibernatePartTestCase extends
- AbstractAjaxValidatorTestCase {
+public class AjaxValidatorHibernatePartTestCase extends AbstractAjaxValidatorTestCase {
- /* COMPONENTS */
+ private final String LOC_INPUT_HIBERNATE_NAME =
getLoc("INPUT_HIBERNATE_NAME");
+ private final String LOC_INPUT_HIBERNATE_AGE = getLoc("INPUT_HIBERNATE_AGE");
+ private final String LOC_INPUT_HIBERNATE_EMAIL =
getLoc("INPUT_HIBERNATE_EMAIL");
- private final String name = getLoc("hibernateName");
- private final String age = getLoc("hibernateAge");
- private final String email = getLoc("hibernateEmail");
+ 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_HIBERNATE_VALID_INPUT =
getMsg("INPUT_HIBERNATE_VALID_INPUT");
+ 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_VALUE_REQUIRED_PREFORMATTED =
getMsg("OUTPUT_VALUE_REQUIRED");
+ 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");
- /* 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 = format(MSG_OUTPUT_VALUE_REQUIRED_PREFORMATTED,
LOC_INPUT_HIBERNATE_NAME);
+ typeAndBlur(LOC_INPUT_HIBERNATE_NAME, "");
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_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), getMess("bean-name--length"));
+ public void testNameMinimumLength() {
+ typeAndBlur(LOC_INPUT_HIBERNATE_NAME, MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM);
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME),
MSG_OUTPUT_LENGTH_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_MAXIMUM);
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_NAME),
MSG_OUTPUT_LENGTH_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_STRING_CONTAIN_ONLY_SPACES);
}
+ /**
+ * Try type the invalid name input and checks that after typing valid input
+ * 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_EQUAL);
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_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 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_EQUAL);
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_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 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 = format(MSG_OUTPUT_MUST_BE_A_NUMBER,
LOC_INPUT_HIBERNATE_AGE);
+ typeAndBlur(LOC_INPUT_HIBERNATE_AGE, MSG_INPUT_IS_NOT_NUMBER);
+ waitForTextEquals(getMessageFor(LOC_INPUT_HIBERNATE_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 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_MAY_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_NOT_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_NOT_WELL_FORMED_EMAIL);
}
+ /**
+ * Enter bad email address (only @ char with domain name suffix) and checks
+ * 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_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 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/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestCase.java 2009-09-03
11:13:01 UTC (rev 15445)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AjaxValidatorTestCase.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 <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
+ * @version test$Revision$
*/
public class AjaxValidatorTestCase extends AbstractAjaxValidatorTestCase {
- /* COMPONENTS */
+ private final String LOC_INPUT_NAME = getLoc("INPUT_NAME");
+ private final String LOC_INPUT_AGE = getLoc("INPUT_AGE");
- private final String name = getLoc("name");
- private final String age = getLoc("age");
+ private final String MSG_INPUT_VALUE_IS_GREATER_THAN_MAXIMUM =
getMsg("INPUT_VALUE_IS_GREATER_THAN_MAXIMUM");
+ private final String MSG_INPUT_VALUE_IS_LESS_THAN_MINIMUM =
getMsg("INPUT_VALUE_IS_LESS_THAN_MINIMUM");
+ private final String MSG_INPUT_VALID_NAME = getMsg("INPUT_VALID_NAME");
+ private final String MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW =
getMsg("INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW");
+ private final String MSG_INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE =
getMsg("INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE");
+ 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_OUTPUT_VALUE_REQUIRED_PREFORMATTED =
getMsg("OUTPUT_VALUE_REQUIRED");
+ private final String MSG_OUTPUT_VALUE_IS_LESS_THAN_MINIMUM =
getMsg("OUTPUT_VALUE_IS_LESS_THAN_MINIMUM");
+ private final String MSG_OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTED =
getMsg("OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTED");
+ private final String MSG_OUTPUT_IS_NOT_NUMBER_PREFORMATTED =
getMsg("OUTPUT_IS_NOT_NUMBER_PREFORMATTED");
+ private final String MSG_OUTPUT_NOT_BETWEEN_EXPECTED_VALUES_PREFORMATTED =
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 = format(MSG_OUTPUT_VALUE_REQUIRED_PREFORMATTED,
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 = 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 =
format(MSG_OUTPUT_VALUE_IS_GREATER_THAN_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 input
+ * 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 = format(MSG_OUTPUT_VALUE_REQUIRED_PREFORMATTED,
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 =
format(MSG_OUTPUT_NOT_BETWEEN_EXPECTED_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 message
+ * 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 =
format(MSG_OUTPUT_NOT_BETWEEN_EXPECTED_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 = format(MSG_OUTPUT_IS_NOT_NUMBER_PREFORMATTED,
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 then
+ * 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/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.properties 2009-09-03
11:13:01 UTC (rev 15445)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/locators.properties 2009-09-03
11:15:21 UTC (rev 15446)
@@ -1,6 +1,6 @@
-name=ajaxValidatorForm\:name
-age=ajaxValidatorForm\:age
-hibernateName=ajaxValidatorForm2\:name
-hibernateAge=ajaxValidatorForm2\:age
-hibernateEmail=ajaxValidatorForm2\:email
-relativeMessageLink=//input[@id\='%s']/../../td[3]/*[1][(a)class\='rich-message']
+VALIDATION_MESSAGE_RELATIVE=//input[@id\='{0}']/../../td[3]/*[1][(a)class\='rich-message']
+INPUT_NAME=ajaxValidatorForm\:name
+INPUT_AGE=ajaxValidatorForm\:age
+INPUT_HIBERNATE_NAME=ajaxValidatorForm2\:name
+INPUT_HIBERNATE_AGE=ajaxValidatorForm2\:age
+INPUT_HIBERNATE_EMAIL=ajaxValidatorForm2\:email
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.properties 2009-09-03
11:13:01 UTC (rev 15445)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/ajaxValidator/messages.properties 2009-09-03
11:15:21 UTC (rev 15446)
@@ -1,25 +1,26 @@
-value-required={0}\: Validation Error\: Value is required.
-less-than-minimum={0}\: Validation Error\: Value is less than allowable minimum of
'3'
-less-than-minimum--enter=12
-greater-than-maximum={0}\: Validation Error\: Value is greater than allowable maximum of
'12'
-greater-than-maximum--enter=1234567890123
-valid-name=Sam
-long-range--bellow=17
-long-range--above=100
-long-range={0}\: Validation Error\: Specified attribute is not between the expected
values of 18 and 99.
-valid-age=18
-bean-name--length=length must be between 3 and 12
-bad-email-1=corporation.com
-bad-email-2=(a)corporation.com
-well-formed-email=email(a)corporation.com
-bean-name--not-empty=This string contain only spaces
-bean-name--valid-input=Sam Hawkings
-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
-age-integer-only={0}\: 'abc' is not a number. Example\: 99
-bean-age--integer-only={0}\: 'abc' must be a number between -2147483648 and
2147483647 Example\: 9346
-may-not-be-null-or-empty=may not be null or empty
-not-well-formed-email=not a well-formed email address
-may-not-be-null=may not be null
+INPUT_VALUE_IS_LESS_THAN_MINIMUM=12
+INPUT_VALUE_IS_GREATER_THAN_MAXIMUM=1234567890123
+INPUT_VALID_NAME=Sam
+INPUT_NOT_BETWEEN_EXPECTED_VALUES_BELLOW=17
+INPUT_NOT_BETWEEN_EXPECTED_VALUES_ABOVE=100
+INPUT_IS_NOT_NUMBER=abc
+INPUT_VALID_AGE=18
+OUTPUT_VALUE_REQUIRED={0}\: Validation Error\: Value is required.
+OUTPUT_VALUE_IS_LESS_THAN_MINIMUM={0}\: Validation Error\: Value is less than allowable
minimum of '3'
+OUTPUT_VALUE_IS_GREATER_THAN_MAXIMUM_PREFORMATTED={0}\: Validation Error\: Value is
greater than allowable maximum of '12'
+OUTPUT_NOT_BETWEEN_EXPECTED_VALUES_PREFORMATTED={0}\: Validation Error\: Specified
attribute is not between the expected values of 18 and 99.
+OUTPUT_IS_NOT_NUMBER_PREFORMATTED={0}\: 'abc' is not a number. Example\: 99
+OUTPUT_LENGTH_MUST_BE_BETWEEN=length must be between 3 and 12
+OUTPUT_STRING_CONTAIN_ONLY_SPACES=This string contain only spaces
+INPUT_HIBERNATE_VALID_INPUT=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_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