use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.
the class SchedulerExecutorServiceImplTest method clusterAtFixedRate.
@Test
public void clusterAtFixedRate() throws Exception {
setCluster(0);
final SchedulableTask task = mockTask("task1");
service.scheduleAtFixedRate(task, 0, 10, TimeUnit.MILLISECONDS);
verify(hazelcastExecutorService, times(1)).scheduleAtFixedRate(task, 0, 10, TimeUnit.MILLISECONDS);
}
use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.
the class SchedulerExecutorServiceImplTest method clusterTimeout.
@Test
public void clusterTimeout() throws Exception {
setCluster(6000);
final SchedulableTask task = mockTask("task1");
service.unsetClusteredScheduler(clusteredScheduler);
assertThrows(RuntimeException.class, () -> service.schedule(task, 1, TimeUnit.MILLISECONDS));
}
use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.
the class SchedulerExecutorServiceImplTest method localAtFixedRate.
@Test
public void localAtFixedRate() throws Exception {
setLocal();
final SchedulableTask task = mockTask("task1");
service.scheduleAtFixedRate(task, 0, 10, TimeUnit.MILLISECONDS);
Thread.sleep(50);
verify(task, atLeast(4)).run();
}
use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.
the class SchedulerExecutorServiceImplTest method localDeactivate.
@Test
public void localDeactivate() throws Exception {
setLocal();
final SchedulableTask task = mockTask("task1");
localScheduler.deactivate();
assertThrows(RejectedExecutionException.class, () -> service.schedule(task, 1, TimeUnit.MILLISECONDS));
}
use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.
the class SchedulerExecutorServiceImplTest method localCancelled.
@Test
void localCancelled() throws Exception {
setLocal();
final SchedulableTask task = mockTask("task1");
final ScheduledFuture<?> future = service.scheduleAtFixedRate(task, 100, 10000, TimeUnit.MILLISECONDS);
future.cancel(true);
Thread.sleep(200);
verify(task, never()).run();
}
Aggregations