Search in sources :

Example 1 with CronJob

use of org.openhab.core.scheduler.CronJob in project openhab-core by openhab.

the class CronSchedulerImplTest method testAddRemoveScheduler.

@Test
@Timeout(value = 2, unit = TimeUnit.SECONDS)
public void testAddRemoveScheduler() throws InterruptedException {
    Semaphore s = new Semaphore(0);
    CronJob cronJob = m -> s.release();
    Map<String, Object> map = Map.of(CronJob.CRON, "* * * * * *");
    cronScheduler.addSchedule(cronJob, map);
    s.acquire();
    cronScheduler.removeSchedule(cronJob);
}
Also used : ScheduledCompletableFuture(org.openhab.core.scheduler.ScheduledCompletableFuture) NonNullByDefault(org.eclipse.jdt.annotation.NonNullByDefault) Semaphore(java.util.concurrent.Semaphore) Instant(java.time.Instant) AtomicReference(java.util.concurrent.atomic.AtomicReference) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Nullable(org.eclipse.jdt.annotation.Nullable) CronJob(org.openhab.core.scheduler.CronJob) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.junit.jupiter.api.Assertions) Timeout(org.junit.jupiter.api.Timeout) CronJob(org.openhab.core.scheduler.CronJob) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

Duration (java.time.Duration)1 Instant (java.time.Instant)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Semaphore (java.util.concurrent.Semaphore)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 NonNullByDefault (org.eclipse.jdt.annotation.NonNullByDefault)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Assertions (org.junit.jupiter.api.Assertions)1 Test (org.junit.jupiter.api.Test)1 Timeout (org.junit.jupiter.api.Timeout)1 CronJob (org.openhab.core.scheduler.CronJob)1 ScheduledCompletableFuture (org.openhab.core.scheduler.ScheduledCompletableFuture)1