Author: andrei_exadel
Date: 2008-12-10 11:02:56 -0500 (Wed, 10 Dec 2008)
New Revision: 11701
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
RF-5231
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2008-12-10
16:02:56 UTC (rev 11701)
@@ -48,6 +48,8 @@
public static final String VALIDATOR_DEFAULT_ID =
"autoTestDefaultValidator";
public static final String ONCOMPLETE = "window._ajaxOncomplete = true;";
+
+ public static final String VALIDATOR_MESSAGE = "Validator message";
// private String input = INPUT_TEXT;
@@ -68,7 +70,7 @@
private String oncomplete = ONCOMPLETE;
private String validatorId = VALIDATOR_DEFAULT_ID;
-
+
public void actionListener(ActionEvent event) {
setStatus(getStatus() + ACTION_LISTENER_STATUS);
}
@@ -331,4 +333,12 @@
this.validatorId = validatorId;
}
+ /**
+ * @return the validatorMessage
+ */
+ public String getValidatorMessage() {
+ return VALIDATOR_MESSAGE;
+ }
+
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml 2008-12-10
16:02:56 UTC (rev 11701)
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <rich:calendar id="componentId"
+ immediate="#{autoTestBean.immediate}"
+ ajaxSingle="#{autoTestBean.ajaxSingle}"
+ reRender="#{autoTestBean.reRender}"
+ limitToList="#{autoTestBean.limitToList}"
+ bypassUpdates="#{autoTestBean.bypassUpdate}"
+ rendered="#{autoTestBean.rendered}"
+ oncomplete="#{autoTestBean.oncomplete}"
+ validatorMessage="#{autoTestBean.validatorMessage}"
+ mode="ajax"
+ popup="false"
+ >
+ <f:validator validatorId="#{autoTestBean.validatorId}" />
+ <f:param name="parameter1" value="value1" />
+ </rich:calendar>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml 2008-12-10
16:02:56 UTC (rev 11701)
@@ -17,6 +17,8 @@
<h:form id="autoTestForm">
<ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
<ui:insert name="component" />
+ <br/>
+ <h:message id="_auto_messageId"
for="componentId"></h:message>
</h:form>
</h:panelGroup>
<h:outputText value="#{row}"
rendered="#{templateBean.dataTableRowIndex != row}" />
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml 2008-12-10
16:02:56 UTC (rev 11701)
@@ -19,6 +19,8 @@
<h:form id="autoTestForm">
<ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
<ui:insert name="component" />
+ <br/>
+ <h:message id="_auto_messageId"
for="componentId"></h:message>
</h:form>
<ui:include src="../../layout/controlLayout.xhtml" />
</rich:modalPanel>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml 2008-12-10
16:02:56 UTC (rev 11701)
@@ -11,6 +11,8 @@
<h:form id="autoTestForm">
<ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
<ui:insert name="component" />
+ <br/>
+ <h:message id="_auto_messageId"
for="componentId"></h:message>
</h:form>
</ui:define>
</ui:composition>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2008-12-10
16:02:56 UTC (rev 11701)
@@ -31,6 +31,8 @@
public static final String STATUS_ID = "_auto_status";
private static final String TIME_ID = "_auto_time";
+
+ private static final String MESSAGE_FOR_ID = "_auto_messageId";
public static final String COMPONENT_ID = "componentId";
@@ -41,6 +43,8 @@
private static final String AJAX_SUBMIT = "_auto_ajax_submit";
private static final String AJAX_RESET = "_auto_ajax_reset";
+
+ private
// /private String componentName;
@@ -377,6 +381,18 @@
private void changeValue() {
base.changeValue();
}
+
+ private void setInternalValidation(boolean passed) {
+ setupControl(TestSetupEntry.validatorId, (passed) ?
AutoTestBean.VALIDATOR_DEFAULT_ID : AutoTestBean.VALIDATOR_ID);
+ }
+
+ private String getValidatorMessage() {
+ String id = base.getParentId() + AUTOTEST_FORM_ID + MESSAGE_FOR_ID;
+ if (base.isPresent(id)) {
+ return base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + MESSAGE_FOR_ID);
+ }
+ return "";
+ }
public void setupControl(TestSetupEntry attr, Object o) {
final String idPrefix = "_auto_";
@@ -387,6 +403,35 @@
base.runScript("document.getElementById('" + controlId +
"').checked = " + o.toString());
}
}
+
+ public void testValidatorAndValidatorMessageAttributes() {
+ setInternalValidation(true);
+ clickLoad();
+ renderPage(base.getTemplate(), null);
+
+ changeValue();
+ clickSubmit();
+
+ String validatorMessage = getValidatorMessage();
+ if (!"".equals(validatorMessage)) {
+ Assert.fail("Validator attribute does not work. Validation failed, but should
not.");
+ }
+
+ setInternalValidation(false);
+ clickLoad();
+ renderPage(base.getTemplate(), null);
+
+ changeValue();
+ clickSubmit();
+
+ validatorMessage = getValidatorMessage();
+ if ("".equals(validatorMessage)) {
+ Assert.fail("Validator attribute does not work. Validation passed, should be
failed.");
+ }else if (!AutoTestBean.VALIDATOR_MESSAGE.equals(validatorMessage)) {
+ Assert.fail("ValidatorMessage attribute does not work. ValidationMessage
expected: [" + AutoTestBean.VALIDATOR_MESSAGE+"].But was [" +
validatorMessage + "]");
+ }
+
+ }
public void checkActionListener(boolean passed) {
String status = getStatus();
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-10
16:00:00 UTC (rev 11700)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-10
16:02:56 UTC (rev 11701)
@@ -30,6 +30,7 @@
import org.ajax4jsf.bean.CalendarTestBean;
import org.ajax4jsf.template.Template;
import org.ajax4jsf.util.DateUtils;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -265,7 +266,16 @@
}
}
+
@Test
+ public void testValidatorAndValidatorMessageAttributes(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ calendarId = tester.getClientId(AutoTester.COMPONENT_ID, template);
+ tester.testValidatorAndValidatorMessageAttributes();
+ }
+
+ @Test
public void testClientMode(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -406,7 +416,7 @@
}
- //@Test
+ @Test
public void testCalendarComponent(Template template) {
renderPage(template);
@@ -435,7 +445,7 @@
Assert.assertTrue(isVisibleById(calendarOpenedId), "Calendar window should
be visible on the component!");
}
- // @Test
+ @Test
public void testSelectDateComponent(Template template) {
renderPage(template);
@@ -527,7 +537,7 @@
Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current
date");
}
- @Test
+ @Test
public void testValueAndCurrentDateOfCalendarWithPopupFalse(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -890,4 +900,14 @@
public String getTestUrl() {
return "pages/calendar/calendarTest.xhtml";
}
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/calendar/calendarAutoTest.xhtml";
+ }
+
+ @Override
+ public void changeValue() {
+ changeDate();
+ }
}