mirror of
https://github.com/frode-carlsen/cron.git
synced 2025-12-07 06:20:53 +03:00
Merge pull request #2 from alf/make-tests-deterministic
Specify the timezone for the tests
This commit is contained in:
@@ -21,18 +21,32 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import fc.cron.CronExpression;
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.DateTimeZone;
|
||||||
|
import org.joda.time.Hours;
|
||||||
|
import org.joda.time.LocalDate;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import fc.cron.CronExpression.CronFieldType;
|
import fc.cron.CronExpression.CronFieldType;
|
||||||
import fc.cron.CronExpression.DayOfMonthField;
|
import fc.cron.CronExpression.DayOfMonthField;
|
||||||
import fc.cron.CronExpression.DayOfWeekField;
|
import fc.cron.CronExpression.DayOfWeekField;
|
||||||
import fc.cron.CronExpression.SimpleField;
|
import fc.cron.CronExpression.SimpleField;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.Hours;
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class CronExpressionTest {
|
public class CronExpressionTest {
|
||||||
|
DateTimeZone original;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
original = DateTimeZone.getDefault();
|
||||||
|
DateTimeZone.setDefault(DateTimeZone.forID("Europe/Oslo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
DateTimeZone.setDefault(original);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shall_parse_number() throws Exception {
|
public void shall_parse_number() throws Exception {
|
||||||
@@ -233,7 +247,7 @@ public class CronExpressionTest {
|
|||||||
assertThat(new CronExpression("0 * 7,19 * * *").nextTimeAfter(new DateTime(2012, 4, 10, 19, 00))).isEqualTo(new DateTime(2012, 4, 10, 19, 01));
|
assertThat(new CronExpression("0 * 7,19 * * *").nextTimeAfter(new DateTime(2012, 4, 10, 19, 00))).isEqualTo(new DateTime(2012, 4, 10, 19, 01));
|
||||||
assertThat(new CronExpression("0 * 7,19 * * *").nextTimeAfter(new DateTime(2012, 4, 10, 19, 59))).isEqualTo(new DateTime(2012, 4, 11, 07, 00));
|
assertThat(new CronExpression("0 * 7,19 * * *").nextTimeAfter(new DateTime(2012, 4, 10, 19, 59))).isEqualTo(new DateTime(2012, 4, 11, 07, 00));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void check_hour_shall_run_25_times_in_DST_change_to_wintertime() throws Exception {
|
public void check_hour_shall_run_25_times_in_DST_change_to_wintertime() throws Exception {
|
||||||
CronExpression cron = new CronExpression("0 1 * * * *");
|
CronExpression cron = new CronExpression("0 1 * * * *");
|
||||||
@@ -252,7 +266,7 @@ public class CronExpressionTest {
|
|||||||
}
|
}
|
||||||
assertThat(count).isEqualTo(25);
|
assertThat(count).isEqualTo(25);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void check_hour_shall_run_23_times_in_DST_change_to_summertime() throws Exception {
|
public void check_hour_shall_run_23_times_in_DST_change_to_summertime() throws Exception {
|
||||||
CronExpression cron = new CronExpression("0 0 * * * *");
|
CronExpression cron = new CronExpression("0 0 * * * *");
|
||||||
|
|||||||
Reference in New Issue
Block a user