use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class EnableSchedulingTests method withAmbiguousTaskSchedulers_andSingleTask_disambiguatedBySchedulerNameAttribute.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withAmbiguousTaskSchedulers_andSingleTask_disambiguatedBySchedulerNameAttribute() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withAmbiguousTaskSchedulers_andSingleTask_disambiguatedBySchedulerNameAttribute.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 withInitiallyDelayedFixedRateTask.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withInitiallyDelayedFixedRateTask() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfig_withInitialDelay.class);
Thread.sleep(1950);
AtomicInteger counter = ctx.getBean(AtomicInteger.class);
// The @Scheduled method should have been called at least once but
// not more times than the delay allows.
assertThat(counter.get()).isBetween(1, 10);
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class EnableSchedulingTests method withSubclass.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withSubclass() throws InterruptedException {
ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfigSubclass.class);
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(2);
Thread.sleep(100);
assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10);
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class ScheduledExecutorFactoryBeanTests method withInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly.
@Test
@EnabledForTestGroups(LONG_RUNNING)
void withInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
Runnable runnable = mock(Runnable.class);
ScheduledExecutorTask task = new ScheduledExecutorTask(runnable);
task.setPeriod(500);
// nice long wait...
task.setDelay(3000);
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
factory.setScheduledExecutorTasks(task);
factory.afterPropertiesSet();
pauseToLetTaskStart(1);
// invoke destroy before tasks have even been scheduled...
factory.destroy();
// Mock must never have been called
verify(runnable, never()).run();
}
use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.
the class ScheduledExecutorFactoryBeanTests method fixedRepeatedExecutionIsSetUpAndFiresCorrectly.
@Test
@EnabledForTestGroups(LONG_RUNNING)
void fixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
Runnable runnable = mock(Runnable.class);
ScheduledExecutorTask task = new ScheduledExecutorTask(runnable);
task.setPeriod(500);
task.setFixedRate(true);
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
factory.setScheduledExecutorTasks(task);
factory.afterPropertiesSet();
pauseToLetTaskStart(2);
factory.destroy();
verify(runnable, atLeast(2)).run();
}
Aggregations