use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithSpringBeanJobFactory.
@Test
@EnabledForTestGroups(LONG_RUNNING)
void schedulerWithSpringBeanJobFactory() throws Exception {
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);
assertThat(DummyJob.param).isEqualTo(10);
assertThat(DummyJob.count > 0).as("DummyJob should have been executed at least once.").isTrue();
bean.destroy();
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerWithTaskExecutor.
@Test
@EnabledForTestGroups(LONG_RUNNING)
void schedulerWithTaskExecutor() throws Exception {
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);
assertThat(DummyJob.count > 0).as("DummyJob should have been executed at least once.").isTrue();
assertThat(taskExecutor.count).isEqualTo(DummyJob.count);
bean.destroy();
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class EnableSchedulingTests method withExplicitScheduledTaskRegistrar.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withExplicitScheduledTaskRegistrar() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(ExplicitScheduledTaskRegistrarConfig.class);
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(1);
Thread.sleep(100);
assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10);
assertThat(ctx.getBean(ExplicitScheduledTaskRegistrarConfig.class).threadName).startsWith("explicitScheduler1");
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class EnableSchedulingTests method withAmbiguousTaskSchedulers_andSingleTask_disambiguatedByScheduledTaskRegistrarBean.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withAmbiguousTaskSchedulers_andSingleTask_disambiguatedByScheduledTaskRegistrarBean() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withAmbiguousTaskSchedulers_andSingleTask_disambiguatedByScheduledTaskRegistrar.class);
Thread.sleep(100);
assertThat(ctx.getBean(ThreadAwareWorker.class).executedByThread).startsWith("explicitScheduler2-");
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class EnableSchedulingTests method withTaskAddedVia_configureTasks.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withTaskAddedVia_configureTasks() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withTaskAddedVia_configureTasks.class);
Thread.sleep(100);
assertThat(ctx.getBean(ThreadAwareWorker.class).executedByThread).startsWith("taskScheduler-");
}
Aggregations