Skip to content

How to disable quartz in unit tests ? #116

@vnybst

Description

@vnybst

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions