Skip to content

Commit

Permalink
Merge branch 'quartz-2.2.x_issue93-cleanup' into quartz-2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
zemian committed Jan 16, 2017
2 parents 76d4923 + 47a15cb commit d99b9fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 56 deletions.
40 changes: 32 additions & 8 deletions quartz-core/src/test/java/org/quartz/core/RecoverJobsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@

import org.junit.Assert;
import org.junit.Test;
import org.quartz.JobBuilder;
import org.quartz.JobExecutionContext;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.TriggerBuilder;
import org.quartz.*;
import org.quartz.impl.DirectSchedulerFactory;
import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities;
import org.quartz.impl.jdbcjobstore.JobStoreTX;

import org.quartz.listeners.JobListenerSupport;
import org.quartz.simpl.SimpleThreadPool;
import org.quartz.utils.DBConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
Expand Down Expand Up @@ -81,8 +79,9 @@ public void testRecoveringRepeatJobWhichIsFiredAndMisfiredAtTheSameTime() throws
// emulate fail over situation
scheduler.shutdown(false);

Statement st = DBConnectionManager.getInstance().getConnection(dsName).createStatement();
Connection conn = DBConnectionManager.getInstance().getConnection(dsName);
try {
Statement st = conn.createStatement();
ResultSet rs1 = st.executeQuery("SELECT TRIGGER_STATE from QRTZ_TRIGGERS");
rs1.next();
// check that trigger is blocked after fail over situation
Expand All @@ -92,8 +91,9 @@ public void testRecoveringRepeatJobWhichIsFiredAndMisfiredAtTheSameTime() throws
rs2.next();
// check that fired trigger remains after fail over situation
Assert.assertEquals(1, rs2.getLong(1));
} finally {
st.close();
} finally {
conn.close();
}

// stop job executing to not as part of emulation fail over situation
Expand Down Expand Up @@ -130,4 +130,28 @@ public void jobToBeExecuted(JobExecutionContext context) {
}
}

/**
* @author https://github.com/eugene-goroschenya
*/
@DisallowConcurrentExecution
public static class RecoverJobsTestJob implements Job {
private static Logger _log = LoggerFactory.getLogger(RecoverJobsTestJob.class);
static boolean runForever = true;

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
long now = System.currentTimeMillis();
int tic = 0;
_log.info("Started - " + now);
try {
while (runForever) {
Thread.sleep(1000);
_log.info("Tic " + (++tic) + "- " + now);
}
_log.info("Stopped - " + now);
} catch (InterruptedException e) {
_log.info("Interrupted - " + now);
}
}
}
}
48 changes: 0 additions & 48 deletions quartz-core/src/test/java/org/quartz/core/RecoverJobsTestJob.java

This file was deleted.

0 comments on commit d99b9fe

Please sign in to comment.