use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithTaskExecutor.
@Test
public void schedulerWithTaskExecutor() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CountingTaskExecutor taskExecutor = new CountingTaskExecutor();
DummyJob.count = 0;
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setDurability(true);
jobDetail.setJobClass(DummyJob.class);
jobDetail.setName("myJob");
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setName("myTrigger");
trigger.setJobDetail(jobDetail);
trigger.setStartDelay(1);
trigger.setRepeatInterval(500);
trigger.setRepeatCount(1);
trigger.afterPropertiesSet();
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setTaskExecutor(taskExecutor);
bean.setTriggers(trigger.getObject());
bean.setJobDetails(jobDetail);
bean.afterPropertiesSet();
bean.start();
Thread.sleep(500);
assertTrue("DummyJob should have been executed at least once.", DummyJob.count > 0);
assertEquals(DummyJob.count, taskExecutor.count);
bean.destroy();
}
use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithQuartzJobBean.
@Test
public void schedulerWithQuartzJobBean() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
DummyJob.param = 0;
DummyJob.count = 0;
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setDurability(true);
jobDetail.setJobClass(DummyJobBean.class);
jobDetail.setName("myJob");
jobDetail.getJobDataMap().put("param", "10");
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setName("myTrigger");
trigger.setJobDetail(jobDetail);
trigger.setStartDelay(1);
trigger.setRepeatInterval(500);
trigger.setRepeatCount(1);
trigger.afterPropertiesSet();
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setTriggers(trigger.getObject());
bean.setJobDetails(jobDetail);
bean.afterPropertiesSet();
bean.start();
Thread.sleep(500);
assertEquals(10, DummyJobBean.param);
assertTrue(DummyJobBean.count > 0);
bean.destroy();
}
use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.
the class QuartzSupportTests method jobDetailWithRunnableInsteadOfJob.
@Test(expected = IllegalArgumentException.class)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void jobDetailWithRunnableInsteadOfJob() {
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setJobClass((Class) DummyRunnable.class);
}
use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithSpringBeanJobFactoryAndQuartzJobBean.
@Test
public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
DummyJobBean.param = 0;
DummyJobBean.count = 0;
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setDurability(true);
jobDetail.setJobClass(DummyJobBean.class);
jobDetail.setName("myJob");
jobDetail.getJobDataMap().put("param", "10");
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setName("myTrigger");
trigger.setJobDetail(jobDetail);
trigger.setStartDelay(1);
trigger.setRepeatInterval(500);
trigger.setRepeatCount(1);
trigger.afterPropertiesSet();
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setJobFactory(new SpringBeanJobFactory());
bean.setTriggers(trigger.getObject());
bean.setJobDetails(jobDetail);
bean.afterPropertiesSet();
bean.start();
Thread.sleep(500);
assertEquals(10, DummyJobBean.param);
assertTrue(DummyJobBean.count > 0);
bean.destroy();
}
use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithSpringBeanJobFactory.
@Test
public void schedulerWithSpringBeanJobFactory() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
DummyJob.param = 0;
DummyJob.count = 0;
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setDurability(true);
jobDetail.setJobClass(DummyJob.class);
jobDetail.setName("myJob");
jobDetail.getJobDataMap().put("param", "10");
jobDetail.getJobDataMap().put("ignoredParam", "10");
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setName("myTrigger");
trigger.setJobDetail(jobDetail);
trigger.setStartDelay(1);
trigger.setRepeatInterval(500);
trigger.setRepeatCount(1);
trigger.afterPropertiesSet();
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setJobFactory(new SpringBeanJobFactory());
bean.setTriggers(trigger.getObject());
bean.setJobDetails(jobDetail);
bean.afterPropertiesSet();
bean.start();
Thread.sleep(500);
assertEquals(10, DummyJob.param);
assertTrue("DummyJob should have been executed at least once.", DummyJob.count > 0);
bean.destroy();
}
Aggregations