-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #10967 from marcelorubim/master
Added support to Quartz Plugins And Listeners
- Loading branch information
Showing
10 changed files
with
258 additions
and
0 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
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
28 changes: 28 additions & 0 deletions
28
...loyment/src/test/java/io/quarkus/quartz/test/InvalidTriggerListenerConfigurationTest.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,28 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
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.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InvalidTriggerListenerConfigurationTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(IllegalArgumentException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(SimpleJobs.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.quartz.triggerListener.jobHistory.class=org.quartz.plugins.history.LoggingJobHistoryPlugin\n" | ||
+ "quarkus.quartz.triggerListener.jobHistory.jobSuccessMessage=Job [{1}.{0}] execution complete and reports: {8}"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void shouldFailWhenInvalidTriggerListenerConfiguration() { | ||
Assertions.fail(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...sions/quartz/deployment/src/test/java/io/quarkus/quartz/test/RegisterJobListenerTest.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,43 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
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 org.quartz.SchedulerException; | ||
|
||
import io.quarkus.quartz.test.listeners.HelloJobListener; | ||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RegisterJobListenerTest { | ||
|
||
@Inject | ||
org.quartz.Scheduler quartzScheduler; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Jobs.class) | ||
.addClass(HelloJobListener.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.quartz.jobListener.testJobListener.class=io.quarkus.quartz.test.listeners.HelloJobListener"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testJobListenerRegistered() throws InterruptedException, SchedulerException { | ||
assertNotNull(quartzScheduler.getListenerManager().getJobListener("testJobListener")); | ||
} | ||
|
||
static class Jobs { | ||
@Scheduled(every = "1s") | ||
void checkEverySecond() { | ||
// no op | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../deployment/src/test/java/io/quarkus/quartz/test/RegisterLoggingJobHistoryPluginTest.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,42 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
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 RegisterLoggingJobHistoryPluginTest { | ||
|
||
@Inject | ||
Scheduler quartzScheduler; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Jobs.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.quartz.plugin.jobHistory.class=org.quartz.plugins.history.LoggingJobHistoryPlugin\n" | ||
+ "quarkus.quartz.plugin.jobHistory.jobSuccessMessage=Job [{1}.{0}] execution complete and reports: {8}"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testSchedulerStarted() throws InterruptedException { | ||
assertTrue(quartzScheduler.isRunning()); | ||
} | ||
|
||
static class Jobs { | ||
@Scheduled(every = "1s") | ||
void checkEverySecond() { | ||
// no op | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ns/quartz/deployment/src/test/java/io/quarkus/quartz/test/listeners/HelloJobListener.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,28 @@ | ||
package io.quarkus.quartz.test.listeners; | ||
|
||
import org.quartz.JobExecutionContext; | ||
import org.quartz.JobExecutionException; | ||
import org.quartz.JobListener; | ||
|
||
public class HelloJobListener implements JobListener { | ||
|
||
@Override | ||
public String getName() { | ||
return "testJobListener"; | ||
} | ||
|
||
@Override | ||
public void jobToBeExecuted(JobExecutionContext jobExecutionContext) { | ||
|
||
} | ||
|
||
@Override | ||
public void jobExecutionVetoed(JobExecutionContext jobExecutionContext) { | ||
|
||
} | ||
|
||
@Override | ||
public void jobWasExecuted(JobExecutionContext jobExecutionContext, JobExecutionException e) { | ||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...s/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzAdditionalPropsConfig.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,25 @@ | ||
package io.quarkus.quartz.runtime; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.runtime.annotations.ConfigDocMapKey; | ||
import io.quarkus.runtime.annotations.ConfigDocSection; | ||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class QuartzAdditionalPropsConfig { | ||
/** | ||
* Class name for the configuration. | ||
*/ | ||
@ConfigItem(name = "class") | ||
public String clazz; | ||
|
||
/** | ||
* The props name and the values for the props. | ||
*/ | ||
@ConfigDocSection | ||
@ConfigDocMapKey("propsAndValue") | ||
@ConfigItem(name = ConfigItem.PARENT) | ||
public Map<String, String> propsValue; | ||
} |
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