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