Search in sources :

Example 11 with SchedulableTask

use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.

the class SchedulerExecutorServiceImplTest method localSchedule.

@Test
void localSchedule() throws Exception {
    setLocal();
    final SchedulableTask task = mockTask("task1");
    service.schedule(task, 1, TimeUnit.SECONDS);
    assertEquals(1, service.getAllFutures().size());
    assertTrue(service.getAllFutures().contains(task.getName()));
    assertTrue(service.get(task.getName()).isPresent());
}
Also used : SchedulableTask(com.enonic.xp.impl.scheduler.distributed.SchedulableTask) Test(org.junit.jupiter.api.Test)

Example 12 with SchedulableTask

use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.

the class SchedulerExecutorServiceImplTest method mockTask.

private SchedulableTask mockTask(final String name) {
    final SchedulableTask task = mock(SchedulableTask.class);
    when(task.getName()).thenReturn(name);
    return task;
}
Also used : SchedulableTask(com.enonic.xp.impl.scheduler.distributed.SchedulableTask)

Example 13 with SchedulableTask

use of com.enonic.xp.impl.scheduler.distributed.SchedulableTask in project xp by enonic.

the class SchedulerExecutorServiceImplTest method clusterUnset.

@Test
public void clusterUnset() throws Exception {
    setCluster(0);
    final SchedulableTask task = mockTask("task1");
    service.unsetClusteredScheduler(clusteredScheduler);
    assertThrows(RuntimeException.class, () -> service.schedule(task, 1, TimeUnit.MILLISECONDS));
}
Also used : SchedulableTask(com.enonic.xp.impl.scheduler.distributed.SchedulableTask) Test(org.junit.jupiter.api.Test)

Aggregations

SchedulableTask (com.enonic.xp.impl.scheduler.distributed.SchedulableTask)13 Test (org.junit.jupiter.api.Test)12