提交 f6a2f64b 编写于 作者: J Jesse Glick

Test & I18N for checkSanity.

上级 d8b29df3
......@@ -420,8 +420,7 @@ public final class CronTab {
// this rank has a sparse entry.
// if we have a sparse rank, one of them better be the left-most.
if(i>0)
return "Do you really mean \"every minute\" when you say \""+spec+"\"? "+
"Perhaps you meant \"0 "+spec.substring(spec.indexOf(' ')+1)+"\"";
return Messages.CronTab_do_you_really_mean_every_minute_when_you(spec, "0 " + spec.substring(spec.indexOf(' ')+1));
// once we find a sparse rank, upper ranks don't matter
return null;
}
......
......@@ -23,4 +23,5 @@
BaseParser.StartEndReversed=You mean {0}-{1}?
BaseParser.MustBePositive=step must be positive, but found {0}
BaseParser.OutOfRange={0} is an invalid value. Must be within {1} and {2}
CronTabList.InvalidInput=Invalid input: "{0}": {1}
\ No newline at end of file
CronTab.do_you_really_mean_every_minute_when_you=Do you really mean "every minute" when you say "{0}"? Perhaps you meant "{1}"
CronTabList.InvalidInput=Invalid input: "{0}": {1}
......@@ -178,6 +178,17 @@ public class CronTabTest {
compare(answer,x.floor(c));
}
@Test public void checkSanity() throws Exception {
assertEquals(Messages.CronTab_do_you_really_mean_every_minute_when_you("* * * * *", "0 * * * *"), new CronTab("* * * * *").checkSanity());
assertEquals(null, new CronTab("0 * * * *").checkSanity());
assertEquals(null, new CronTab("0 3 * * *").checkSanity());
assertEquals(null, new CronTab("H H(0-2) * * *", Hash.from("stuff")).checkSanity());
assertEquals(Messages.CronTab_do_you_really_mean_every_minute_when_you("* 0 * * *", "0 0 * * *"), new CronTab("* 0 * * *").checkSanity());
assertEquals(Messages.CronTab_do_you_really_mean_every_minute_when_you("* 6,18 * * *", "0 6,18 * * *"), new CronTab("* 6,18 * * *").checkSanity());
// dubious; could be improved:
assertEquals(Messages.CronTab_do_you_really_mean_every_minute_when_you("* * 3 * *", "0 * 3 * *"), new CronTab("* * 3 * *").checkSanity());
}
/**
* Humans can't easily see difference in two {@link Calendar}s, do help the diagnosis by using {@link DateFormat}.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册