Do not depend on english locale for tests
@@ -268,11 +268,20 @@ public class CronTabTest {
compare(new GregorianCalendar(2013, Calendar.MARCH, 21, 0, 2), new CronTab("H(0-3)/4 * * * *", Hash.from("junk")).ceil(new GregorianCalendar(2013, Calendar.MARCH, 21, 0, 0)));
compare(new GregorianCalendar(2013, Calendar.MARCH, 21, 1, 2), new CronTab("H(0-3)/4 * * * *", Hash.from("junk")).ceil(new GregorianCalendar(2013, Calendar.MARCH, 21, 0, 5)));
+ Locale saveLocale = Locale.getDefault();
+ Locale.setDefault(Locale.ENGLISH);
+
+ try {
ANTLRException e = assertThrows(ANTLRException.class, () ->
compare(new GregorianCalendar(2013, Calendar.MARCH, 21, 0, 0), new CronTab("H(0-3)/15 * * * *", Hash.from("junk")).ceil(new GregorianCalendar(2013, Calendar.MARCH, 21, 0, 0))));
assertThat(e, instanceOf(IllegalArgumentException.class));
assertEquals("line 1:9: 15 is an invalid value. Must be within 1 and 4", e.getMessage());
}
+ finally {
+ Locale.setDefault(saveLocale);
+ }
+ }
+
@Test public void repeatedHash() throws Exception {
CronTabList tabs = CronTabList.create("H * * * *\nH * * * *", Hash.from("seed"));
@@ -290,16 +299,32 @@ public class CronTabTest {
}
@Test public void rangeBoundsCheckFailHour() {
+ Locale saveLocale = Locale.getDefault();
+ Locale.setDefault(Locale.ENGLISH);
+
+ try {
ANTLRException e = assertThrows(ANTLRException.class, () -> new CronTab("H H(12-24) * * *"));
assertThat(e, instanceOf(IllegalArgumentException.class));
assertEquals("line 1:10: 24 is an invalid value. Must be within 0 and 23", e.getMessage());
}
+ finally {
+ Locale.setDefault(saveLocale);
+ }
+ }
@Test public void rangeBoundsCheckFailMinute() {
+ Locale saveLocale = Locale.getDefault();
+ Locale.setDefault(Locale.ENGLISH);
+
+ try {
ANTLRException e = assertThrows(ANTLRException.class, () -> new CronTab("H(33-66) * * * *"));
assertThat(e, instanceOf(IllegalArgumentException.class));
assertEquals("line 1:8: 66 is an invalid value. Must be within 0 and 59", e.getMessage());
}
+ finally {
+ Locale.setDefault(saveLocale);
+ }
+ }
@Issue("JENKINS-9283")
@Test public void testTimezone() throws Exception {
