Skip to content

Commit

Permalink
Merge pull request #1200 from jhouserizer/main
Browse files Browse the repository at this point in the history
Fix class cast (to wrong class) issue #1125, add basic xml plugin integration test
  • Loading branch information
jhouserizer authored Oct 16, 2024
2 parents 492b3d5 + a54574d commit edd918c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 21 deletions.
20 changes: 1 addition & 19 deletions quartz/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,9 @@ dependencies {
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'

compileOnly 'jakarta.transaction:jakarta.transaction-api:2.0.1'
testImplementation 'jakarta.transaction:jakarta.transaction-api:2.0.1'
compileOnly 'jakarta.servlet:jakarta.servlet-api:6.1.0'

/*
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
*/


testImplementation "junit:junit:$junitVersion"
testImplementation 'asm:asm:3.3.1'
testImplementation 'org.mockito:mockito-core:1.9.5'
Expand Down
3 changes: 1 addition & 2 deletions quartz/src/main/java/org/quartz/plugins/xml/FileScanJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.quartz.plugins.xml;

import org.quartz.*;
import org.quartz.jobs.FileScanListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -99,7 +98,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap");
}

org.quartz.jobs.FileScanListener listener = (FileScanListener)schedCtx.get(listenerName);
FileScanListener listener = (FileScanListener)schedCtx.get(listenerName);

if(listener == null) {
throw new JobExecutionException("FileScanListener named '" +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
* Copyright Super iPaaS Integration LLC, an IBM Company 2024
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.quartz.xml;

import junit.framework.TestCase;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.simpl.CascadingClassLoadHelper;
import org.quartz.spi.ClassLoadHelper;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class XMLSchedulingDataProcessorPluginTest extends TestCase implements TriggerListener {

CountDownLatch latch = new CountDownLatch(1);
boolean jobRan = false;

public void testPluginSchedulesFromSimpleXMLFile() throws Exception {
Scheduler scheduler = null;
try {
StdSchedulerFactory factory = new StdSchedulerFactory("org/quartz/xml/quartz-xml-plugin-test.properties");
scheduler = factory.getScheduler();

scheduler.getListenerManager().addTriggerListener(this);
scheduler.start();
latch.await(1, TimeUnit.MINUTES);

assert(jobRan);
} finally {
if (scheduler != null)
scheduler.shutdown();
}
}

@Override
public void triggerFired(Trigger trigger, JobExecutionContext context) {
jobRan = true;
latch.countDown();
}

@Override
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) {
return false;
}

@Override
public void triggerMisfired(Trigger trigger) {

}

@Override
public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 10
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

org.quartz.jobStore.misfireThreshold: 60000

org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore

org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = org/quartz/xml/simple-job-trigger-no-repeat.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
#org.quartz.plugin.jobInitializer.scanInterval = 5

0 comments on commit edd918c

Please sign in to comment.