Author: dsvyatobatsko
Date: 2008-09-23 11:14:30 -0400 (Tue, 23 Sep 2008)
New Revision: 10542
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/beanValidator/beanValidatorTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java
Log:
BeanValidator test completed
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/beanValidator/beanValidatorTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java 2008-09-23
10:44:51 UTC (rev 10541)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java 2008-09-23
15:14:30 UTC (rev 10542)
@@ -6,11 +6,77 @@
public class BeanValidatorTest 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";
+
+ private static final String SUBMIT_BTN = "_submit";
+
@Test
public void testBeanValidatorComponent(Template template) {
renderPage(template);
+
+ writeStatus("Check bean validator component with model-based constraints
defined using hibernate validator.");
+
+ String parentId = getParentId() + "_form:";
+
+ 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");
+
+ writeStatus("Age must be between 18 and 100. Type less than that");
+ type(tfAgeId, "3");
+
+ writeStatus("Email must be an email. Type not a well-formed email");
+ type(tfEmailId, "notemail");
+
+ submit();
+
+ assertPresent(tfNameErrMsg);
+ assertPresent(tfAgeErrMsg);
+ assertPresent(tfEmailErrMsg);
+
+ writeStatus("Correct the inputs and resubmit form. Error messages have to
disappear");
+
+ type(tfNameId, "Mick");
+ type(tfAgeId, "33");
+ type(tfEmailId, "email(a)ya.com");
+
+ submit();
+
+ assertNotPresent(tfNameErrMsg);
+ assertNotPresent(tfAgeErrMsg);
+ assertNotPresent(tfEmailErrMsg);
+
}
+ private void submit() {
+ clickAjaxCommandAndWait(getParentId() + "_form:" + SUBMIT_BTN);
+ }
+
+ 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/beanValidator/beanValidatorTest.xhtml";