Search code examples
quartz-scheduler

How to test quartz job


I'm using quartz framework to setup a schedule task in java. eg: I hope the job will be triggered at 12:00 o'clock from 2022-01-25 to 2022-01-29. is there any way that I can change the quartz's calendar to a specific date and time to make the schedule job can be triggered immediately?

if today is 2022-01-20, how can I mock current date and time in jvm, rather than bring up my spring boot service and wait, until that day...

thanks for your help.


Solution

  • The easiest way is probably using some of the GUI-based Quartz scheduler managers that let you connect to your Quartz scheduler manually execute arbitrary jobs through a GUI.

    Here is an example of how to do that using QuartzDesk (I am biased here), but other tools may work similarly. Even the QuartzDesk Lite (free) edition lets you do that. No application code changes are required.

    Triggering job from QuartzDesk GUI