use of org.quartz.spi.TriggerFiredBundle in project head by mifos.
the class BatchJobCatchUpIntegrationTest method testIncompleteTaskDelay.
@Test
public void testIncompleteTaskDelay() throws Exception {
mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/catchUpTask.xml");
Scheduler scheduler = mifosScheduler.getScheduler();
ProductStatus productStatusTask = new ProductStatus();
productStatusTask.setJobExplorer(mifosScheduler.getBatchJobExplorer());
productStatusTask.setJobLauncher(mifosScheduler.getBatchJobLauncher());
productStatusTask.setJobLocator(mifosScheduler.getBatchJobLocator());
productStatusTask.setJobRepository(mifosScheduler.getBatchJobRepository());
String quartzJobName = "ProductStatusJob";
String quartzTriggerName = "ProductStatusTrigger2";
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 10);
Date previousFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 21);
Date quartzFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 22);
Date quartzNextFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 20);
Date quartzPrevFireTime = calendar.getTime();
JobDetail jobDetail = scheduler.getJobDetail(quartzJobName, Scheduler.DEFAULT_GROUP);
jobDetail.setJobDataMap(new JobDataMap());
CronTrigger trigger = new CronTrigger(quartzTriggerName, Scheduler.DEFAULT_GROUP, quartzJobName, Scheduler.DEFAULT_GROUP, "* * * * * ?");
trigger.setJobDataMap(new JobDataMap());
TriggerFiredBundle triggerFiredBundle = new TriggerFiredBundle(jobDetail, trigger, new BaseCalendar(), false, quartzFireTime, quartzFireTime, quartzPrevFireTime, quartzNextFireTime);
JobExecutionContext jobExecutionContext = new JobExecutionContext(scheduler, triggerFiredBundle, productStatusTask);
JobLauncher jobLauncher = mifosScheduler.getBatchJobLauncher();
JobLocator jobLocator = mifosScheduler.getBatchJobLocator();
jobLauncher.run(jobLocator.getJob(jobName), MifosBatchJob.createJobParameters(previousFireTime.getTime()));
Thread.sleep(1500);
productStatusTask.catchUpMissedLaunches(jobLocator.getJob(jobName), jobExecutionContext);
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 20);
Assert.assertEquals(11, jobInstances.size());
for (JobInstance jobInstance : jobInstances) {
List<JobExecution> jobExecutions = explorer.getJobExecutions(jobInstance);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecutions.get(0).getStatus());
Assert.assertEquals(calendar.getTimeInMillis(), jobInstance.getJobParameters().getLong(MifosBatchJob.JOB_EXECUTION_TIME_KEY));
calendar.roll(Calendar.SECOND, false);
}
}
use of org.quartz.spi.TriggerFiredBundle in project kylo by Teradata.
the class AutowiringSpringBeanJobFactoryTest method testSetApplicationContext.
@Test
public void testSetApplicationContext() throws Exception {
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setJobClass(MockJob.class);
TriggerFiredBundle bundle = new TriggerFiredBundle(jobDetail, Mockito.mock(OperableTrigger.class), new BaseCalendar(), true, new Date(), new Date(), new Date(), new Date());
assertNotNull(factory.createJobInstance(bundle));
}
use of org.quartz.spi.TriggerFiredBundle in project candlepin by candlepin.
the class HighlanderFactoryTest method testNewJob.
@Test
public void testNewJob() throws SchedulerException, ParseException {
assertNotNull(hf);
try {
hf.newJob(null, null);
fail("should've died with npe");
} catch (NullPointerException npe) {
// Expected
}
String crontab = "0 0 12 * * ?";
JobDetail jd = newJob(TestJob.class).withIdentity("testjob", "group").build();
Trigger trigger = newTrigger().withIdentity("testjob", "group").withSchedule(cronSchedule(crontab)).build();
TriggerFiredBundle tfb = new TriggerFiredBundle(jd, (OperableTrigger) trigger, null, false, null, null, null, null);
Job j = hf.newJob(tfb, null);
assertNotNull(j);
}
Aggregations