forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-29214 Tests showing failure when time changes.
Some times during the year there is no 01:00:00 time as the clocks are going forward. These tests show the bug happening in the Europe/London timezone in 2015.
- Loading branch information
Showing
3 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
calendar/calendar-util/util/src/test/org/sakaiproject/util/CalendarUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.sakaiproject.util; | ||
|
||
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Locale; | ||
import java.util.TimeZone; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class CalendarUtilTest { | ||
|
||
|
||
@Before | ||
public void setUp() { | ||
// Need this so that developers in locales that don't use AM/PM have passing tests | ||
// If you want to test this setting is working set it to Locale.JAPAN which should | ||
// result in failing tests. | ||
Locale.setDefault(Locale.ENGLISH); | ||
} | ||
|
||
@Test | ||
public void testLocalAMString() { | ||
// This is to test that the schedule tool works through GMT -> BST transitions | ||
DateTimeZone zone = DateTimeZone.forTimeZone(TimeZone.getTimeZone("Europe/London")); | ||
// This a day that the clocks go forward in London | ||
DateTime dateTime = new DateTime(2015, 3, 29, 3,0, zone); | ||
assertEquals("AM", CalendarUtil.getLocalAMString(dateTime)); | ||
} | ||
|
||
@Test | ||
public void testLocalPMString() { | ||
// This is to test that the schedule tool works through GMT -> BST transitions | ||
DateTimeZone zone = DateTimeZone.forTimeZone(TimeZone.getTimeZone("Europe/London")); | ||
// This a day that the clocks go forward in London | ||
DateTime dateTime = new DateTime(2015, 3, 29, 16,0, zone); | ||
assertEquals("PM", CalendarUtil.getLocalPMString(dateTime)); | ||
} | ||
|
||
@Test | ||
public void testLocalPMStringStartOfDay() { | ||
// This is to test that the schedule tool works through GMT -> BST transitions | ||
DateTimeZone zone = DateTimeZone.forTimeZone(TimeZone.getTimeZone("Europe/London")); | ||
// This a day that the clocks go forward in London | ||
DateTime dateTime = new DateTime(2015, 3, 29, 0, 0, zone); | ||
assertEquals("PM", CalendarUtil.getLocalPMString(dateTime)); | ||
} | ||
|
||
|
||
} |