grails / grails-quartz

This project provides integration of the Quartz scheduling framework into the Grails Framework
http://grails.org/plugin/quartz
Apache License 2.0
76 stars 90 forks source link

How to disable quartz in unit tests ? #116

Open vnybst opened 2 years ago

vnybst commented 2 years ago

Hi,

I am using quartz org.grails.plugins:quartz:2.0.13 with grails 3.3.14. My quartz config is as follows:

quartz:
    autoStartup: true
    jdbcStore: true
    waitForJobsToCompleteOnShutdown: false
    exposeSchedulerInRepository: false
    props:
        scheduler:
            skipUpdateCheck: true
    jobStore:
        tablePrefix: 'QRTZ_'
        misfireThreshold: 60000
        maxMisfiresToHandleAtATime: 2
        clusterCheckinInterval: 5000
        class: 'org.quartz.impl.jdbcjobstore.JobStoreTX'
        driverDelegateClass: 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'
        isClustered: true
        useProperties: false
    threadPool:
        threadCount: 4
        class: 'org.quartz.simpl.SimpleThreadPool'
        threadPriority: 1
    plugin:
        shutdownhook:
            class: 'org.quartz.plugins.management.ShutdownHookPlugin'
            cleanShutdown: true
        triggerHistory:
            class: 'org.quartz.plugins.history.LoggingTriggerHistoryPlugin'
    jobHistory:
        class: 'org.quartz.plugins.history.LoggingJobHistoryPlugin'

Now, i want to disable quartz for test environment. For that i did:

environments:
          test:
              quartz:
                    autoStartup: false
                    jdbcStore: false

in application.yml file.

But it gives me error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler': Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: DataSource name not set.

Caused by: org.quartz.SchedulerConfigException: DataSource name not set.

I tried setting

environments:
          test:
              quartz:
                    pluginEnabled: false

But then it gives me

Caused by: java.lang.NullPointerException: Cannot get property 'group' on null object
    at grails.plugins.quartz.QuartzJob$Trait$Helper.schedule(QuartzJob.groovy:58)