1
2
3
4
5
6
7
8
9
10
11
12
13 package org.kuali.rice.ksb.quartz;
14
15 import java.util.Date;
16
17 import org.junit.Test;
18 import org.kuali.rice.ksb.service.KSBServiceLocator;
19 import org.kuali.rice.ksb.test.KSBTestCase;
20 import org.quartz.JobDataMap;
21 import org.quartz.JobDetail;
22 import org.quartz.Scheduler;
23 import org.quartz.Trigger;
24 import org.quartz.TriggerUtils;
25
26
27
28
29
30
31
32 public class QuartzTest extends KSBTestCase {
33
34 @Test
35 public void testSchedulingJob() throws Exception {
36 Scheduler scheduler = KSBServiceLocator.getScheduler();
37 JobDataMap datMap = new JobDataMap();
38 datMap.put("yo", "yo");
39 JobDetail jobDetail = new JobDetail("myJob", null, TestJob.class);
40 jobDetail.setJobDataMap(datMap);
41
42 Trigger trigger = TriggerUtils.makeImmediateTrigger(1, 1);
43 trigger.setStartTime(new Date());
44 trigger.setName("i'm a trigger puller");
45 trigger.setJobDataMap(datMap);
46
47 scheduler.scheduleJob(jobDetail, trigger);
48
49
50 synchronized (TestJob.LOCK) {
51 TestJob.LOCK.wait(30 * 1000);
52 }
53
54 assertTrue("job never fired", TestJob.EXECUTED);
55 }
56
57 }