View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Test basic sanity check of quartz implementation
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
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  }