提交 51927783 编写于 作者: D Daniel Beck 提交者: Oliver Gondža

[JENKINS-43228] Add test

(cherry picked from commit a34479c4)
上级 e7d5b4b2
......@@ -24,9 +24,14 @@
package hudson.triggers;
import antlr.ANTLRException;
import hudson.scheduler.CronTabList;
import hudson.scheduler.Hash;
import org.junit.Assert;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import java.util.TimeZone;
/**
* @author Kanstantsin Shautsou
*/
......@@ -36,4 +41,22 @@ public class TimerTriggerTest {
public void testNoNPE() throws ANTLRException {
new TimerTrigger("").run();
}
@Issue("JENKINS-43328")
@Test
public void testTimeZoneOffset() throws Exception {
TimeZone defaultTz = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
try {
String cron = "TZ=GMT\nH 0 * * *";
CronTabList ctl = CronTabList.create(cron, Hash.from("whatever"));
Assert.assertEquals("previous occurrence is in GMT", "GMT", ctl.previous().getTimeZone().getID());
cron = "TZ=America/Denver\nH 0 * * *";
ctl = CronTabList.create(cron, Hash.from("whatever"));
Assert.assertEquals("next occurrence is in America/Denver", "America/Denver", ctl.next().getTimeZone().getID());
} finally {
TimeZone.setDefault(defaultTz);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册