-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13532 from sultansoy/fix-simple-scheduler
Fix SimpleScheduler pause functionality
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...ons/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/PausedSchedulerTest.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,48 @@ | ||
package io.quarkus.scheduler.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.scheduler.Scheduler; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class PausedSchedulerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(PausedSchedulerTest.Jobs.class) | ||
.addAsResource(new StringAsset("quarkus.scheduler.enabled=true"), | ||
"application.properties")); | ||
|
||
@Inject | ||
Scheduler scheduler; | ||
|
||
@Test | ||
public void testSchedulerPauseMethod() throws InterruptedException { | ||
scheduler.pause(); | ||
assertFalse(scheduler.isRunning()); | ||
assertFalse(Jobs.LATCH.await(3, TimeUnit.SECONDS)); | ||
} | ||
|
||
static class Jobs { | ||
static final CountDownLatch LATCH = new CountDownLatch(2); | ||
|
||
@Scheduled(every = "1s") | ||
void countDownSecond() { | ||
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