Search in sources :

Example 1 with JobDetailImpl

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();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Example 2 with JobDetailImpl

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();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Example 3 with JobDetailImpl

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);
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Example 4 with JobDetailImpl

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();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Example 5 with JobDetailImpl

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();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Aggregations

JobDetailImpl (org.quartz.impl.JobDetailImpl)13 Test (org.junit.Test)9 JobDetail (org.quartz.JobDetail)3 ParseException (java.text.ParseException)2 JobContext (org.craftercms.engine.util.quartz.JobContext)2 RequisitionDef (org.opennms.netmgt.config.provisiond.RequisitionDef)2 CronTrigger (org.quartz.CronTrigger)2 SchedulerException (org.quartz.SchedulerException)2 CronTriggerImpl (org.quartz.impl.triggers.CronTriggerImpl)2 Calendar (java.util.Calendar)1 Report (org.opennms.netmgt.config.reportd.Report)1 Job (org.quartz.Job)1 JobExecutionContext (org.quartz.JobExecutionContext)1 Trigger (org.quartz.Trigger)1 TriggerListener (org.quartz.TriggerListener)1 SimpleTriggerImpl (org.quartz.impl.triggers.SimpleTriggerImpl)1