@Test
@Timeout(value = 6, unit = TimeUnit.SECONDS)
public void testCronScheduling() throws Exception {

    long now = System.currentTimeMillis();
    AtomicReference<Object> ref = new AtomicReference<>();
    Semaphore s = new Semaphore(0);
    cronScheduler.schedule(foo -> {
        s.release();
        ref.set(foo.get("foo"));
    }, Map.of("foo", "bar"), "#\n" //
            + "\n" //
            + " foo = bar \n" //
            + "# bla bla foo=foo\n" //
            + "0/2 * * * * *");
    s.acquire(2);
    long diff = (System.currentTimeMillis() - now + 50) / 1000;
    assertTrue(diff >= 3 && diff <= 4, "Difference calculation should be between 3 and 4 but was: " + diff);
    assertEquals("bar", ref.get(), "Environment variable 'foo' should be correctly set");
}