This repository has been archived by the owner on May 4, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #17 from chupakabr/issue-16
Fix for issue #16
- Loading branch information
Showing
5 changed files
with
95 additions
and
14 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
11 changes: 11 additions & 0 deletions
11
src/java/grails/plugin/quartz2/GrailsArtefactNonConcurrentJob.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
package grails.plugin.quartz2; | |||
|
|||
import org.quartz.DisallowConcurrentExecution; | |||
|
|||
@DisallowConcurrentExecution | |||
class GrailsArtefactNonConcurrentJob extends GrailsArtefactJob { | |||
|
|||
public GrailsArtefactNonConcurrentJob(Object job) { | |||
super(job); | |||
} | |||
} |
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
59 changes: 59 additions & 0 deletions
59
test/unit/grails/plugin/quartz2/GrailsArtefactJobDetailFactoryBeanTests.groovy
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
|
|||
|
|||
package grails.plugin.quartz2 | |||
|
|||
import grails.test.GrailsMock | |||
import grails.test.mixin.* | |||
import grails.test.mixin.support.* | |||
|
|||
import org.junit.* | |||
import org.quartz.JobKey | |||
|
|||
/** | |||
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions | |||
*/ | |||
@TestMixin(GrailsUnitTestMixin) | |||
class GrailsArtefactJobDetailFactoryBeanTests { | |||
|
|||
void setUp() { | |||
// Setup logic here | |||
} | |||
|
|||
void tearDown() { | |||
// Tear down logic here | |||
} | |||
|
|||
void testConcurrentJobCreation() { | |||
def jobClassMock = new GrailsMock(GrailsJobClass, true) | |||
jobClassMock.demand.getJobKey(1) { return new JobKey("111") } | |||
jobClassMock.demand.isConcurrent(2) { return true } | |||
jobClassMock.demand.getFullName(1) { return "myfullname" } | |||
jobClassMock.demand.isSessionRequired(1) { return true } | |||
jobClassMock.demand.isGormSession(1) { return true } | |||
jobClassMock.demand.getDurability(1) { return true } | |||
jobClassMock.demand.getRequestsRecovery(1) { return true } | |||
|
|||
def factory = new GrailsArtefactJobDetailFactoryBean() | |||
factory.grailsJobClass = jobClassMock.createMock() | |||
factory.afterPropertiesSet() | |||
|
|||
assert factory.getObject().getJobClass() == GrailsArtefactJob.class | |||
} | |||
|
|||
void testNonConcurrentJobCreation() { | |||
def jobClassMock = new GrailsMock(GrailsJobClass, true) | |||
jobClassMock.demand.getJobKey(1) { return new JobKey("111") } | |||
jobClassMock.demand.isConcurrent(2) { return false } | |||
jobClassMock.demand.getFullName(1) { return "myfullname" } | |||
jobClassMock.demand.isSessionRequired(1) { return true } | |||
jobClassMock.demand.isGormSession(1) { return true } | |||
jobClassMock.demand.getDurability(1) { return true } | |||
jobClassMock.demand.getRequestsRecovery(1) { return true } | |||
|
|||
def factory = new GrailsArtefactJobDetailFactoryBean() | |||
factory.grailsJobClass = jobClassMock.createMock() | |||
factory.afterPropertiesSet() | |||
|
|||
assert factory.getObject().getJobClass() == GrailsArtefactNonConcurrentJob.class | |||
} | |||
} |