[richfaces-svn-commits] JBoss Rich Faces SVN: r11511 - 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
Wed Dec 3 07:49:45 EST 2008


Author: dsvyatobatsko
Date: 2008-12-03 07:49:44 -0500 (Wed, 03 Dec 2008)
New Revision: 11511

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-5153 started

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-03 12:42:14 UTC (rev 11510)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java	2008-12-03 12:49:44 UTC (rev 11511)
@@ -35,11 +35,11 @@
 import org.richfaces.event.CurrentDateChangeEvent;
 
 public class CalendarTestBean {
-	
-	public static final String valueChangeListener = "valueChangeListener";
-	
-	public static final String currentDateChangeListener = "currentDateChangeListener";
 
+    public static final String valueChangeListener = "valueChangeListener";
+
+    public static final String currentDateChangeListener = "currentDateChangeListener";
+
     public static final String DATE_PATTERN = "MM/dd/yyyy HH:mm";
 
     public static final Locale LOCALE = new Locale("US");
@@ -52,35 +52,35 @@
 
     public static DateFormat DATE_FORMAT;
 
-    // constructor for static fields 
+    // constructor for static fields
     static {
-	setupDefaultConverter();
-	setupDefaultDate();
+        setupDefaultConverter();
+        setupDefaultDate();
     }
-    
-    private String datePattern ;
-    
+
+    private String datePattern;
+
     private Locale locale;
-    
+
     private TimeZone timeZone;
-    
+
     private Date selectedDate;
-    
+
     private String selectedDateString;
-    
+
     private CalendarDataModel model;
-    
-    private String mode = UICalendar.AJAX_MODE; 
-    
+
+    private String mode = UICalendar.AJAX_MODE;
+
     private String status;
-    
+
     public CalendarTestBean() {
-	selectedDate = DEFAULT_DATE;
-	resetSelectedDateString();
-	
-	datePattern = DATE_PATTERN;
-	locale = LOCALE;
-	timeZone = TIME_ZONE;
+        selectedDate = DEFAULT_DATE;
+        resetSelectedDateString();
+
+        datePattern = DATE_PATTERN;
+        locale = LOCALE;
+        timeZone = TIME_ZONE;
     }
 
     public Date getSelectedDate() {
@@ -91,11 +91,11 @@
         this.selectedDate = selectedDate;
         resetSelectedDateString();
     }
-    
+
     public void resetSelectedDateString() {
-	setSelectedDateString(DATE_FORMAT.format(getSelectedDate()));
+        setSelectedDateString(DATE_FORMAT.format(getSelectedDate()));
     }
-    
+
     public String getSelectedDateString() {
         return selectedDateString;
     }
@@ -121,112 +121,134 @@
     }
 
     public void setLocale(Locale locale) {
-	this.locale = locale;
+        this.locale = locale;
     }
 
     public void setTimeZone(TimeZone timeZone) {
-	this.timeZone = timeZone;
+        this.timeZone = timeZone;
     }
-    
+
     public static Calendar getCalendar() {
-	return Calendar.getInstance(CalendarTestBean.TIME_ZONE, CalendarTestBean.LOCALE);
+        return Calendar.getInstance(CalendarTestBean.TIME_ZONE, CalendarTestBean.LOCALE);
     }
-    
+
     /**
      * Setup the default date
      */
     private static void setupDefaultDate() {
-	DEFAULT_DATE = getDayInMay(10);
+        DEFAULT_DATE = getDayInMay(10);
     }
-    
+
     public static Date getDayInMay(int dayOfMonth) {
-	Calendar calendar = getCalendar();
-	calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
-	calendar.set(Calendar.MONTH, Calendar.MAY);
-	calendar.set(Calendar.YEAR, 2008);
-	calendar.set(Calendar.HOUR_OF_DAY, 18);
-	calendar.set(Calendar.MINUTE, 25);
-	calendar.set(Calendar.SECOND, 0);
-	calendar.set(Calendar.MILLISECOND, 0);
-	
-	return calendar.getTime();
+        Calendar calendar = getCalendar();
+        calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+        calendar.set(Calendar.MONTH, Calendar.MAY);
+        calendar.set(Calendar.YEAR, 2008);
+        calendar.set(Calendar.HOUR_OF_DAY, 18);
+        calendar.set(Calendar.MINUTE, 25);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+
+        return calendar.getTime();
     }
-    
+
     /**
      * Setup the default converter
      */
-    private static void setupDefaultConverter() {	
-	DEFAULT_CONVERTER = new DateTimeConverter();
+    private static void setupDefaultConverter() {
+        DEFAULT_CONVERTER = new DateTimeConverter();
 
-	DEFAULT_CONVERTER.setPattern(DATE_PATTERN);
-	DEFAULT_CONVERTER.setLocale(LOCALE);
-	DEFAULT_CONVERTER.setTimeZone(TIME_ZONE);
-	
-	try {
-	    Method method = null;
-	    Method[] declaredMethods = DateTimeConverter.class.getDeclaredMethods();
-	    for (int i = 0; i < declaredMethods.length; i++) {
-		if (declaredMethods[i].getName().equals("getDateFormat")) {
-		    method = declaredMethods[i];
-		    break;
-		}
-	    }
-	    if (method != null) {
+        DEFAULT_CONVERTER.setPattern(DATE_PATTERN);
+        DEFAULT_CONVERTER.setLocale(LOCALE);
+        DEFAULT_CONVERTER.setTimeZone(TIME_ZONE);
 
-		method.setAccessible(true);
-		DATE_FORMAT = (DateFormat) method.invoke(DEFAULT_CONVERTER, DEFAULT_CONVERTER.getLocale());
-		DATE_FORMAT.setTimeZone(DEFAULT_CONVERTER.getTimeZone());
-	    }
-	} catch (Exception e) {
-	    // skip exception
-	}
+        try {
+            Method method = null;
+            Method[] declaredMethods = DateTimeConverter.class.getDeclaredMethods();
+            for (int i = 0; i < declaredMethods.length; i++) {
+                if (declaredMethods[i].getName().equals("getDateFormat")) {
+                    method = declaredMethods[i];
+                    break;
+                }
+            }
+            if (method != null) {
+
+                method.setAccessible(true);
+                DATE_FORMAT = (DateFormat) method.invoke(DEFAULT_CONVERTER, DEFAULT_CONVERTER.getLocale());
+                DATE_FORMAT.setTimeZone(DEFAULT_CONVERTER.getTimeZone());
+            }
+        } catch (Exception e) {
+            // skip exception
+        }
     }
-    
+
     public void valueChangeListener(ValueChangeEvent event) {
-    	status = getStatus() + valueChangeListener;
+        status = getStatus() + valueChangeListener;
     }
-    
+
     public void currectDateChangeListener(CurrentDateChangeEvent event) {
-    	status = getStatus() + currentDateChangeListener;
+        status = getStatus() + currentDateChangeListener;
     }
-    
+
     public String testClientMode() {
-    	mode = UICalendar.CLIENT_MODE;
-    	return null;
+        mode = UICalendar.CLIENT_MODE;
+        return null;
     }
-    
+
     public void reset() {
-    	mode = UICalendar.AJAX_MODE;
-    	status = "";    	
-    	selectedDate = new Date();
+        mode = UICalendar.AJAX_MODE;
+        status = "";
+        selectedDate = new Date();
     }
-    
+
     public String resetAction() {
-    	reset();
-    	return null;
+        reset();
+        return null;
     }
 
-	public String getStatus() {
-		return status;
-	}
+    public String getStatus() {
+        return status;
+    }
 
-	public void setStatus(String status) {
-		this.status = status;
-	}
+    public void setStatus(String status) {
+        this.status = status;
+    }
 
-	public String getMode() {
-		return mode;
-	}
+    public String getMode() {
+        return mode;
+    }
 
-	public void setMode(String mode) {
-		this.mode = mode;
-	}
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
 
-	public CalendarDataModel getModel() {
-		return model;
-	}
+    public CalendarDataModel getModel() {
+        return model;
+    }
 
-	public void setModel(CalendarDataModel model) {
-		this.model = model;
-	}
+    public void setModel(CalendarDataModel model) {
+        this.model = model;
+    }
+
+    private Date currentDate = null;
+
+    /**
+     * Gets value of currentDate field.
+     * 
+     * @return value of currentDate field
+     */
+    public Date getCurrentDate() {
+        return currentDate;
+    }
+
+    /**
+     * Set a new value for currentDate field.
+     * 
+     * @param currentDate
+     *                a new value for currentDate field
+     */
+    public void setCurrentDate(Date currentDate) {
+        this.currentDate = currentDate;
+    }
+
 }

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-03 12:42:14 UTC (rev 11510)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java	2008-12-03 12:49:44 UTC (rev 11511)
@@ -32,203 +32,197 @@
 
 public class CalendarTest extends SeleniumTestBase {
 
-	static final String RESET_METHOD = "#{calendarBean.reset}";
+    static final String RESET_METHOD = "#{calendarBean.reset}";
 
-	static final String FORM_ID = "_form:";
-	static final String CONTROLS_FORM_ID = "_controls:";
-	
-	static final String availableDayCellClass = "rich-calendar-cell-size rich-calendar-cell rich-calendar-btn"; 
-	
-	String calendarId;
-	String calendarHeaderId;
-	String ajaxSubmitId;
-	String serverSubmitId;
-	String statusId;
-	String resetActionId;
-	String testClientModeId;
+    static final String FORM_ID = "_form:";
 
-	void initIds(String parentId) {
-		calendarId = parentId + FORM_ID + "calendar";
-		calendarHeaderId = calendarId + "Header";
-		ajaxSubmitId = parentId + FORM_ID + "ajaxSubmit";
-		serverSubmitId = parentId + FORM_ID + "serverSubmit";
-		statusId = parentId + FORM_ID + "status";
-		resetActionId = parentId + CONTROLS_FORM_ID + "resetAction";
-		testClientModeId = parentId + CONTROLS_FORM_ID + "testClientMode";
-	}
+    static final String CONTROLS_FORM_ID = "_controls:";
 
-	String getStatus() {
-		return getTextById(statusId);
-	}
+    static final String availableDayCellClass = "rich-calendar-cell-size rich-calendar-cell rich-calendar-btn";
 
-	void assertListeners(String... listener) {
-		String status = getStatus();
-		String s = status;
-		String sum = "";
-		for (String l : listener) {
-			if (status.indexOf(l) == -1) {
-				Assert.fail(l + " has been skipped");
-			} else {
-				s = s.replace(l, "");
-			}
-			sum += l;
-		}
-		if (s.length() > 0) {
-			Assert.fail("The following listener were called but shouldn't: "
-					+ s);
-		}
-		if (!status.equals(sum)) {
-			Assert.fail("Order of listeners call is incorrect. Should be: "
-					+ sum + ". But was : " + status);
-		}
-	}
-	
-	void changeDate() {
-		String weekNumId = calendarId + "WeekNum2";
-		selenium.click("//tr[@id='"+weekNumId+"']/td[@class='"+availableDayCellClass+"']");
-	}
-	
-	void changeCurrentDate(boolean wait4ajax) {
-		selenium.click("//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td/div");
-		if (wait4ajax) {
-			waitForAjaxCompletion();
-		}
-	}
-	
-	void reset() {
-		clickCommandAndWait(resetActionId);
-	}
-	
-	void switchToClientMode() {
-		clickCommandAndWait(testClientModeId);
-	}
-	
-	@Test
-	public void testListenersInAjaxMode(Template template) {
-		renderPage(template, RESET_METHOD);
-		initIds(getParentId());
+    String calendarId;
 
-		changeDate();
-		
-		clickAjaxCommandAndWait(ajaxSubmitId);
-		assertListeners(CalendarTestBean.valueChangeListener);
-		
-		reset();
-		
-		changeCurrentDate(true);
-		changeDate();
-		clickAjaxCommandAndWait(ajaxSubmitId);
-		assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
-		
-	}
-	
-	
-	@Test
-	public void testListenersInClientMode(Template template) {
-		renderPage(template, RESET_METHOD);
-		initIds(getParentId());
-		switchToClientMode();
-		
-		changeDate();
-		
-		clickCommandAndWait(serverSubmitId);
-		assertListeners(CalendarTestBean.valueChangeListener);
-		
-		reset();
-		switchToClientMode();
-		
-		changeCurrentDate(false);
-		changeDate();
-		clickCommandAndWait(serverSubmitId);
-		assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
-		
-	}
+    String calendarHeaderId;
 
+    String ajaxSubmitId;
 
-	// @Test
-	public void testCalendarComponent(Template template) {
-		renderPage(template);
+    String serverSubmitId;
 
-		String containerId = getParentId() + "_form:";
-		String calendarOpenedId = containerId + "calendar";
-		String calendarCollapsedId = calendarOpenedId + "Popup";
-		String calendarInputDate = calendarOpenedId + "InputDate";
-		String calendarPopupButton = calendarCollapsedId + "Button";
-		String outputPanel = containerId + "outputPanel";
+    String statusId;
 
-		Assert.assertFalse(isVisibleById(calendarOpenedId),
-				"Calendar window should NOT be visible on the component!");
+    String resetActionId;
 
-		writeStatus("Mouse click on calendar InputDate field");
-		clickById(calendarInputDate);
+    String testClientModeId;
 
-		Assert.assertTrue(isVisibleById(calendarOpenedId),
-				"Calendar window should be visible on the component!");
+    void initIds(String parentId) {
+        calendarId = parentId + FORM_ID + "calendar";
+        calendarHeaderId = calendarId + "Header";
+        ajaxSubmitId = parentId + FORM_ID + "ajaxSubmit";
+        serverSubmitId = parentId + FORM_ID + "serverSubmit";
+        statusId = parentId + FORM_ID + "status";
+        resetActionId = parentId + CONTROLS_FORM_ID + "resetAction";
+        testClientModeId = parentId + CONTROLS_FORM_ID + "testClientMode";
+    }
 
-		writeStatus("Mouse click outside calendar");
-		clickById(outputPanel);
+    String getStatus() {
+        return getTextById(statusId);
+    }
 
-		Assert.assertFalse(isVisibleById(calendarOpenedId),
-				"Calendar window should NOT be visible on the component!");
+    void assertListeners(String... listener) {
+        String status = getStatus();
+        String s = status;
+        String sum = "";
+        for (String l : listener) {
+            if (status.indexOf(l) == -1) {
+                Assert.fail(l + " has been skipped");
+            } else {
+                s = s.replace(l, "");
+            }
+            sum += l;
+        }
+        if (s.length() > 0) {
+            Assert.fail("The following listener were called but shouldn't: " + s);
+        }
+        if (!status.equals(sum)) {
+            Assert.fail("Order of listeners call is incorrect. Should be: " + sum + ". But was : " + status);
+        }
+    }
 
-		writeStatus("Mouse click on calendar popup button");
-		clickById(calendarPopupButton);
+    void changeDate() {
+        String weekNumId = calendarId + "WeekNum2";
+        selenium.click("//tr[@id='" + weekNumId + "']/td[@class='" + availableDayCellClass + "']");
+    }
 
-		Assert.assertTrue(isVisibleById(calendarOpenedId),
-				"Calendar window should be visible on the component!");
-	}
+    void changeCurrentDate(boolean wait4ajax) {
+        selenium.click("//td[@id='" + calendarHeaderId + "']/table/tbody/tr/td/div");
+        if (wait4ajax) {
+            waitForAjaxCompletion();
+        }
+    }
 
-	// @Test
-	public void testSelectDateComponent(Template template) {
-		renderPage(template);
+    void reset() {
+        clickCommandAndWait(resetActionId);
+    }
 
-		Date newSelectedDate = CalendarTestBean.getDayInMay(15);
+    void switchToClientMode() {
+        clickCommandAndWait(testClientModeId);
+    }
 
-		String containerId = getParentId() + "_form:";
-		String calendarOpenedId = containerId + "calendar";
-		String calendarCollapsedId = calendarOpenedId + "Popup";
-		String calendarInputDate = calendarOpenedId + "InputDate";
-		String calendarPopupButton = calendarCollapsedId + "Button";
-		String outputPanel = containerId + "outputPanel";
+    @Test
+    public void testListenersInAjaxMode(Template template) {
+        renderPage(template, RESET_METHOD);
+        initIds(getParentId());
 
-		Assert.assertFalse(isVisibleById(calendarOpenedId),
-				"Calendar window should NOT be visible on the component!");
-		writeStatus("Mouse click on calendar popup button");
-		clickById(calendarPopupButton);
-		Assert.assertTrue(isVisibleById(calendarOpenedId),
-				"Calendar window should be visible on the component!");
+        changeDate();
 
-		String inputDateString = getValueById(calendarInputDate);
-		Date readDate = null;
-		try {
-			readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
-		} catch (ParseException parseException) {
-			// skip exception
-		}
-		Assert.assertEquals(readDate, CalendarTestBean.DEFAULT_DATE,
-				"Default date representation is wrong!");
+        clickAjaxCommandAndWait(ajaxSubmitId);
+        assertListeners(CalendarTestBean.valueChangeListener);
 
-		// click on 15th of May
-		String newSelectedDateId = calendarOpenedId + "DayCell18";
-		clickById(newSelectedDateId);
+        reset();
 
-		writeStatus("Mouse click outside calendar");
-		clickById(outputPanel);
+        changeCurrentDate(true);
+        changeDate();
+        clickAjaxCommandAndWait(ajaxSubmitId);
+        assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
 
-		inputDateString = getValueById(calendarInputDate);
-		try {
-			readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
-		} catch (ParseException parseException) {
-			// skip exception
-		}
-		Assert.assertEquals(readDate, newSelectedDate,
-				"Date representation after selecting 15.May.2008 is wrong!");
+    }
 
-		Assert.assertFalse(isVisibleById(calendarOpenedId),
-				"Calendar window should NOT be visible on the component!");
-	}
+    @Test
+    public void testListenersInClientMode(Template template) {
+        renderPage(template, RESET_METHOD);
+        initIds(getParentId());
+        switchToClientMode();
 
-	public String getTestUrl() {
-		return "pages/calendar/calendarTest.xhtml";
-	}
+        changeDate();
+
+        clickCommandAndWait(serverSubmitId);
+        assertListeners(CalendarTestBean.valueChangeListener);
+
+        reset();
+        switchToClientMode();
+
+        changeCurrentDate(false);
+        changeDate();
+        clickCommandAndWait(serverSubmitId);
+        assertListeners(CalendarTestBean.valueChangeListener, CalendarTestBean.currentDateChangeListener);
+
+    }
+
+    // @Test
+    public void testCalendarComponent(Template template) {
+        renderPage(template);
+
+        String containerId = getParentId() + "_form:";
+        String calendarOpenedId = containerId + "calendar";
+        String calendarCollapsedId = calendarOpenedId + "Popup";
+        String calendarInputDate = calendarOpenedId + "InputDate";
+        String calendarPopupButton = calendarCollapsedId + "Button";
+        String outputPanel = containerId + "outputPanel";
+
+        Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should NOT be visible on the component!");
+
+        writeStatus("Mouse click on calendar InputDate field");
+        clickById(calendarInputDate);
+
+        Assert.assertTrue(isVisibleById(calendarOpenedId), "Calendar window should be visible on the component!");
+
+        writeStatus("Mouse click outside calendar");
+        clickById(outputPanel);
+
+        Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should NOT be visible on the component!");
+
+        writeStatus("Mouse click on calendar popup button");
+        clickById(calendarPopupButton);
+
+        Assert.assertTrue(isVisibleById(calendarOpenedId), "Calendar window should be visible on the component!");
+    }
+
+    // @Test
+    public void testSelectDateComponent(Template template) {
+        renderPage(template);
+
+        Date newSelectedDate = CalendarTestBean.getDayInMay(15);
+
+        String containerId = getParentId() + "_form:";
+        String calendarOpenedId = containerId + "calendar";
+        String calendarCollapsedId = calendarOpenedId + "Popup";
+        String calendarInputDate = calendarOpenedId + "InputDate";
+        String calendarPopupButton = calendarCollapsedId + "Button";
+        String outputPanel = containerId + "outputPanel";
+
+        Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should NOT be visible on the component!");
+        writeStatus("Mouse click on calendar popup button");
+        clickById(calendarPopupButton);
+        Assert.assertTrue(isVisibleById(calendarOpenedId), "Calendar window should be visible on the component!");
+
+        String inputDateString = getValueById(calendarInputDate);
+        Date readDate = null;
+        try {
+            readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
+        } catch (ParseException parseException) {
+            // skip exception
+        }
+        Assert.assertEquals(readDate, CalendarTestBean.DEFAULT_DATE, "Default date representation is wrong!");
+
+        // click on 15th of May
+        String newSelectedDateId = calendarOpenedId + "DayCell18";
+        clickById(newSelectedDateId);
+
+        writeStatus("Mouse click outside calendar");
+        clickById(outputPanel);
+
+        inputDateString = getValueById(calendarInputDate);
+        try {
+            readDate = CalendarTestBean.DATE_FORMAT.parse(inputDateString);
+        } catch (ParseException parseException) {
+            // skip exception
+        }
+        Assert.assertEquals(readDate, newSelectedDate, "Date representation after selecting 15.May.2008 is wrong!");
+
+        Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should NOT be visible on the component!");
+    }
+
+    public String getTestUrl() {
+        return "pages/calendar/calendarTest.xhtml";
+    }
 }




More information about the richfaces-svn-commits mailing list