01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in
05: * compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.opensource.org/licenses/ecl1.php
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
10: * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11: * language governing permissions and limitations under the License.
12: */
13: package org.kuali.bus.quartz;
14:
15: import java.util.Date;
16:
17: import org.junit.Test;
18: import org.kuali.bus.services.KSBServiceLocator;
19: import org.kuali.bus.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: * Test basic sanity check of quartz implementation
28: *
29: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
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,
40: 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: synchronized (TestJob.LOCK) {
51: TestJob.LOCK.wait(30 * 1000);
52: }
53:
54: assertTrue("job never fired", TestJob.EXECUTED);
55: }
56:
57: }
|