001 /** 002 * Copyright 2005-2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.ksb.quartz; 017 018 import org.junit.Test; 019 import org.kuali.rice.ksb.service.KSBServiceLocator; 020 import org.kuali.rice.ksb.test.KSBTestCase; 021 import org.quartz.*; 022 023 import java.util.Date; 024 025 import static org.junit.Assert.assertTrue; 026 027 /** 028 * Test basic sanity check of quartz implementation 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 * 032 */ 033 public class QuartzTest extends KSBTestCase { 034 035 @Test 036 public void testSchedulingJob() throws Exception { 037 Scheduler scheduler = KSBServiceLocator.getScheduler(); 038 JobDataMap datMap = new JobDataMap(); 039 datMap.put("yo", "yo"); 040 JobDetail jobDetail = new JobDetail("myJob", null, TestJob.class); 041 jobDetail.setJobDataMap(datMap); 042 043 Trigger trigger = TriggerUtils.makeImmediateTrigger(1, 1); 044 trigger.setStartTime(new Date()); 045 trigger.setName("i'm a trigger puller"); 046 trigger.setJobDataMap(datMap); 047 048 scheduler.scheduleJob(jobDetail, trigger); 049 050 051 synchronized (TestJob.LOCK) { 052 TestJob.LOCK.wait(30 * 1000); 053 } 054 055 assertTrue("job never fired", TestJob.EXECUTED); 056 } 057 058 }