diff --git a/core/src/test/java/hudson/scheduler/CronTabTest.java b/core/src/test/java/hudson/scheduler/CronTabTest.java index 813ae6c375..b8301dd7a0 100644 --- a/core/src/test/java/hudson/scheduler/CronTabTest.java +++ b/core/src/test/java/hudson/scheduler/CronTabTest.java @@ -268,12 +268,21 @@ 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))); - 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()); + 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")); List times = new ArrayList<>(); @@ -290,15 +299,31 @@ public class CronTabTest { } @Test public void rangeBoundsCheckFailHour() { - 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()); + 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() { - 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()); + 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")