mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 12:32:15 +00:00
Do not depend on english locale for tests (#7334)
This commit is contained in:
1 parent
621c7a26e9
commit
36aa4cbbb7
1 file changed
+35
-10
@@ -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<Integer> 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")
|
||||
|
||||
Reference in new issue
Block a user