[richfaces-svn-commits] JBoss Rich Faces SVN: r11732 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/calendar and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Dec 12 06:32:20 EST 2008
Author: dsvyatobatsko
Date: 2008-12-12 06:32:20 -0500 (Fri, 12 Dec 2008)
New Revision: 11732
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5251
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-12 10:41:53 UTC (rev 11731)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-12 11:32:20 UTC (rev 11732)
@@ -40,6 +40,8 @@
public static final String currentDateChangeListener = "currentDateChangeListener";
+ public static final String REQUIRED_MESSAGE = "Date cannot be empty";
+
public static final String DATE_PATTERN = "MM/dd/yyyy HH:mm";
public static final Locale LOCALE = Locale.US;
@@ -222,6 +224,7 @@
isPopup = false;
currentDate = new Date();
locale = Locale.US;
+ required = false;
}
public String resetAction() {
@@ -457,4 +460,46 @@
this.todayControlMode = todayControlMode;
}
+ private boolean required;
+
+ /**
+ * Gets value of required field.
+ * @return value of required field
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Set a new value for required field.
+ * @param required a new value for required field
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ private String requiredMessage = REQUIRED_MESSAGE;
+
+ /**
+ * Gets value of requiredMessage field.
+ * @return value of requiredMessage field
+ */
+ public String getRequiredMessage() {
+ return requiredMessage;
+ }
+
+ /**
+ * Set a new value for requiredMessage field.
+ * @param requiredMessage a new value for requiredMessage field
+ */
+ public void setRequiredMessage(String requiredMessage) {
+ this.requiredMessage = requiredMessage;
+ }
+
+ public void initRequiredTest() {
+ required = true;
+ selectedDate = null;
+ isPopup = false;
+ }
+
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
===================================================================
(Binary files differ)
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-12 10:41:53 UTC (rev 11731)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-12 11:32:20 UTC (rev 11732)
@@ -21,6 +21,13 @@
package org.richfaces.testng;
+import static org.ajax4jsf.bean.CalendarTestBean.DATE_FORMAT;
+import static org.ajax4jsf.bean.CalendarTestBean.DEFAULT_DATE;
+import static org.ajax4jsf.bean.CalendarTestBean.REQUIRED_MESSAGE;
+import static org.ajax4jsf.bean.CalendarTestBean.currentDateChangeListener;
+import static org.ajax4jsf.bean.CalendarTestBean.getDayInMay;
+import static org.ajax4jsf.bean.CalendarTestBean.valueChangeListener;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -29,10 +36,8 @@
import java.util.List;
import java.util.Locale;
-import org.ajax4jsf.bean.CalendarTestBean;
import org.ajax4jsf.template.Template;
import org.ajax4jsf.util.DateUtils;
-import org.apache.tools.ant.util.StringUtils;
import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
@@ -46,6 +51,8 @@
static final String INIT_SHOW_ATTRIBUTES_TEST = "#{calendarBean.initShowAttributesTest}";
+ static final String INIT_REQUIRED_TEST = "#{calendarBean.initRequiredTest}";
+
static final String FORM_ID = "_form:";
static final String SHOW_ATTRIBURES_TEST_URL = "pages/calendar/showAttributesTest.xhtml";
@@ -68,8 +75,7 @@
WEEK_DAYS_RU.add("×ò");
WEEK_DAYS_RU.add("Ïò");
WEEK_DAYS_RU.add("Ñá");
- WEEK_DAYS_RU.add("Âñ");
-
+ WEEK_DAYS_RU.add("Âñ");
}
String calendarId;
@@ -92,6 +98,8 @@
String setupActionId;
+ String ajaxSetupActionId;
+
String dateSelectionXpath;
String timeSelectionXpath;
@@ -147,9 +155,9 @@
String cleanButtonXPath;
String closeHeaderXpath;
-
-
+ String calendarMessageId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -163,6 +171,7 @@
resetActionId = parentId + CONTROLS_FORM_ID + "resetAction";
testClientModeId = parentId + CONTROLS_FORM_ID + "testClientMode";
setupActionId = parentId + CONTROLS_FORM_ID + "setup";
+ ajaxSetupActionId = parentId + CONTROLS_FORM_ID + "ajaxSetup";
timeHoursSelectionId = calendarId + "TimeHours";
timeMinutesSelectionId = calendarId + "TimeMinutes";
timeSelectionOkButtonId = calendarId + "TimeEditorButtonOk";
@@ -189,6 +198,7 @@
todayControlXpath = "//td[@id='" + calendarFooterId + "']/table/tbody/tr/td[5]";
applyButtonXpath = "//td[@id='" + calendarFooterId + "']/table/tbody/tr/td[6]";
cleanButtonXPath = "//td[@id='"+calendarFooterId+"']/table/tbody/tr/td[2]";
+ calendarMessageId = parentId + FORM_ID + "calendarMsg";
}
String getStatus() {
@@ -513,14 +523,14 @@
changeDate();
clickAjaxCommandAndWait(ajaxSubmitId);
- assertListeners(CalendarTestBean.valueChangeListener);
+ assertListeners(valueChangeListener);
reset();
changeCurrentDate(true);
changeDate();
clickAjaxCommandAndWait(ajaxSubmitId);
- assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
+ assertListeners(valueChangeListener, currentDateChangeListener);
}
@@ -533,7 +543,7 @@
changeDate();
clickCommandAndWait(serverSubmitId);
- assertListeners(CalendarTestBean.valueChangeListener);
+ assertListeners(valueChangeListener);
reset();
switchToClientMode();
@@ -541,7 +551,7 @@
changeCurrentDate(false);
changeDate();
clickCommandAndWait(serverSubmitId);
- assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
+ assertListeners(valueChangeListener, currentDateChangeListener);
}
@@ -578,7 +588,7 @@
public void testSelectDateComponent(Template template) {
renderPage(template);
- Date newSelectedDate = CalendarTestBean.getDayInMay(15);
+ Date newSelectedDate = getDayInMay(15);
String containerId = getParentId() + "_form:";
String calendarOpenedId = containerId + "calendar";
@@ -595,11 +605,11 @@
String inputDateString = getValueById(calendarInputDate);
Date readDate = null;
try {
- readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
+ readDate = DATE_FORMAT.parse(inputDateString);
} catch (ParseException parseException) {
// skip exception
}
- Assert.assertEquals(readDate, CalendarTestBean.DEFAULT_DATE, "Default date representation is wrong!");
+ Assert.assertEquals(readDate, DEFAULT_DATE, "Default date representation is wrong!");
// click on 15th of May
String newSelectedDateId = calendarOpenedId + "DayCell18";
@@ -610,7 +620,7 @@
inputDateString = getValueById(calendarInputDate);
try {
- readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
+ readDate = DATE_FORMAT.parse(inputDateString);
} catch (ParseException parseException) {
// skip exception
}
@@ -666,7 +676,7 @@
Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current date");
}
- @Test
+ @Test
public void testValueAndCurrentDateOfCalendarWithPopupFalse(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -891,7 +901,7 @@
AssertPresent(weeksBarId, "Weeks bar is not present");
}
- @Test
+ @Test
public void testShowInput(Template template) {
renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
initIds(getParentId());
@@ -1005,8 +1015,8 @@
Assert.assertFalse(isVisible(todayControlXpath), "Control 'Today' has to be hidden");
}
- @Test
- public void buttonRelatedAttributesTest(Template template) {
+ @Test
+ public void testButtonRelatedAttributes(Template template) {
renderPage(BUTTON_RELATED_TEST_URL, template, null);
writeStatus("Check button-related attributes");
@@ -1028,6 +1038,50 @@
AssertTextEquals(labeledPopupBtnId, "Button");
}
+ @Test
+ public void testRequiredAndRequiredMessageAttributes(Template template) {
+ renderPage(template, INIT_REQUIRED_TEST);
+ initIds(getParentId());
+
+ String validDate = new SimpleDateFormat(selenium.getValue(datePatternId)).format(new Date());
+
+ writeStatus("Check required & requiredMessage attributes");
+
+ writeStatus("Initially calendar message has to be empty. Check it");
+ AssertTextEquals(calendarMessageId, "", "there is already not empty message here! This is no good!");
+
+ writeStatus("Check the attributes themselves. In any case 'Date cannot be empty' error message has to come up. Track it");
+ writeStatus("Check non-popup mode");
+
+ clickAjaxCommandAndWait(ajaxSubmitId);
+ AssertTextEquals(calendarMessageId, REQUIRED_MESSAGE, "Wrong message is shown up");
+ ajaxSetup();
+ clickCommandAndWait(serverSubmitId);
+ AssertTextEquals(calendarMessageId, REQUIRED_MESSAGE, "Wrong message is shown up");
+
+ writeStatus("Check popup mode");
+ setPopup(true);
+ ajaxSetup();
+
+ clickAjaxCommandAndWait(ajaxSubmitId);
+ AssertTextEquals(calendarMessageId, REQUIRED_MESSAGE, "Wrong message is shown up");
+ ajaxSetup();
+ clickCommandAndWait(serverSubmitId);
+ AssertTextEquals(calendarMessageId, REQUIRED_MESSAGE, "Wrong message is shown up");
+
+ writeStatus("Fix date. Error message has to escape");
+ setValueById(selectedDateId, validDate);
+ ajaxSetup();
+
+ clickAjaxCommandAndWait(ajaxSubmitId);
+ AssertTextEquals(calendarMessageId, "", "Message has to be empty");
+ ajaxSetup();
+
+ clickCommandAndWait(serverSubmitId);
+ AssertTextEquals(calendarMessageId, "", "Message has to be empty");
+ ajaxSetup();
+ }
+
private void setPopup(boolean isPopup) {
runScript("$('" + isPopupId + "').checked=" + isPopup);
}
@@ -1044,6 +1098,10 @@
clickCommandAndWait(setupActionId);
}
+ private void ajaxSetup() {
+ clickAjaxCommandAndWait(ajaxSetupActionId);
+ }
+
private void showPopup() {
writeStatus("Show popup");
clickById(popupButtonId);
@@ -1081,7 +1139,7 @@
public void changeValue() {
changeDate();
}
-
+
@Override
public void sendAjax() {
changeCurrentDate(true);
More information about the richfaces-svn-commits
mailing list