forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler: run multiple scheduler implementations
- related to quarkusio#41954
- Loading branch information
Showing
18 changed files
with
577 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...rtz/deployment/src/test/java/io/quarkus/quartz/test/composite/CompositeSchedulerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.quarkus.quartz.test.composite; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.quartz.QuartzScheduler; | ||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.scheduler.Scheduled.Implementation; | ||
import io.quarkus.scheduler.Scheduler; | ||
import io.quarkus.scheduler.runtime.Constituent; | ||
import io.quarkus.scheduler.runtime.SimpleScheduler; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class CompositeSchedulerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(Jobs.class)) | ||
.overrideConfigKey("quarkus.scheduler.use-composite-scheduler", "true"); | ||
|
||
@Constituent | ||
QuartzScheduler quartz; | ||
|
||
@Constituent | ||
SimpleScheduler simple; | ||
|
||
@Inject | ||
Scheduler composite; | ||
|
||
@Test | ||
public void testExecution() throws InterruptedException { | ||
assertTrue(Jobs.SIMPLE_LATCH.await(5, TimeUnit.SECONDS)); | ||
assertTrue(Jobs.QUARTZ_LATCH.await(5, TimeUnit.SECONDS)); | ||
assertTrue(Jobs.AUTO_LATCH.await(5, TimeUnit.SECONDS)); | ||
|
||
assertNull(quartz.getScheduledJob("simple")); | ||
assertNotNull(quartz.getScheduledJob("quartz")); | ||
assertNotNull(quartz.getScheduledJob("auto")); | ||
|
||
assertNotNull(simple.getScheduledJob("simple")); | ||
assertNull(simple.getScheduledJob("quartz")); | ||
assertNull(simple.getScheduledJob("auto")); | ||
|
||
assertNotNull(composite.getScheduledJob("quartz")); | ||
assertNotNull(composite.getScheduledJob("auto")); | ||
assertNotNull(composite.getScheduledJob("simple")); | ||
} | ||
|
||
static class Jobs { | ||
|
||
static final CountDownLatch SIMPLE_LATCH = new CountDownLatch(1); | ||
static final CountDownLatch QUARTZ_LATCH = new CountDownLatch(1); | ||
static final CountDownLatch AUTO_LATCH = new CountDownLatch(1); | ||
|
||
@Scheduled(identity = "simple", every = "1s", executeWith = Implementation.SIMPLE) | ||
void simple() { | ||
SIMPLE_LATCH.countDown(); | ||
} | ||
|
||
@Scheduled(identity = "quartz", every = "1s", executeWith = Implementation.QUARTZ) | ||
void quartz() { | ||
QUARTZ_LATCH.countDown(); | ||
} | ||
|
||
@Scheduled(identity = "auto", every = "1s") | ||
void auto() { | ||
AUTO_LATCH.countDown(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.