Author: dsvyatobatsko
Date: 2008-09-22 11:07:47 -0400 (Mon, 22 Sep 2008)
New Revision: 10531
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxValidator/ajaxValidatorTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java
Log:
AjaxValidator test completed
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxValidator/ajaxValidatorTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java 2008-09-22
15:05:32 UTC (rev 10530)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java 2008-09-22
15:07:47 UTC (rev 10531)
@@ -6,11 +6,122 @@
public class AjaxValidatorTest extends SeleniumTestBase {
+ private static final String NAME = "name";
+
+ private static final String AGE = "age";
+
+ private static final String EMAIL = "email";
+
+ private static final String ERR_MSG_POSTFIX = "_err_msg";
+
@Test
- public void testAjaxValidatorComponent(Template template) {
+ public void testAjaxValidatorComponentWithStandartValidators(Template template) {
renderPage(template);
+
+ writeStatus("Check ajax validator component with standart validators.
"
+ + "Validation has to be occured by javascript event
'onblur'");
+ String parentId = getParentId() + "_form:";
+
+ String tfNameId = parentId + NAME;
+ String tfAgeId = parentId + AGE;
+
+ String tfNameErrMsg = tfNameId + ERR_MSG_POSTFIX;
+ String tfAgeErrMsg = tfAgeId + ERR_MSG_POSTFIX;
+
+ assertNotPresent(tfNameErrMsg);
+ assertNotPresent(tfAgeErrMsg);
+
+ writeStatus("Name must be between 3 and 12 at length. Type shorter
one");
+ type(tfNameId, "Mi");
+ selenium.fireEvent(tfNameId, "blur");
+ waitForAjaxCompletion();
+ assertPresent(tfNameErrMsg);
+
+ writeStatus("Age must be greater than or equal to 18. Type less than
that");
+ type(tfAgeId, "3");
+ selenium.fireEvent(tfAgeId, "blur");
+ waitForAjaxCompletion();
+ assertPresent(tfAgeErrMsg);
+
+ writeStatus("Correct the inputs and leave. Error messages have to
disappear");
+
+ type(tfNameId, "Mick");
+ selenium.fireEvent(tfNameId, "blur");
+ waitForAjaxCompletion();
+ assertNotPresent(tfNameErrMsg);
+
+ type(tfAgeId, "33");
+ selenium.fireEvent(tfAgeId, "blur");
+ waitForAjaxCompletion();
+ assertNotPresent(tfAgeErrMsg);
+
}
+ @Test
+ public void testAjaxValidatorComponentWithHibernateValidator(Template template) {
+ renderPage(template);
+
+ writeStatus("Check ajax validator component with hibernate validator.
"
+ + "Validation has to be occured by javascript event
'onblur'");
+ String parentId = getParentId() + "_form1:";
+
+ String tfNameId = parentId + NAME;
+ String tfAgeId = parentId + AGE;
+ String tfEmailId = parentId + EMAIL;
+
+ String tfNameErrMsg = tfNameId + ERR_MSG_POSTFIX;
+ String tfAgeErrMsg = tfAgeId + ERR_MSG_POSTFIX;
+ String tfEmailErrMsg = tfEmailId + ERR_MSG_POSTFIX;
+
+ assertNotPresent(tfNameErrMsg);
+ assertNotPresent(tfAgeErrMsg);
+ assertNotPresent(tfEmailErrMsg);
+
+ writeStatus("Name must be between 3 and 12 at length. Type shorter
one");
+ type(tfNameId, "Mi");
+ selenium.fireEvent(tfNameId, "blur");
+ waitForAjaxCompletion();
+ assertPresent(tfNameErrMsg);
+
+ writeStatus("Age must be between 18 and 100. Type less than that");
+ type(tfAgeId, "3");
+ selenium.fireEvent(tfAgeId, "blur");
+ waitForAjaxCompletion();
+ assertPresent(tfAgeErrMsg);
+
+ writeStatus("Email must be an email. Type not a well-formed email");
+ type(tfEmailId, "notemail");
+ selenium.fireEvent(tfEmailId, "blur");
+ waitForAjaxCompletion();
+ assertPresent(tfEmailErrMsg);
+
+ writeStatus("Correct the inputs and leave. Error messages have to
disappear");
+
+ type(tfNameId, "Mick");
+ selenium.fireEvent(tfNameId, "blur");
+ waitForAjaxCompletion();
+ assertNotPresent(tfNameErrMsg);
+
+ type(tfAgeId, "33");
+ selenium.fireEvent(tfAgeId, "blur");
+ waitForAjaxCompletion();
+ assertNotPresent(tfAgeErrMsg);
+
+ type(tfEmailId, "email(a)ya.com");
+ selenium.fireEvent(tfEmailId, "blur");
+ waitForAjaxCompletion();
+ assertNotPresent(tfEmailErrMsg);
+
+ }
+
+ private void assertPresent(String id) {
+ AssertTextNotEquals(id, "", "Message [" + id + "] must
not be empty on the page");
+ }
+
+ private void assertNotPresent(String id) {
+ AssertTextEquals(id, "", "Message [" + id + "] must be
empty on the page");
+ }
+
@Override
public String getTestUrl() {
return "pages/ajaxValidator/ajaxValidatorTest.xhtml";