Skip to content

Commit

Permalink
Quartz - improve the error message when scheduler is disabled...
Browse files Browse the repository at this point in the history
... and org.quartz.Scheduler is injected
- resolve quarkusio#10633
  • Loading branch information
mkouba authored and gsmet committed Jul 16, 2020
1 parent 28d396a commit ab103c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
@@ -1,7 +1,10 @@
package io.quarkus.quartz.test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import javax.enterprise.inject.Instance;
import javax.inject.Inject;

import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand All @@ -17,7 +20,10 @@
public class DisabledSchedulerTest {

@Inject
Scheduler quartzScheduler;
Scheduler scheduler;

@Inject
Instance<org.quartz.Scheduler> quartzScheduler;

@RegisterExtension
static final QuarkusUnitTest test = new QuarkusUnitTest()
Expand All @@ -28,7 +34,13 @@ public class DisabledSchedulerTest {

@Test
public void testNoSchedulerInvocations() throws InterruptedException {
assertFalse(quartzScheduler.isRunning());
assertFalse(scheduler.isRunning());
assertTrue(quartzScheduler.isResolvable());
try {
quartzScheduler.get();
fail();
} catch (IllegalStateException expected) {
}
}

static class Jobs {
Expand Down
Expand Up @@ -67,7 +67,7 @@ public class QuartzScheduler implements Scheduler {
org.quartz.Scheduler produceQuartzScheduler() {
if (scheduler == null) {
throw new IllegalStateException(
"Cannot produce org.quartz.Scheduler - Quartz scheduler is disabled or no schedules were found");
"Quartz scheduler is either explicitly disabled through quarkus.scheduler.enabled=false or no @Scheduled methods were found. If you only need to schedule a job programmatically you can force the start of the scheduler via quarkus.quartz.force-start=true");
}
return scheduler;
}
Expand Down

0 comments on commit ab103c3

Please sign in to comment.