diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java index 95b4aecdb3..1592fb6c38 100644 --- a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java @@ -216,6 +216,60 @@ public class CalendarBasicsTest { calendar.isClientChangeAllowed()); } + // regression test to ensure old functionality is not broken + @Test + public void defaultFirstDayOfWeek() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.MONDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeek() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.SUNDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeekCanSetEvenBeforeLocale() { + Calendar calendar = new Calendar(); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + + calendar.setLocale(Locale.GERMAN); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.SUNDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeekSetNullRestoresDefault() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + calendar.setFirstDayOfWeek(null); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.MONDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test(expected = IllegalArgumentException.class) + public void customFirstDayOfWeekValidation() { + Calendar calendar = new Calendar(); + int someWrongDayOfWeek = 10; + calendar.setFirstDayOfWeek(someWrongDayOfWeek); + } + private static class TestCalendar extends Calendar { TestCalendar(boolean connectorEnabled) { isConnectorEnabled = connectorEnabled; |