diff --git a/.gitignore b/.gitignore index 4a77147c..18f63658 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ target-eclipse # Unused grails files grails-app/i18n/ + +plugin.xml \ No newline at end of file diff --git a/QuartzGrailsPlugin.groovy b/QuartzGrailsPlugin.groovy index 099ac96c..1b97eec6 100644 --- a/QuartzGrailsPlugin.groovy +++ b/QuartzGrailsPlugin.groovy @@ -14,14 +14,26 @@ * limitations under the License. */ -import grails.plugins.quartz.* -import grails.plugins.quartz.GrailsJobClassConstants as Constants +import grails.plugins.quartz.CustomTriggerFactoryBean +import grails.plugins.quartz.GrailsJobClass +import grails.plugins.quartz.GrailsJobFactory +import grails.plugins.quartz.JobArtefactHandler +import grails.plugins.quartz.JobDetailFactoryBean +import grails.plugins.quartz.TriggerUtils import grails.plugins.quartz.listeners.ExceptionPrinterJobListener import grails.plugins.quartz.listeners.SessionBinderJobListener import grails.spring.BeanBuilder import grails.util.Environment + import org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext -import org.quartz.* +import org.quartz.JobDataMap +import org.quartz.JobDetail +import org.quartz.JobKey +import org.quartz.ListenerManager +import org.quartz.Scheduler +import org.quartz.SimpleTrigger +import org.quartz.Trigger +import org.quartz.TriggerKey import org.quartz.impl.matchers.KeyMatcher import org.quartz.spi.MutableTrigger import org.slf4j.Logger @@ -30,11 +42,8 @@ import org.springframework.beans.factory.config.MethodInvokingFactoryBean import org.springframework.context.ApplicationContext import org.springframework.scheduling.quartz.SchedulerFactoryBean -import grails.plugins.quartz.TriggerUtils - /** - * A plug-in that configures Quartz job support for Grails. - * + * Configures Quartz job support. * * @author Graeme Rocher * @author Marcel Overdijk @@ -44,20 +53,22 @@ import grails.plugins.quartz.TriggerUtils */ class QuartzGrailsPlugin { - def version = "1.0-RC11" + def version = "1.0" def grailsVersion = "2.0 > *" def author = "Sergey Nebolsin, Graeme Rocher, Ryan Vanderwerf, Vitalii Samolovskikh" def authorEmail = "rvanderwerf@gmail.com" def title = "Quartz plugin for Grails" - def description = '''\ -This plugin adds Quartz job scheduling features to Grails application. -''' + def description = 'Adds Quartz job scheduling features' def documentation = "http://grails.org/plugin/quartz" - def pluginExcludes = ['grails-app/jobs/**'] + def pluginExcludes = [ + 'grails-app/jobs/**', + 'src/docs/**', + 'web-app/**' + ] def license = "APACHE" - def issueManagement = [system: "GitHub Issues", url: "http://jira.grails.org/browse/GPQUARTZ"] + def issueManagement = [system: "JIRA", url: "http://jira.grails.org/browse/GPQUARTZ"] def scm = [url: "http://github.com/grails-plugins/grails-quartz"] def loadAfter = ['core', 'hibernate', 'datasources'] @@ -169,7 +180,7 @@ This plugin adds Quartz job scheduling features to Grails application. * Adds schedule methods for job classes. */ private static void addMethods(tc, ctx) { - Scheduler quartzScheduler = ctx.getBean('quartzScheduler') + Scheduler quartzScheduler = ctx.quartzScheduler def mc = tc.metaClass String jobName = tc.getFullName() String jobGroup = tc.getGroup() @@ -243,23 +254,22 @@ This plugin adds Quartz job scheduling features to Grails application. * Schedules jobs. Creates job details and trigger beans. And schedules them. */ def scheduleJob(GrailsJobClass jobClass, ApplicationContext ctx, boolean hasHibernate) { - Scheduler scheduler = ctx.getBean("quartzScheduler") as Scheduler + Scheduler scheduler = ctx.quartzScheduler if (scheduler) { def fullName = jobClass.fullName // Creates job details - JobDetailFactoryBean jdfb = new JobDetailFactoryBean(); + JobDetailFactoryBean jdfb = new JobDetailFactoryBean() jdfb.jobClass = jobClass jdfb.afterPropertiesSet() JobDetail jobDetail = jdfb.object // adds the job to the scheduler, and associates triggers with it - scheduler.addJob(jobDetail, true); + scheduler.addJob(jobDetail, true) // The session listener if is needed if (hasHibernate && jobClass.sessionRequired) { - SessionBinderJobListener listener = - ctx.getBean("${SessionBinderJobListener.NAME}") as SessionBinderJobListener + SessionBinderJobListener listener = ctx.getBean(SessionBinderJobListener.NAME) if (listener != null) { ListenerManager listenerManager = scheduler.getListenerManager() KeyMatcher matcher = KeyMatcher.keyEquals(jobDetail.key) @@ -275,7 +285,7 @@ This plugin adds Quartz job scheduling features to Grails application. // Creates and schedules triggers jobClass.triggers.each { name, Expando descriptor -> - CustomTriggerFactoryBean factory = new CustomTriggerFactoryBean(); + CustomTriggerFactoryBean factory = new CustomTriggerFactoryBean() factory.triggerClass = descriptor.triggerClass factory.triggerAttributes = descriptor.triggerAttributes factory.jobDetail = jobDetail @@ -304,7 +314,7 @@ This plugin adds Quartz job scheduling features to Grails application. log.debug("Job ${event.source} changed. Reloading...") GrailsApplicationContext context = event.ctx - def scheduler = context?.getBean("quartzScheduler") + def scheduler = context?.quartzScheduler GrailsJobClass jobClass = application.getJobClass(event.source?.name) @@ -314,7 +324,7 @@ This plugin adds Quartz job scheduling features to Grails application. // get quartz scheduler if (context && scheduler) { - // if job already exists, delete it from scheduler + // if job already exists, delete it from scheduler if (jobClass) { def jobKey = new JobKey(jobClass.fullName, jobClass.group) scheduler.deleteJob(jobKey) @@ -322,7 +332,7 @@ This plugin adds Quartz job scheduling features to Grails application. } // add job artifact to application - jobClass = application.addArtefact(JobArtefactHandler.TYPE, event.source as Class) as GrailsJobClass + jobClass = application.addArtefact(JobArtefactHandler.TYPE, event.source as Class) def fullName = jobClass.fullName boolean hasHibernate = manager?.hasGrailsPlugin("hibernate") @@ -337,7 +347,7 @@ This plugin adds Quartz job scheduling features to Grails application. context.registerBeanDefinition("${fullName}", beans.getBeanDefinition("${fullName}")) // Reschedule jobs - scheduleJob(jobClass as GrailsJobClass, event.ctx as ApplicationContext, hasHibernate) + scheduleJob(jobClass, event.ctx, hasHibernate) } else { log.error("Application context or Quartz Scheduler not found. Can't reload Quartz plugin.") } @@ -345,17 +355,17 @@ This plugin adds Quartz job scheduling features to Grails application. } /* - * Load the various configs. + * Load the various configs. * Order of priority has been "fixed" in 1.0-RC2 to be: * - * 1. DefaultQuartzConfig is loaded + * 1. DefaultQuartzConfig is loaded * 2. App's Config.groovy is loaded in and overwrites anything from DQC * 3. QuartzConfig is loaded and overwrites anything from DQC or AppConfig * 4. quartz.properties are loaded into config as quartz._props */ private ConfigObject loadQuartzConfig(ConfigObject config) { def classLoader = new GroovyClassLoader(getClass().classLoader) - String environment = Environment.current.toString() + String environment = Environment.current.name // Note here the order of objects when calling merge - merge OVERWRITES values in the target object // Load default Quartz config as a basis diff --git a/README.rdoc b/README.rdoc index 4b01f60b..da7be2a4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,6 +1,6 @@ = Grails Quartz Plugin http://stillmaintained.com/nebolsin/grails-quartz.png -This plugin has been updated to run on Quartz 2.1.x and no longer runs on Quartz 1.8.x. The newer +This plugin has been updated to run on Quartz 2.2.x and no longer runs on Quartz 1.8.x. The newer version of Quartz will also allow it to be used With Terrcotta 3.6 or later (I tested on 3.7) - Ryan This is different than the quartz2 plugin others maintain, because it does not use JobDetailsImpl, that one will @@ -13,9 +13,9 @@ configured via {Spring}[http://www.springsource.org/about], but is made simpler == Installation -To install the latest stable version of the plugin run: +To install the latest stable version of the plugin add this to your BuildConfig.groovy in the plugins section (be sure to use the latest version): - grails install-plugin quartz + compile ':quartz:1.0-RC11' == Using diff --git a/application.properties b/application.properties index 5026e30b..fab2d5cc 100644 --- a/application.properties +++ b/application.properties @@ -1,5 +1,2 @@ -#Grails Metadata file -#Tue Oct 01 23:31:25 CDT 2013 app.grails.version=2.3.0 app.name=quartz -app.servlet.version=2.5 diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy index 39e745cc..d8c40448 100644 --- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -1,7 +1,4 @@ -grails.project.source.level = 1.6 -grails.project.class.dir = "target/classes" -grails.project.test.class.dir = "target/test-classes" -grails.project.test.reports.dir = "target/test-reports" +grails.project.work.dir = "target" grails.project.dependency.resolution = { inherits "global" @@ -13,13 +10,15 @@ grails.project.dependency.resolution = { mavenCentral() } - plugins { - build ":release:3.0.1", { export = false } - } - dependencies { compile("org.quartz-scheduler:quartz:2.2.0") { excludes 'slf4j-api', 'c3p0' } } + + plugins { + build ':release:3.0.1', ':rest-client-builder:1.0.3', { + export = false + } + } } diff --git a/plugin.xml b/plugin.xml deleted file mode 100644 index acddb83c..00000000 --- a/plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ - - Sergey Nebolsin, Graeme Rocher, Ryan Vanderwerf - rvanderwerf@gmail.com - Quartz plugin for Grails - This plugin adds Quartz job scheduling features to Grails application. - - http://grails.org/plugin/quartz - QuartzGrailsPlugin - - DefaultQuartzConfig - QuartzBootStrap - grails.plugins.quartz.JobManagerService - - - - - - - - - - - - - - \ No newline at end of file diff --git a/scripts/CreateJob.groovy b/scripts/CreateJob.groovy index d67fdb85..fc574ec8 100644 --- a/scripts/CreateJob.groovy +++ b/scripts/CreateJob.groovy @@ -1,12 +1,12 @@ /* * Copyright 2006-2008 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,39 +22,20 @@ * @since 0.2 */ -Ant.property(environment: "env") -grailsHome = Ant.antProject.properties."env.GRAILS_HOME" - - - -if (grails.util.GrailsUtil.grailsVersion.startsWith("1.0")) { - includeTargets << new File("${grailsHome}/scripts/Init.groovy") - includeTargets << new File("${grailsHome}/scripts/CreateIntegrationTest.groovy") +includeTargets << grailsScript("_GrailsInit") +includeTargets << grailsScript("_GrailsCreateArtifacts") - target('default': "Creates a new Quartz scheduled job") { - depends(checkVersion) +target(createJob: "Creates a new Quartz scheduled job") { + depends(checkVersion, parseArguments) - typeName = "Job" - artifactName = "Job" - artifactPath = "grails-app/jobs" + def type = "Job" + promptForName(type: type) - createArtifact() - createTestSuite() - } -} else { - includeTargets << grailsScript("_GrailsInit") - includeTargets << grailsScript("_GrailsCreateArtifacts") - - target('default': "Creates a new Quartz scheduled job") { - depends(checkVersion, parseArguments) - - def type = "Job" - promptForName(type: type) - - for (name in argsMap["params"]) { - name = purgeRedundantArtifactSuffix(name, type) - createArtifact(name: name, suffix: type, type: type, path: "grails-app/jobs") - createUnitTest(name: name, suffix: type) - } + for (name in argsMap["params"]) { + name = purgeRedundantArtifactSuffix(name, type) + createArtifact(name: name, suffix: type, type: type, path: "grails-app/jobs") + createUnitTest(name: name, suffix: type) } } + +setDefaultTarget 'createJob' diff --git a/scripts/InstallQuartzConfig.groovy b/scripts/InstallQuartzConfig.groovy index c5397f9a..58d2b283 100644 --- a/scripts/InstallQuartzConfig.groovy +++ b/scripts/InstallQuartzConfig.groovy @@ -22,24 +22,14 @@ * @since 0.3 */ -if(grails.util.GrailsUtil.grailsVersion.startsWith("1.0")) { - includeTargets << new File ( "${grailsHome}/scripts/Init.groovy" ) - includeTargets << new File( "${grailsHome}/scripts/CreateIntegrationTest.groovy") -} else { - includeTargets << grailsScript("_GrailsInit") - includeTargets << grailsScript("_GrailsCreateArtifacts") +includeTargets << grailsScript("_GrailsInit") +includeTargets << grailsScript("_GrailsCreateArtifacts") -} - -target('default': "Installs Quartz config in the /grails-app/conf/ directory") { - installQuartzConfig() -} - -target(installQuartzConfig: "The implementation task") { +target(installQuartzConfig: "Installs Quartz config in the /grails-app/conf/ directory") { depends(checkVersion) def configFile = "${basedir}/grails-app/conf/QuartzConfig.groovy" if(!(configFile as File).exists() || confirmInput("Quartz config file already exists in your project. Overwrite it?")) { - Ant.copy( + ant.copy( file:"${quartzPluginDir}/grails-app/conf/DefaultQuartzConfig.groovy", tofile:configFile, overwrite: true @@ -50,6 +40,8 @@ target(installQuartzConfig: "The implementation task") { } confirmInput = {String message -> - Ant.input(message: message, addproperty: "confirm.message", validargs: "y,n") - Ant.antProject.properties."confirm.message" == "y" + ant.input(message: message, addproperty: "confirm.message", validargs: "y,n") + ant.antProject.properties."confirm.message" == "y" } + +setDefaultTarget 'installQuartzConfig' diff --git a/scripts/_Install.groovy b/scripts/_Install.groovy index c54cd47b..eb4296ed 100644 --- a/scripts/_Install.groovy +++ b/scripts/_Install.groovy @@ -22,4 +22,4 @@ * @since 0.2 */ -Ant.mkdir(dir:"${basedir}/grails-app/jobs") +ant.mkdir(dir:"${basedir}/grails-app/jobs") diff --git a/scripts/_Upgrade.groovy b/scripts/_Upgrade.groovy index 4a2dd944..91af5725 100644 --- a/scripts/_Upgrade.groovy +++ b/scripts/_Upgrade.groovy @@ -23,4 +23,4 @@ */ // ensure that there are 'jobs' directory under application 'grails-app' -Ant.mkdir(dir:"${basedir}/grails-app/jobs") +ant.mkdir(dir:"${basedir}/grails-app/jobs") diff --git a/src/groovy/grails/plugins/quartz/config/TriggersConfigBuilder.groovy b/src/groovy/grails/plugins/quartz/config/TriggersConfigBuilder.groovy index 6e6a6692..2837c114 100644 --- a/src/groovy/grails/plugins/quartz/config/TriggersConfigBuilder.groovy +++ b/src/groovy/grails/plugins/quartz/config/TriggersConfigBuilder.groovy @@ -16,10 +16,10 @@ package grails.plugins.quartz.config -import grails.plugins.quartz.GrailsJobClassConstants as Constants - import grails.plugins.quartz.CustomTriggerFactoryBean +import grails.plugins.quartz.GrailsJobClassConstants as Constants import grails.util.GrailsUtil + import org.quartz.CronExpression import org.quartz.SimpleTrigger import org.quartz.Trigger @@ -33,21 +33,20 @@ import org.quartz.impl.triggers.SimpleTriggerImpl * * @since 0.3 */ -public class TriggersConfigBuilder extends BuilderSupport { +class TriggersConfigBuilder extends BuilderSupport { private triggerNumber = 0 private jobName def triggers = [:] - public TriggersConfigBuilder(String jobName) { - super() + TriggersConfigBuilder(String jobName) { this.jobName = jobName } /** * Evaluate triggers closure */ - public build(closure) { + def build(closure) { closure.delegate = this closure.call() return triggers @@ -60,7 +59,7 @@ public class TriggersConfigBuilder extends BuilderSupport { * @param attributes trigger attributes * @return trigger definitions */ - public Expando createTrigger(def name, Map attributes) { + Expando createTrigger(name, Map attributes) { def triggerClass def triggerAttributes = attributes ? new HashMap(attributes) : [:] @@ -131,18 +130,18 @@ public class TriggersConfigBuilder extends BuilderSupport { if (!(it instanceof Integer || it instanceof Long)) { throw new IllegalArgumentException( "startDelay trigger property in the job class ${jobName} must be Integer or Long" - ); + ) } if (((Number) it).longValue() < 0) { throw new IllegalArgumentException( "startDelay trigger property in the job class ${jobName} is negative (possibly integer overflow error)" - ); + ) } } ) } - private def prepareSimpleTriggerAttributes(Map triggerAttributes) { + private prepareSimpleTriggerAttributes(Map triggerAttributes) { def prepare = prepareTriggerAttribute.curry(triggerAttributes) // Process the old deprecated property "timeout" @@ -152,12 +151,12 @@ public class TriggersConfigBuilder extends BuilderSupport { if (!(triggerAttributes[Constants.TIMEOUT] instanceof Integer || triggerAttributes[Constants.TIMEOUT] instanceof Long)) { throw new IllegalArgumentException( "timeout trigger property in the job class ${jobName} must be Integer or Long" - ); + ) } if (((Number) triggerAttributes[Constants.TIMEOUT]).longValue() < 0) { throw new IllegalArgumentException( "timeout trigger property for job class ${jobName} is negative (possibly integer overflow error)" - ); + ) } triggerAttributes[Constants.REPEAT_INTERVAL] = triggerAttributes.remove(Constants.TIMEOUT) } @@ -168,10 +167,10 @@ public class TriggersConfigBuilder extends BuilderSupport { Constants.DEFAULT_REPEAT_INTERVAL, { if (!(it instanceof Integer || it instanceof Long)) { - throw new IllegalArgumentException("repeatInterval trigger property in the job class ${jobName} must be Integer or Long"); + throw new IllegalArgumentException("repeatInterval trigger property in the job class ${jobName} must be Integer or Long") } if (((Number) it).longValue() < 0) { - throw new IllegalArgumentException("repeatInterval trigger property for job class ${jobName} is negative (possibly integer overflow error)"); + throw new IllegalArgumentException("repeatInterval trigger property for job class ${jobName} is negative (possibly integer overflow error)") } } ) @@ -184,18 +183,18 @@ public class TriggersConfigBuilder extends BuilderSupport { if (!(it instanceof Integer || it instanceof Long)) { throw new IllegalArgumentException( "repeatCount trigger property in the job class ${jobName} must be Integer or Long" - ); + ) } if (((Number) it).longValue() < 0 && ((Number) it).longValue() != SimpleTrigger.REPEAT_INDEFINITELY) { throw new IllegalArgumentException( "repeatCount trigger property for job class ${jobName} is negative (possibly integer overflow error)" - ); + ) } } ) } - private def prepareCronTriggerAttributes(Map triggerAttributes) { + private prepareCronTriggerAttributes(Map triggerAttributes) { prepareTriggerAttribute( triggerAttributes, Constants.CRON_EXPRESSION, @@ -204,13 +203,13 @@ public class TriggersConfigBuilder extends BuilderSupport { if (!CronExpression.isValidExpression(it.toString())) { throw new IllegalArgumentException( "Cron expression '${it}' in the job class ${jobName} is not a valid cron expression" - ); + ) } } ) } - private prepareTriggerAttribute = {Map attributes, String name, def defaultValue, validate = {} -> + private prepareTriggerAttribute = {Map attributes, String name, defaultValue, validate = {} -> if(attributes[name] == null){ attributes[name] = defaultValue } diff --git a/src/java/grails/plugins/quartz/CustomTriggerFactoryBean.java b/src/java/grails/plugins/quartz/CustomTriggerFactoryBean.java index c65aab61..aa87f438 100644 --- a/src/java/grails/plugins/quartz/CustomTriggerFactoryBean.java +++ b/src/java/grails/plugins/quartz/CustomTriggerFactoryBean.java @@ -16,9 +16,13 @@ package grails.plugins.quartz; +import java.beans.PropertyEditorSupport; +import java.text.ParseException; +import java.util.Date; +import java.util.Map; + import org.quartz.JobDetail; import org.quartz.Trigger; -import org.quartz.impl.JobDetailImpl; import org.quartz.impl.triggers.AbstractTrigger; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanWrapper; @@ -26,11 +30,6 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; -import java.beans.PropertyEditorSupport; -import java.text.ParseException; -import java.util.Date; -import java.util.Map; - /** * The factory bean to create and register trigger beans in Spring context. * @@ -120,4 +119,4 @@ public void setValue(Object value) { public void setAsText(String text) throws IllegalArgumentException { setValue(text); } -} \ No newline at end of file +} diff --git a/test/integration/QuartzPluginTests.groovy b/test/integration/QuartzPluginTests.groovy index 3feebc64..8829b78c 100644 --- a/test/integration/QuartzPluginTests.groovy +++ b/test/integration/QuartzPluginTests.groovy @@ -14,21 +14,18 @@ * limitations under the License. */ -import org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration -import org.springframework.context.ApplicationContextAware -import org.springframework.context.ApplicationContext import grails.plugins.quartz.JobArtefactHandler import grails.plugins.quartz.listeners.ExceptionPrinterJobListener -import grails.plugins.quartz.listeners.SessionBinderJobListener + +import org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration +import org.springframework.context.ApplicationContext +import org.springframework.context.ApplicationContextAware class QuartzPluginTests extends GroovyTestCase implements ApplicationContextAware { - def transactional = false + boolean transactional = false def grailsApplication def pluginManager - def applicationContext - - void setUp() { - } + ApplicationContext applicationContext void testLoading() { assertNotNull 'Plugin manager is null', pluginManager @@ -58,8 +55,4 @@ class QuartzPluginTests extends GroovyTestCase implements ApplicationContextAwar def ctx = springConfig.applicationContext assertTrue "Bean 'TestJob' is not registered in application context", ctx.containsBean('TestJob') } - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext - } } diff --git a/test/integration/grails/plugins/quartz/DynamicMethodsTests.groovy b/test/integration/grails/plugins/quartz/DynamicMethodsTests.groovy index 5f4fcf8a..9b2560e0 100644 --- a/test/integration/grails/plugins/quartz/DynamicMethodsTests.groovy +++ b/test/integration/grails/plugins/quartz/DynamicMethodsTests.groovy @@ -1,5 +1,8 @@ package grails.plugins.quartz +import static org.quartz.JobBuilder.newJob +import static org.quartz.TriggerBuilder.* + import org.codehaus.groovy.grails.commons.GrailsApplication import org.codehaus.groovy.grails.plugins.GrailsPluginManager import org.junit.After @@ -13,9 +16,6 @@ import org.quartz.SimpleTrigger import org.quartz.Trigger import org.quartz.TriggerKey -import static org.quartz.JobBuilder.newJob; -import static org.quartz.TriggerBuilder.*; - /** * Tests the dynamic methods of jobs. * @@ -91,7 +91,7 @@ class DynamicMethodsTests extends GroovyTestCase { .withSchedule(SimpleScheduleBuilder.repeatMinutelyForever()).build() IntegrationTestJob.schedule(trigger) assertLength(1, quartzScheduler.getTriggersOfJob(jobDetail.key)) - IntegrationTestJob.unschedule(trigger.key.name, trigger.key.group); + IntegrationTestJob.unschedule(trigger.key.name, trigger.key.group) assertEquals(0, quartzScheduler.getTriggersOfJob(jobDetail.key).size()) } diff --git a/test/integration/grails/plugins/quartz/JobManagerServiceTests.groovy b/test/integration/grails/plugins/quartz/JobManagerServiceTests.groovy index 9d312bcb..af2d5cbc 100644 --- a/test/integration/grails/plugins/quartz/JobManagerServiceTests.groovy +++ b/test/integration/grails/plugins/quartz/JobManagerServiceTests.groovy @@ -1,14 +1,21 @@ package grails.plugins.quartz +import static org.quartz.Trigger.TriggerState.NORMAL +import static org.quartz.Trigger.TriggerState.PAUSED + import org.junit.After import org.junit.Before import org.junit.Test -import org.quartz.* +import org.quartz.JobBuilder +import org.quartz.JobDetail +import org.quartz.JobKey +import org.quartz.Scheduler +import org.quartz.SimpleScheduleBuilder +import org.quartz.Trigger +import org.quartz.TriggerBuilder +import org.quartz.TriggerKey import org.quartz.impl.matchers.GroupMatcher -import static org.quartz.Trigger.TriggerState.NORMAL -import static org.quartz.Trigger.TriggerState.PAUSED - /** * Tests for the JobManagerService. * @@ -25,10 +32,10 @@ class JobManagerServiceTests extends GroovyTestCase { @Before void setUp(){ - JobDetail job1 = JobBuilder.newJob(SimpleTestJob.class).withIdentity(JOB_KEY_11).build() - JobDetail job2 = JobBuilder.newJob(SimpleTestJob.class).withIdentity(JOB_KEY_21).build() - JobDetail job3 = JobBuilder.newJob(SimpleTestJob.class).withIdentity(JOB_KEY_12).build() - JobDetail job4 = JobBuilder.newJob(SimpleTestJob.class) + JobDetail job1 = JobBuilder.newJob(SimpleTestJob).withIdentity(JOB_KEY_11).build() + JobDetail job2 = JobBuilder.newJob(SimpleTestJob).withIdentity(JOB_KEY_21).build() + JobDetail job3 = JobBuilder.newJob(SimpleTestJob).withIdentity(JOB_KEY_12).build() + JobDetail job4 = JobBuilder.newJob(SimpleTestJob) .withIdentity(JOB_KEY_22) .storeDurably() .build() @@ -75,7 +82,7 @@ class JobManagerServiceTests extends GroovyTestCase { } @Test - public void testGetAllJobs() { + void testGetAllJobs() { Map> jobs = jobManagerService.getAllJobs() assertNotNull(jobs) @@ -94,7 +101,7 @@ class JobManagerServiceTests extends GroovyTestCase { } @Test - public void testGetJobs() { + void testGetJobs() { assert jobManagerService.getJobs('group1')*.name.contains('job2') def names = jobManagerService.getJobs('group2')*.name @@ -103,12 +110,12 @@ class JobManagerServiceTests extends GroovyTestCase { } @Test - public void testGetRunningJobs() { + void testGetRunningJobs() { jobManagerService.getRunningJobs() } @Test - public void testPauseAndResumeJob() { + void testPauseAndResumeJob() { def triggerKeys = quartzScheduler.getTriggersOfJob(new JobKey('job2', 'group1'))*.key assertTriggersState(triggerKeys, NORMAL) @@ -125,7 +132,7 @@ class JobManagerServiceTests extends GroovyTestCase { } @Test - public void testPauseAndResumeTrigger() { + void testPauseAndResumeTrigger() { TriggerKey key = new TriggerKey('trigger2', 'tgroup1') assert quartzScheduler.getTriggerState(key) == NORMAL @@ -136,54 +143,54 @@ class JobManagerServiceTests extends GroovyTestCase { } @Test - public void testPauseAndResumeJobGroup() { + void testPauseAndResumeJobGroup() { def jobKeys = quartzScheduler.getJobKeys(GroupMatcher.groupEquals('group2')) def keys = [] jobKeys.each { - keys += quartzScheduler.getTriggersOfJob(it)*.key + keys.addAll quartzScheduler.getTriggersOfJob(it)*.key } assertTriggersState(keys, NORMAL) - jobManagerService.pauseJobGroup('group2'); + jobManagerService.pauseJobGroup('group2') assertTriggersState(keys, PAUSED) - jobManagerService.resumeJobGroup('group2'); + jobManagerService.resumeJobGroup('group2') assertTriggersState(keys, NORMAL) } @Test - public void testPauseAndResumeTriggerGroup() { + void testPauseAndResumeTriggerGroup() { def keys = quartzScheduler.getTriggerKeys(GroupMatcher.groupEquals('tgroup2')) assertTriggersState(keys, NORMAL) - jobManagerService.pauseTriggerGroup('tgroup2'); + jobManagerService.pauseTriggerGroup('tgroup2') assertTriggersState(keys, PAUSED) - jobManagerService.resumeTriggerGroup('tgroup2'); + jobManagerService.resumeTriggerGroup('tgroup2') assertTriggersState(keys, NORMAL) } @Test - public void testRemoveJob() { + void testRemoveJob() { assertTrue(jobManagerService.getJobs('group1')*.name.contains('job2')) jobManagerService.removeJob('group1', 'job2') assertFalse(jobManagerService.getJobs('group1')*.name.contains('job2')) } @Test - public void testUnscheduleJob() { + void testUnscheduleJob() { def key = new JobKey('job2', 'group1') assert quartzScheduler.getTriggersOfJob(key)?.size() > 0 jobManagerService.unscheduleJob('group1', 'job2') List triggers = quartzScheduler.getTriggersOfJob(key) - assert triggers == null || triggers.size() == 0 + assert !triggers } @Test - public void testInterruptJob(){ + void testInterruptJob(){ jobManagerService.interruptJob('group1', 'job2') } @Test - public void testPauseAndResumeAll(){ + void testPauseAndResumeAll(){ def keys = quartzScheduler.getTriggerKeys(GroupMatcher.groupEquals('tgroup2')) assertTriggersState(keys, NORMAL) diff --git a/test/unit/grails/plugins/quartz/CustomTriggerFactoryBeanTests.groovy b/test/unit/grails/plugins/quartz/CustomTriggerFactoryBeanTests.groovy index 85373805..04176a93 100644 --- a/test/unit/grails/plugins/quartz/CustomTriggerFactoryBeanTests.groovy +++ b/test/unit/grails/plugins/quartz/CustomTriggerFactoryBeanTests.groovy @@ -1,7 +1,8 @@ package grails.plugins.quartz import grails.plugins.quartz.config.TriggersConfigBuilder -import org.junit.* + +import org.junit.Test import org.quartz.CronTrigger import org.quartz.DailyTimeIntervalTrigger import org.quartz.DateBuilder @@ -21,7 +22,7 @@ class CustomTriggerFactoryBeanTests { private static final TimeOfDay END_TIME = new TimeOfDay(11, 30) @Test - public void testFactory() { + void testFactory() { def builder = new TriggersConfigBuilder('TestJob') def closure = { simple name: 'simple', group:'group', startDelay: 500, repeatInterval: 1000, repeatCount: 3 @@ -32,7 +33,7 @@ class CustomTriggerFactoryBeanTests { } builder.build(closure) - Map triggers = [:]; + Map triggers = [:] builder.triggers.values().each { CustomTriggerFactoryBean factory = new CustomTriggerFactoryBean() diff --git a/test/unit/grails/plugins/quartz/DefaultGrailsJobClassTests.groovy b/test/unit/grails/plugins/quartz/DefaultGrailsJobClassTests.groovy index f47766dc..3bd34e6e 100644 --- a/test/unit/grails/plugins/quartz/DefaultGrailsJobClassTests.groovy +++ b/test/unit/grails/plugins/quartz/DefaultGrailsJobClassTests.groovy @@ -14,8 +14,6 @@ * limitations under the License. */ - - package grails.plugins.quartz class DefaultGrailsJobClassTests extends GroovyTestCase { @@ -34,7 +32,7 @@ class DefaultGrailsJobClassTests extends GroovyTestCase { assertTrue "Job should require Hibernate session by default", grailsJobClass.sessionRequired assertTrue "Job should be concurrent by default", grailsJobClass.concurrent } - + void testJobClassExecute() { boolean wasExecuted = false def testClosure = { wasExecuted = true } diff --git a/test/unit/grails/plugins/quartz/JobArtefactHandlerTests.groovy b/test/unit/grails/plugins/quartz/JobArtefactHandlerTests.groovy index 7420e479..b6f6d9f5 100644 --- a/test/unit/grails/plugins/quartz/JobArtefactHandlerTests.groovy +++ b/test/unit/grails/plugins/quartz/JobArtefactHandlerTests.groovy @@ -14,8 +14,6 @@ * limitations under the License. */ - - package grails.plugins.quartz import org.codehaus.groovy.grails.commons.ArtefactHandler @@ -27,29 +25,26 @@ import org.codehaus.groovy.grails.commons.ArtefactHandler * @since 0.2 */ class JobArtefactHandlerTests extends GroovyTestCase { - protected GroovyClassLoader gcl = new GroovyClassLoader(); + private ArtefactHandler handler = new JobArtefactHandler() + protected GroovyClassLoader gcl = new GroovyClassLoader() void testJobClassWithExecuteMethod() { - Class c = gcl.parseClass("class TestJob { def execute() { }}\n"); - ArtefactHandler handler = new JobArtefactHandler(); - assertTrue "Class *Job which defines execute() method should be recognized as a Job class", handler.isArtefact(c); + Class c = gcl.parseClass("class TestJob { def execute() { }}\n") + assertTrue "Class *Job which defines execute() method should be recognized as a Job class", handler.isArtefact(c) } void testJobClassWithExecuteMethodWithParam() { - Class c = gcl.parseClass("class TestJob { def execute(param) { }}\n"); - ArtefactHandler handler = new JobArtefactHandler(); - assertTrue "Class *Job which defines execute(param) method should be recognized as a Job class", handler.isArtefact(c); + Class c = gcl.parseClass("class TestJob { def execute(param) { }}\n") + assertTrue "Class *Job which defines execute(param) method should be recognized as a Job class", handler.isArtefact(c) } void testJobClassWithWrongName() { - Class c = gcl.parseClass("class TestController { def execute() { }}\n"); - ArtefactHandler handler = new JobArtefactHandler(); - assertFalse "Class which name doesn't end with 'Job' shouldn't be recognized as a Job class", handler.isArtefact(c); + Class c = gcl.parseClass("class TestController { def execute() { }}\n") + assertFalse "Class which name doesn't end with 'Job' shouldn't be recognized as a Job class", handler.isArtefact(c) } void testJobClassWithoutExecuteMethod() { - Class c = gcl.parseClass("class TestJob { def execute1() { }}\n"); - ArtefactHandler handler = new JobArtefactHandler(); - assertFalse "Class which doesn't declare 'execute' method shouldn't be recognized as a Job class", handler.isArtefact(c); + Class c = gcl.parseClass("class TestJob { def execute1() { }}\n") + assertFalse "Class which doesn't declare 'execute' method shouldn't be recognized as a Job class", handler.isArtefact(c) } } diff --git a/test/unit/grails/plugins/quartz/JobDescriptorTests.groovy b/test/unit/grails/plugins/quartz/JobDescriptorTests.groovy index c65322f1..de4abfd4 100644 --- a/test/unit/grails/plugins/quartz/JobDescriptorTests.groovy +++ b/test/unit/grails/plugins/quartz/JobDescriptorTests.groovy @@ -3,7 +3,6 @@ package grails.plugins.quartz import org.junit.After import org.junit.Before import org.junit.Test -import org.quartz.Job import org.quartz.JobBuilder import org.quartz.JobDetail import org.quartz.JobKey @@ -25,7 +24,7 @@ class JobDescriptorTests { private Trigger trigger @Before - public void prepare(){ + void prepare(){ scheduler = StdSchedulerFactory.getDefaultScheduler() scheduler.start() @@ -41,12 +40,12 @@ class JobDescriptorTests { } @After - public void dispose(){ + void dispose(){ scheduler.shutdown() } @Test - public void testBuild(){ + void testBuild(){ JobDescriptor descriptor = JobDescriptor.build(job, scheduler) assert descriptor.name == 'job' assert descriptor.group == 'group' diff --git a/test/unit/grails/plugins/quartz/JobDetailFactoryBeanTests.groovy b/test/unit/grails/plugins/quartz/JobDetailFactoryBeanTests.groovy index d732430e..02acfb54 100644 --- a/test/unit/grails/plugins/quartz/JobDetailFactoryBeanTests.groovy +++ b/test/unit/grails/plugins/quartz/JobDetailFactoryBeanTests.groovy @@ -1,8 +1,11 @@ package grails.plugins.quartz -import junit.framework.Assert +import static junit.framework.Assert.assertEquals +import static junit.framework.Assert.assertFalse +import static junit.framework.Assert.assertNull +import static junit.framework.Assert.assertTrue + import org.codehaus.groovy.grails.commons.GrailsApplication -import org.junit.Before import org.junit.Test import org.quartz.JobDetail import org.quartz.JobKey @@ -17,12 +20,7 @@ class JobDetailFactoryBeanTests { private static final String JOB_NAME = 'jobName' private static final String JOB_GROUP = 'jobGroup' private static final String JOB_DESCRIPTION = 'The job description' - JobDetailFactoryBean factory - - @Before - void createFactory(){ - factory = new JobDetailFactoryBean() - } + JobDetailFactoryBean factory = new JobDetailFactoryBean() @Test void testFactory1(){ @@ -39,13 +37,13 @@ class JobDetailFactoryBeanTests { ) factory.afterPropertiesSet() JobDetail jobDetail = factory.object - Assert.assertEquals(new JobKey(JOB_NAME, JOB_GROUP), jobDetail.key) - Assert.assertEquals(JOB_NAME, jobDetail.getJobDataMap().get(JobDetailFactoryBean.JOB_NAME_PARAMETER)) - Assert.assertTrue(jobDetail.durable) - Assert.assertFalse(jobDetail.concurrentExectionDisallowed) - Assert.assertFalse(jobDetail.persistJobDataAfterExecution) - Assert.assertTrue(jobDetail.requestsRecovery()) - Assert.assertEquals(JOB_DESCRIPTION, jobDetail.description) + assertEquals(new JobKey(JOB_NAME, JOB_GROUP), jobDetail.key) + assertEquals(JOB_NAME, jobDetail.getJobDataMap().get(JobDetailFactoryBean.JOB_NAME_PARAMETER)) + assertTrue(jobDetail.durable) + assertFalse(jobDetail.concurrentExectionDisallowed) + assertFalse(jobDetail.persistJobDataAfterExecution) + assertTrue(jobDetail.requestsRecovery()) + assertEquals(JOB_DESCRIPTION, jobDetail.description) } @Test @@ -62,13 +60,13 @@ class JobDetailFactoryBeanTests { ) factory.afterPropertiesSet() JobDetail jobDetail = factory.object - Assert.assertEquals(new JobKey(JOB_NAME, JOB_GROUP), jobDetail.key) - Assert.assertEquals(JOB_NAME, jobDetail.getJobDataMap().get(JobDetailFactoryBean.JOB_NAME_PARAMETER)) - Assert.assertFalse(jobDetail.durable) - Assert.assertTrue(jobDetail.concurrentExectionDisallowed) - Assert.assertTrue(jobDetail.persistJobDataAfterExecution) - Assert.assertFalse(jobDetail.requestsRecovery()) - Assert.assertNull(jobDetail.description) + assertEquals(new JobKey(JOB_NAME, JOB_GROUP), jobDetail.key) + assertEquals(JOB_NAME, jobDetail.getJobDataMap().get(JobDetailFactoryBean.JOB_NAME_PARAMETER)) + assertFalse(jobDetail.durable) + assertTrue(jobDetail.concurrentExectionDisallowed) + assertTrue(jobDetail.persistJobDataAfterExecution) + assertFalse(jobDetail.requestsRecovery()) + assertNull(jobDetail.description) } } @@ -81,108 +79,25 @@ class GrailsJobClassMock implements GrailsJobClass { boolean requestsRecovery String description - @Override - void execute() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - Map getTriggers() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - boolean byName() { - return false //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - boolean byType() { - return false //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - boolean getAvailable() { - return false //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - boolean isAbstract() { - return false //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - GrailsApplication getGrailsApplication() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - Object getPropertyValue(String name) { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - boolean hasProperty(String name) { - return false //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - Object newInstance() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getShortName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getPropertyName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getLogicalPropertyName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getNaturalName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - String getPackageName() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - Class getClazz() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - BeanWrapper getReference() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - Object getReferenceInstance() { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - def T getPropertyValue(String name, Class type) { - return null //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - void setGrailsApplication(GrailsApplication grailsApplication) { - //To change body of implemented methods use File | Settings | File Templates. - } + void execute() {} + Map getTriggers() {} + boolean byName() { false } + boolean byType() { false } + boolean getAvailable() { false } + boolean isAbstract() { false } + GrailsApplication getGrailsApplication() {} + Object getPropertyValue(String name) {} + boolean hasProperty(String name) { false } + Object newInstance() {} + String getName() {} + String getShortName() {} + String getPropertyName() {} + String getLogicalPropertyName() {} + String getNaturalName() {} + String getPackageName() {} + Class getClazz() {} + BeanWrapper getReference() {} + Object getReferenceInstance() {} + def T getPropertyValue(String name, Class type) {} + void setGrailsApplication(GrailsApplication grailsApplication) {} } diff --git a/test/unit/grails/plugins/quartz/MockDoWithSpring.groovy b/test/unit/grails/plugins/quartz/MockDoWithSpring.groovy index fa5c757d..e22c362b 100644 --- a/test/unit/grails/plugins/quartz/MockDoWithSpring.groovy +++ b/test/unit/grails/plugins/quartz/MockDoWithSpring.groovy @@ -14,8 +14,6 @@ * limitations under the License. */ - - package grails.plugins.quartz class MockDoWithSpring { @@ -24,23 +22,23 @@ class MockDoWithSpring { def application = [jobClasses: null, config: new ConfigObject()] def manager - def ref( def whatever ) { + def ref(whatever) { null } - def quartzJobFactory( def whatever ) { + def quartzJobFactory(whatever) { null } - def exceptionPrinterListener( def whatever ) { + def exceptionPrinterListener(whatever) { null } - def sessionBinderListener( def something, def whatever ) { + def sessionBinderListener(something, whatever) { null } - void quartzScheduler( def whatever, Closure props ) { + void quartzScheduler(whatever, Closure props) { def data = [:] props.delegate = data props.resolveStrategy = Closure.DELEGATE_FIRST @@ -48,4 +46,4 @@ class MockDoWithSpring { println "xxxxxxxx=$data" this.quartzProperties = data.quartzProperties } -} \ No newline at end of file +} diff --git a/test/unit/grails/plugins/quartz/QuartzConfigTests.groovy b/test/unit/grails/plugins/quartz/QuartzConfigTests.groovy index d3aa2a9f..4b19eaeb 100644 --- a/test/unit/grails/plugins/quartz/QuartzConfigTests.groovy +++ b/test/unit/grails/plugins/quartz/QuartzConfigTests.groovy @@ -14,14 +14,9 @@ * limitations under the License. */ - - package grails.plugins.quartz import grails.test.GrailsUnitTestCase -import org.codehaus.groovy.grails.commons.ConfigurationHolder -import org.codehaus.groovy.grails.commons.DefaultGrailsApplication -import org.codehaus.groovy.grails.commons.GrailsApplication class QuartzConfigTests extends GrailsUnitTestCase { @@ -81,4 +76,4 @@ class QuartzConfigTests extends GrailsUnitTestCase { beans.call() assertTrue beans.delegate.quartzProperties.'org.quartz.threadPool.threadCount' == '5' } -} \ No newline at end of file +} diff --git a/test/unit/grails/plugins/quartz/TestQuartzJob.groovy b/test/unit/grails/plugins/quartz/TestQuartzJob.groovy index 1c11f563..63b56c16 100644 --- a/test/unit/grails/plugins/quartz/TestQuartzJob.groovy +++ b/test/unit/grails/plugins/quartz/TestQuartzJob.groovy @@ -5,12 +5,9 @@ import org.quartz.JobExecutionContext import org.quartz.JobExecutionException /** - * * @author Vitalii Samolovskikh aka Kefir */ class TestQuartzJob implements Job { @Override - void execute(JobExecutionContext context) throws JobExecutionException { - //To change body of implemented methods use File | Settings | File Templates. - } + void execute(JobExecutionContext context) throws JobExecutionException {} } diff --git a/test/unit/grails/plugins/quartz/TriggerDescriptorTests.groovy b/test/unit/grails/plugins/quartz/TriggerDescriptorTests.groovy index 5fc82891..6adc26b4 100644 --- a/test/unit/grails/plugins/quartz/TriggerDescriptorTests.groovy +++ b/test/unit/grails/plugins/quartz/TriggerDescriptorTests.groovy @@ -1,7 +1,16 @@ package grails.plugins.quartz -import org.junit.* -import org.quartz.* +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.quartz.JobBuilder +import org.quartz.JobDetail +import org.quartz.JobKey +import org.quartz.Scheduler +import org.quartz.SimpleScheduleBuilder +import org.quartz.Trigger +import org.quartz.TriggerBuilder +import org.quartz.TriggerKey import org.quartz.impl.StdSchedulerFactory /** @@ -15,7 +24,7 @@ class TriggerDescriptorTests { private Trigger trigger @Before - public void prepare(){ + void prepare(){ scheduler = StdSchedulerFactory.getDefaultScheduler() scheduler.start() @@ -31,12 +40,12 @@ class TriggerDescriptorTests { } @After - public void dispose(){ + void dispose(){ scheduler.shutdown() } @Test - public void testBuild(){ + void testBuild(){ TriggerDescriptor descriptor = TriggerDescriptor.build(JobDescriptor.build(job, scheduler), trigger, scheduler) assert descriptor.name == 'trigger' diff --git a/test/unit/grails/plugins/quartz/config/TriggersConfigBuilderTests.groovy b/test/unit/grails/plugins/quartz/config/TriggersConfigBuilderTests.groovy index 4322cf0c..f3b6dfc1 100644 --- a/test/unit/grails/plugins/quartz/config/TriggersConfigBuilderTests.groovy +++ b/test/unit/grails/plugins/quartz/config/TriggersConfigBuilderTests.groovy @@ -53,7 +53,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: Constants.DEFAULT_REPEAT_COUNT, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob1' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -64,7 +64,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: Constants.DEFAULT_REPEAT_COUNT, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob2' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -75,7 +75,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: Constants.DEFAULT_REPEAT_COUNT, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob3' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -86,7 +86,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: Constants.DEFAULT_REPEAT_COUNT, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob4' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -97,7 +97,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: 3, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'everySecond' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -108,7 +108,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { repeatCount: Constants.DEFAULT_REPEAT_COUNT, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob5' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -118,7 +118,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { cronExpression: Constants.DEFAULT_CRON_EXPRESSION, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'TestJob6' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -128,7 +128,7 @@ class TriggersConfigBuilderTests extends GroovyTestCase { startDelay: Constants.DEFAULT_START_DELAY, ), builder.triggers[triggerName].triggerAttributes ) - + triggerName = 'myTrigger' assert builder.triggers[triggerName]?.clazz == CustomTriggerFactoryBean assertPropertiesEquals(new Expando( @@ -153,9 +153,8 @@ class TriggersConfigBuilderTests extends GroovyTestCase { private static assertPropertiesEquals(expected, actual) { expected.properties.each { entry -> - assert actual[entry.key] == entry.value, "Unexpected value for property: ${entry.key}" + assert actual[entry.key] == entry.value, "Unexpected value for property: ${entry.key}" } assert actual.size() == expected.properties?.size(), 'Different number of properties' } - }