From d519029b63ef6261a15cea4fed148a738ebf44d5 Mon Sep 17 00:00:00 2001 From: "arnaud.mergey@semarchy.com" Date: Mon, 4 Nov 2024 23:33:42 +0100 Subject: [PATCH] unit test refactoring (ease support of test container) Signed-off-by: arnaud.mergey@semarchy.com --- gradle.properties | 3 +- quartz/build.gradle | 1 - .../org/quartz/FlakyJdbcSchedulerTest.java | 7 +- .../java/org/quartz/JdbcSchedulerTest.java | 9 +- .../test/java/org/quartz/core/QTZ385Test.java | 5 +- .../java/org/quartz/core/RecoverJobsTest.java | 6 +- .../jdbcjobstore/DeleteNonExistsJobTest.java | 18 +- .../impl/jdbcjobstore/JdbcJobStoreTest.java | 36 ++-- .../JdbcQuartzMSSQLUtilities.java | 82 ------- .../jdbcjobstore/JdbcQuartzTestUtilities.java | 201 ++++++++++++------ .../impl/jdbcjobstore/MSSQLJdbcStoreTest.java | 27 +++ .../UpdateLockRowSemaphoreTest.java | 1 - ...ssNotFoundExceptionErrorsTriggersTest.java | 2 +- .../tests/JobDataMapStorageTest.java | 2 +- ...QTZ179_TriggerLostAfterDbRestart_Test.java | 2 +- ...283_IgnoreMisfirePolicyJdbcStore_Test.java | 2 +- .../QuartzDatabasePauseAndResumeTest.java | 2 +- .../QuartzDatabaseSimplePropertiesTest.java | 2 +- ...t.java => QuartzDerbyCronTriggerTest.java} | 2 +- ...pport.java => QuartzDerbyTestSupport.java} | 4 +- .../tests/QuartzMSSQLTestSupport.java | 27 +-- .../tests/StdRowLockSemaphoreTest.java | 2 +- ...SystemPropertyInstanceIdGeneratorTest.java | 3 +- .../C3p0PoolingConnectionProviderTest.java | 4 +- ...HikariCpPoolingConnectionProviderTest.java | 4 +- .../xml/XMLSchedulingDataProcessorTest.java | 36 ++-- .../container-license-acceptance.txt | 1 + 27 files changed, 258 insertions(+), 233 deletions(-) delete mode 100644 quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzMSSQLUtilities.java create mode 100644 quartz/src/test/java/org/quartz/impl/jdbcjobstore/MSSQLJdbcStoreTest.java rename quartz/src/test/java/org/quartz/integrations/tests/{QuartzDatabaseCronTriggerTest.java => QuartzDerbyCronTriggerTest.java} (96%) rename quartz/src/test/java/org/quartz/integrations/tests/{QuartzDatabaseTestSupport.java => QuartzDerbyTestSupport.java} (97%) create mode 100644 quartz/src/test/resources/container-license-acceptance.txt diff --git a/gradle.properties b/gradle.properties index 42b88bf36..77c165d86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,7 @@ commonjVersion = 1.0 junitVersion = 4.13.2 junitPlatformVersion = 5.11.3 -#derbyVersion = 10.15.2.0 -derbyVersion = 10.8.2.2 +derbyVersion = 10.15.2.0 # For nexus-publish plugin sonatypeUsername = OVERRIDE_ME diff --git a/quartz/build.gradle b/quartz/build.gradle index 3d0b67c64..c43b0fbfd 100644 --- a/quartz/build.gradle +++ b/quartz/build.gradle @@ -41,7 +41,6 @@ dependencies { testImplementation(platform("org.junit:junit-bom:5.11.3")) testImplementation 'org.junit.jupiter:junit-jupiter-engine' testImplementation 'org.junit.jupiter:junit-jupiter-params' - testImplementation 'org.junit.jupiter:junit-jupiter-params' testImplementation 'org.mockito:mockito-core:5.14.2' testImplementation 'org.testcontainers:mssqlserver:1.20.3' testImplementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11' diff --git a/quartz/src/test/java/org/quartz/FlakyJdbcSchedulerTest.java b/quartz/src/test/java/org/quartz/FlakyJdbcSchedulerTest.java index 27a9d5fdf..68bb5d2c4 100644 --- a/quartz/src/test/java/org/quartz/FlakyJdbcSchedulerTest.java +++ b/quartz/src/test/java/org/quartz/FlakyJdbcSchedulerTest.java @@ -7,6 +7,7 @@ import org.quartz.impl.SchedulerRepository; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; import org.quartz.impl.jdbcjobstore.JobStoreTX; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.simpl.SimpleThreadPool; import org.quartz.utils.ConnectionProvider; import org.quartz.utils.DBConnectionManager; @@ -156,7 +157,7 @@ private class FlakyConnectionProvider implements ConnectionProvider { private FlakyConnectionProvider(String name) throws SQLException { this.delegateName = "delegate_" + name; this.safeThread = Thread.currentThread(); - JdbcQuartzTestUtilities.createDatabase(delegateName); + JdbcQuartzTestUtilities.createDatabase(delegateName, DatabaseType.DERBY); } @Override @@ -176,8 +177,8 @@ public Connection getConnection() throws SQLException { @Override public void shutdown() throws SQLException { DBConnectionManager.getInstance().shutdown(delegateName); - JdbcQuartzTestUtilities.destroyDatabase(delegateName); - JdbcQuartzTestUtilities.shutdownDatabase(); + JdbcQuartzTestUtilities.destroyDatabase(delegateName, DatabaseType.DERBY); + JdbcQuartzTestUtilities.shutdownDatabase(delegateName, DatabaseType.DERBY); } @Override diff --git a/quartz/src/test/java/org/quartz/JdbcSchedulerTest.java b/quartz/src/test/java/org/quartz/JdbcSchedulerTest.java index 79581648b..75f2a6588 100644 --- a/quartz/src/test/java/org/quartz/JdbcSchedulerTest.java +++ b/quartz/src/test/java/org/quartz/JdbcSchedulerTest.java @@ -22,19 +22,24 @@ import org.quartz.impl.SchedulerRepository; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; import org.quartz.impl.jdbcjobstore.JobStoreTX; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.simpl.SimpleThreadPool; public class JdbcSchedulerTest extends AbstractSchedulerTest { + + protected DatabaseType getDatabaseType() { + return DatabaseType.DERBY; + } @Override protected Scheduler createScheduler(String name, int threadPoolSize) throws SchedulerException { try { - JdbcQuartzTestUtilities.createDatabase(name + "Database"); + JdbcQuartzTestUtilities.createDatabase(name + getDatabaseType().name(), getDatabaseType()); } catch (SQLException e) { throw new AssertionError(e); } JobStoreTX jobStore = new JobStoreTX(); - jobStore.setDataSource(name + "Database"); + jobStore.setDataSource(name + getDatabaseType().name()); jobStore.setTablePrefix("QRTZ_"); jobStore.setInstanceId("AUTO"); DirectSchedulerFactory.getInstance().createScheduler(name + "Scheduler", "AUTO", new SimpleThreadPool(threadPoolSize, Thread.NORM_PRIORITY), jobStore); diff --git a/quartz/src/test/java/org/quartz/core/QTZ385Test.java b/quartz/src/test/java/org/quartz/core/QTZ385Test.java index 4f752a2fa..7e6199095 100644 --- a/quartz/src/test/java/org/quartz/core/QTZ385Test.java +++ b/quartz/src/test/java/org/quartz/core/QTZ385Test.java @@ -37,6 +37,7 @@ import org.quartz.impl.DirectSchedulerFactory; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; import org.quartz.impl.jdbcjobstore.JobStoreTX; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.integrations.tests.HelloJob; import org.quartz.listeners.JobListenerSupport; import org.quartz.simpl.SimpleThreadPool; @@ -61,7 +62,7 @@ class QTZ385Test { @Test void testShutdownOrdering() throws SchedulerException, SQLException, InterruptedException, BrokenBarrierException { - JdbcQuartzTestUtilities.createDatabase("testShutdownOrdering"); + JdbcQuartzTestUtilities.createDatabase("testShutdownOrdering", DatabaseType.DERBY); try { final CyclicBarrier barrier = new CyclicBarrier(2); final JobStoreTX realJobStore = new JobStoreTX(); @@ -131,7 +132,7 @@ public void jobToBeExecuted(JobExecutionContext context) { recovery.shutdown(true); } } finally { - JdbcQuartzTestUtilities.destroyDatabase("testShutdownOrdering"); + JdbcQuartzTestUtilities.destroyDatabase("testShutdownOrdering", DatabaseType.DERBY); } } diff --git a/quartz/src/test/java/org/quartz/core/RecoverJobsTest.java b/quartz/src/test/java/org/quartz/core/RecoverJobsTest.java index 6e1063ac6..64bad0734 100644 --- a/quartz/src/test/java/org/quartz/core/RecoverJobsTest.java +++ b/quartz/src/test/java/org/quartz/core/RecoverJobsTest.java @@ -21,7 +21,7 @@ import org.quartz.impl.DirectSchedulerFactory; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; import org.quartz.impl.jdbcjobstore.JobStoreTX; - +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.*; import org.quartz.listeners.JobListenerSupport; import org.quartz.simpl.SimpleThreadPool; @@ -46,7 +46,7 @@ public class RecoverJobsTest { @Test void testRecoveringRepeatJobWhichIsFiredAndMisfiredAtTheSameTime() throws SchedulerException, SQLException, InterruptedException { String dsName = "recoverJobsTest"; - JdbcQuartzTestUtilities.createDatabase(dsName); + JdbcQuartzTestUtilities.createDatabase(dsName, DatabaseType.DERBY); try { final JobStoreTX jobStore = new JobStoreTX(); jobStore.setDataSource(dsName); @@ -130,7 +130,7 @@ public void jobToBeExecuted(JobExecutionContext context) { assertTrue(isJobRecovered.get()); } finally { - JdbcQuartzTestUtilities.destroyDatabase(dsName); + JdbcQuartzTestUtilities.destroyDatabase(dsName, DatabaseType.DERBY); } } diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/DeleteNonExistsJobTest.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/DeleteNonExistsJobTest.java index 8bda7d676..eed46affd 100644 --- a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/DeleteNonExistsJobTest.java +++ b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/DeleteNonExistsJobTest.java @@ -16,7 +16,6 @@ */ package org.quartz.impl.jdbcjobstore; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -24,6 +23,7 @@ import org.quartz.*; import org.quartz.impl.DirectSchedulerFactory; import org.quartz.impl.SchedulerRepository; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.simpl.SimpleThreadPool; import org.quartz.utils.DBConnectionManager; import org.slf4j.Logger; @@ -45,7 +45,7 @@ public class DeleteNonExistsJobTest { @BeforeAll public static void beforeClass() throws Exception { - JdbcQuartzTestUtilities.createDatabase(DB_NAME); + JdbcQuartzTestUtilities.createDatabase(DB_NAME, DatabaseType.DERBY); } @BeforeEach @@ -55,9 +55,10 @@ public void beforeTest() throws Exception { jobStore.setDataSource(DB_NAME); jobStore.setTablePrefix("QRTZ_"); jobStore.setInstanceId("AUTO"); - DirectSchedulerFactory.getInstance().createScheduler(SCHEDULER_NAME, "AUTO", new SimpleThreadPool(4, Thread.NORM_PRIORITY), jobStore); + DirectSchedulerFactory.getInstance().createScheduler(SCHEDULER_NAME, "AUTO", + new SimpleThreadPool(4, Thread.NORM_PRIORITY), jobStore); scheduler = SchedulerRepository.getInstance().lookup(SCHEDULER_NAME); - //scheduler.start(); // Do not start scheduler to produce the defect case. + // scheduler.start(); // Do not start scheduler to produce the defect case. } private void resetDatabaseData() throws Exception { @@ -97,8 +98,7 @@ void deleteJobDetailOnly() throws Exception { void deleteJobDetailWithTrigger() throws Exception { JobDetail jobDetail = JobBuilder.newJob(TestJob.class).withIdentity("testjob2").storeDurably().build(); Trigger trigger = TriggerBuilder.newTrigger().withIdentity("testjob2") - .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")) - .build(); + .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")).build(); scheduler.scheduleJob(jobDetail, trigger); modifyStoredJobClassName(); @@ -109,8 +109,7 @@ void deleteJobDetailWithTrigger() throws Exception { void deleteTrigger() throws Exception { JobDetail jobDetail = JobBuilder.newJob(TestJob.class).withIdentity("testjob3").storeDurably().build(); Trigger trigger = TriggerBuilder.newTrigger().withIdentity("testjob3") - .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")) - .build(); + .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")).build(); scheduler.scheduleJob(jobDetail, trigger); modifyStoredJobClassName(); @@ -121,8 +120,7 @@ void deleteTrigger() throws Exception { void replaceJobDetail() throws Exception { JobDetail jobDetail = JobBuilder.newJob(TestJob.class).withIdentity("testjob3").storeDurably().build(); Trigger trigger = TriggerBuilder.newTrigger().withIdentity("testjob3") - .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")) - .build(); + .withSchedule(CronScheduleBuilder.cronSchedule("* * * * * ?")).build(); scheduler.scheduleJob(jobDetail, trigger); modifyStoredJobClassName(); diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcJobStoreTest.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcJobStoreTest.java index 1c6ec8392..421d9fe5c 100644 --- a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcJobStoreTest.java +++ b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcJobStoreTest.java @@ -20,42 +20,50 @@ import java.util.HashMap; import org.quartz.AbstractJobStoreTest; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.spi.JobStore; public class JdbcJobStoreTest extends AbstractJobStoreTest { - private HashMap stores = new HashMap(); - - void testNothing() { - // nothing + private HashMap stores = new HashMap(); + + protected DatabaseType getDatabaseType() { + return DatabaseType.DERBY; + } + + private String name(String prefix) { + return prefix + "_" + getDatabaseType().name(); } @Override - protected JobStore createJobStore(String name) { + protected JobStore createJobStore(String prefix) { + String name = name(prefix); try { - JdbcQuartzTestUtilities.createDatabase(name); + JdbcQuartzTestUtilities.createDatabase(name, getDatabaseType()); JobStoreTX jdbcJobStore = new JobStoreTX(); jdbcJobStore.setDataSource(name); jdbcJobStore.setTablePrefix("QRTZ_"); - jdbcJobStore.setInstanceId("SINGLE_NODE_TEST"); + jdbcJobStore.setInstanceId("SINGLE_NODE_TEST_" + getDatabaseType().name()); jdbcJobStore.setInstanceName(name); jdbcJobStore.setUseDBLocks(true); + jdbcJobStore.setDriverDelegateClass(getDatabaseType().getDelegateClassName()); stores.put(name, jdbcJobStore); - + return jdbcJobStore; - } catch (SQLException e) { + } catch (Exception e) { throw new AssertionError(e); } } @Override - protected void destroyJobStore(String name) { + protected void destroyJobStore(String prefix) { + String name = name(prefix); try { - JobStoreSupport jdbcJobStore = stores.remove(name); - jdbcJobStore.shutdown(); - - JdbcQuartzTestUtilities.destroyDatabase(name); + JobStoreSupport jdbcJobStore = stores.remove(name); + jdbcJobStore.shutdown(); + + JdbcQuartzTestUtilities.destroyDatabase(name, getDatabaseType()); } catch (SQLException e) { throw new AssertionError(e); } diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzMSSQLUtilities.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzMSSQLUtilities.java deleted file mode 100644 index 23a696d99..000000000 --- a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzMSSQLUtilities.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.impl.jdbcjobstore; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import org.testcontainers.containers.MSSQLServerContainer; - -/** - * A utility class to create a database for Quartz MSSQL test. - * - * @author Arnaud Mergey - */ - -public final class JdbcQuartzMSSQLUtilities { - private static final List DATABASE_SETUP_STATEMENTS; - static { - List setup = new ArrayList(); - String setupScript; - try { - InputStream setupStream = MSSQLDelegate.class.getClassLoader() - .getResourceAsStream("org/quartz/impl/jdbcjobstore/tables_sqlServer.sql"); - try { - BufferedReader r = new BufferedReader(new InputStreamReader(setupStream, "US-ASCII")); - StringBuilder sb = new StringBuilder(); - while (true) { - String line = r.readLine(); - if (line == null) { - break; - } else if (!line.startsWith("--")) { - sb.append(line.replace("GO", ";").replace("[enter_db_name_here]", "[master]")).append("\n"); - } - } - setupScript = sb.toString(); - } finally { - setupStream.close(); - } - } catch (IOException e) { - throw new AssertionError(e); - } - for (String command : setupScript.split(";")) { - if (!command.matches("\\s*")) { - setup.add(command); - } - } - DATABASE_SETUP_STATEMENTS = setup; - } - - public static void createDatabase(MSSQLServerContainer container) throws SQLException { - Connection conn = container.createConnection(""); - try { - Statement statement = conn.createStatement(); - for (String command : DATABASE_SETUP_STATEMENTS) { - statement.addBatch(command); - } - statement.executeBatch(); - } finally { - conn.close(); - } - } -} \ No newline at end of file diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzTestUtilities.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzTestUtilities.java index 88c2d432d..c8ac123a3 100644 --- a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzTestUtilities.java +++ b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/JdbcQuartzTestUtilities.java @@ -25,104 +25,138 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import java.util.EnumMap; import java.util.List; +import java.util.Map; import org.quartz.utils.ConnectionProvider; import org.quartz.utils.DBConnectionManager; public final class JdbcQuartzTestUtilities { - private static final String DATABASE_DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; - private static final String DATABASE_CONNECTION_PREFIX = "jdbc:derby:memory:"; - private static final List DATABASE_SETUP_STATEMENTS; - static { - try { - Class.forName(DATABASE_DRIVER_CLASS).newInstance(); - } catch (ClassNotFoundException e) { - throw new AssertionError(e); - } catch (InstantiationException e) { - throw new AssertionError(e); - } catch (IllegalAccessException e) { - throw new AssertionError(e); + public enum DatabaseType { + DERBY("org/quartz/impl/jdbcjobstore/tables_derby.sql", StdJDBCDelegate.class.getName()), + MSSQL("org/quartz/impl/jdbcjobstore/tables_sqlServer.sql", MSSQLDelegate.class.getName()); + + private final String scriptResource; + private final String delegateClassName; + + DatabaseType(String scriptResource, String delegateClassName) { + this.scriptResource = scriptResource; + this.delegateClassName = delegateClassName; + } + + public String getDelegateClassName() { + return this.delegateClassName; } + } + + private static final Map> DATABASE_SETUP_SCRIPTS = new EnumMap<>(DatabaseType.class); - List setup = new ArrayList(); - String setupScript; - try { - InputStream setupStream = DerbyEmbeddedConnectionProvider.class - .getClassLoader().getResourceAsStream("org/quartz/impl/jdbcjobstore/tables_derby.sql"); + private static List getDatabaseSetupScript(DatabaseType type) { + return DATABASE_SETUP_SCRIPTS.computeIfAbsent(type, t -> { + List commandList = new ArrayList<>(); + String setupScript; try { - BufferedReader r = new BufferedReader(new InputStreamReader(setupStream, "US-ASCII")); - StringBuilder sb = new StringBuilder(); - while (true) { - String line = r.readLine(); - if (line == null) { - break; - } else if (!line.startsWith("--")) { - sb.append(line).append("\n"); + InputStream setupStream = JdbcQuartzTestUtilities.class.getClassLoader() + .getResourceAsStream(t.scriptResource); + try { + BufferedReader r = new BufferedReader(new InputStreamReader(setupStream, "US-ASCII")); + StringBuilder sb = new StringBuilder(); + while (true) { + String line = r.readLine(); + if (line == null) { + break; + } else if (!line.startsWith("--")) { + // update script for some database like sql server to be executable with jdbc + sb.append(line).append("\n"); + } } + setupScript = sb.toString(); + } finally { + setupStream.close(); } - setupScript = sb.toString(); - } finally { - setupStream.close(); + } catch (IOException e) { + throw new AssertionError(e); } - } catch (IOException e) { - throw new AssertionError(e); - } - for (String command : setupScript.split(";")) { - if (!command.matches("\\s*")) { - setup.add(command); + for (String command : setupScript.split(";")) { + if (!command.matches("\\s*")) { + commandList.add(command); + } } - } - DATABASE_SETUP_STATEMENTS = setup; + return commandList; + + }); } - public static void createDatabase(String name) throws SQLException { - DBConnectionManager.getInstance().addConnectionProvider(name, - new DerbyEmbeddedConnectionProvider(name)); + public static void createDatabase(String name, DatabaseType databaseType) throws SQLException { + switch (databaseType) { + case DERBY: + DBConnectionManager.getInstance().addConnectionProvider(name, new DerbyEmbeddedConnectionProvider(name)); + break; + case MSSQL: + DBConnectionManager.getInstance().addConnectionProvider(name, + new TestContainerEmbeddedConnectionProvider("jdbc:tc:sqlserver:latest:///" + name)); + break; + default: + throw new AssertionError("Unsupported database type: " + databaseType); + } } - public static void destroyDatabase(String name) throws SQLException { - try { - DriverManager.getConnection( - DATABASE_CONNECTION_PREFIX + name + ";drop=true").close(); - } catch (SQLException e) { - if (!("Database 'memory:" + name + "' dropped.").equals(e.getMessage())) { - throw e; + public static void destroyDatabase(String name, DatabaseType databaseType) throws SQLException { + switch (databaseType) { + case DERBY: + try { + DriverManager.getConnection("jdbc:derby:memory:" + name + ";drop=true").close(); + } catch (SQLException e) { + if (!("Database 'memory:" + name + "' dropped.").equals(e.getMessage())) { + throw e; + } } + break; + case MSSQL: + shutdownDatabase(name, databaseType); + break; + default: + throw new AssertionError("Unsupported database type: " + databaseType); } } - public static void shutdownDatabase() throws SQLException { - try { - DriverManager.getConnection("jdbc:derby:;shutdown=true").close(); - } catch (SQLException e) { - if (!("Derby system shutdown.").equals(e.getMessage())) { - throw e; + public static void shutdownDatabase(String name, DatabaseType databaseType) throws SQLException { + switch (databaseType) { + case DERBY: + try { + DriverManager.getConnection("jdbc:derby:;shutdown=true").close(); + } catch (SQLException e) { + if (!("Derby system shutdown.").equals(e.getMessage())) { + throw e; + } } - } - try { - Class.forName(DATABASE_DRIVER_CLASS).newInstance(); - } catch (ClassNotFoundException e) { - throw new AssertionError(e); - } catch (InstantiationException e) { - throw new AssertionError(e); - } catch (IllegalAccessException e) { - throw new AssertionError(e); + break; + case MSSQL: + DBConnectionManager.getInstance().shutdown(name); + break; + default: + throw new AssertionError("Unsupported database type: " + databaseType); } } - - static class DerbyEmbeddedConnectionProvider implements ConnectionProvider { + static class DerbyEmbeddedConnectionProvider implements ConnectionProvider { + private final String databaseName; DerbyEmbeddedConnectionProvider(String name) throws SQLException { + try { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new AssertionError(e); + } this.databaseName = name; - Connection conn = DriverManager.getConnection(DATABASE_CONNECTION_PREFIX + databaseName + ";create=true"); + Connection conn = DriverManager.getConnection("jdbc:derby:memory:" + databaseName + ";create=true"); try { Statement statement = conn.createStatement(); - for (String command : DATABASE_SETUP_STATEMENTS) { + for (String command : getDatabaseSetupScript(DatabaseType.DERBY)) { statement.addBatch(command); } statement.executeBatch(); @@ -132,13 +166,46 @@ static class DerbyEmbeddedConnectionProvider implements ConnectionProvider { } public Connection getConnection() throws SQLException { - return DriverManager.getConnection(DATABASE_CONNECTION_PREFIX + databaseName); + return DriverManager.getConnection("jdbc:derby:memory:" + databaseName); } public void shutdown() throws SQLException { // nothing to do } - + + public void initialize() throws SQLException { + // nothing to do + } + } + + static class TestContainerEmbeddedConnectionProvider implements ConnectionProvider { + + private final String jdbcUrl; + //we keep a connection open to keep the testcontainer container alive + private final Connection conn; + + TestContainerEmbeddedConnectionProvider(String jdbcUrl) throws SQLException { + this.jdbcUrl = jdbcUrl; + this.conn = DriverManager.getConnection(this.jdbcUrl); + + Statement statement = conn.createStatement(); + for (String command : getDatabaseSetupScript(DatabaseType.MSSQL)) { + statement.addBatch(command.replace("GO", ";").replace("[enter_db_name_here]", "[master]")); + } + statement.executeBatch(); + } + + public Connection getConnection() throws SQLException { + return DriverManager.getConnection(this.jdbcUrl); + } + + public void shutdown() throws SQLException { + // last connection closed shutdown testcontainer container + if (!conn.isClosed()) { + conn.close(); + } + } + public void initialize() throws SQLException { // nothing to do } diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/MSSQLJdbcStoreTest.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/MSSQLJdbcStoreTest.java new file mode 100644 index 000000000..fce7b8e63 --- /dev/null +++ b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/MSSQLJdbcStoreTest.java @@ -0,0 +1,27 @@ +/* + * 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.impl.jdbcjobstore; + +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; + +public class MSSQLJdbcStoreTest extends JdbcJobStoreTest { + @Override + protected DatabaseType getDatabaseType() { + return DatabaseType.MSSQL; + } + +} diff --git a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/UpdateLockRowSemaphoreTest.java b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/UpdateLockRowSemaphoreTest.java index b82a3d756..b8fa112a6 100644 --- a/quartz/src/test/java/org/quartz/impl/jdbcjobstore/UpdateLockRowSemaphoreTest.java +++ b/quartz/src/test/java/org/quartz/impl/jdbcjobstore/UpdateLockRowSemaphoreTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.startsWith; -; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/quartz/src/test/java/org/quartz/integrations/tests/JobClassNotFoundExceptionErrorsTriggersTest.java b/quartz/src/test/java/org/quartz/integrations/tests/JobClassNotFoundExceptionErrorsTriggersTest.java index 0fe248788..acabd386e 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/JobClassNotFoundExceptionErrorsTriggersTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/JobClassNotFoundExceptionErrorsTriggersTest.java @@ -43,7 +43,7 @@ import static org.quartz.impl.StdSchedulerFactory.PROP_SCHED_CLASS_LOAD_HELPER_CLASS; -public class JobClassNotFoundExceptionErrorsTriggersTest extends QuartzDatabaseTestSupport { +public class JobClassNotFoundExceptionErrorsTriggersTest extends QuartzDerbyTestSupport { private static final String BARRIER_KEY = "BARRIER"; diff --git a/quartz/src/test/java/org/quartz/integrations/tests/JobDataMapStorageTest.java b/quartz/src/test/java/org/quartz/integrations/tests/JobDataMapStorageTest.java index 0e23baa54..7eb859be6 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/JobDataMapStorageTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/JobDataMapStorageTest.java @@ -32,7 +32,7 @@ /** * Created by zemian on 10/25/16. */ -public class JobDataMapStorageTest extends QuartzDatabaseTestSupport { +public class JobDataMapStorageTest extends QuartzDerbyTestSupport { @Test void testJobDataMapDirtyFlag() throws Exception { JobDetail jobDetail = newJob(HelloJob.class) diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QTZ179_TriggerLostAfterDbRestart_Test.java b/quartz/src/test/java/org/quartz/integrations/tests/QTZ179_TriggerLostAfterDbRestart_Test.java index 77efb237e..592eb6fe2 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QTZ179_TriggerLostAfterDbRestart_Test.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QTZ179_TriggerLostAfterDbRestart_Test.java @@ -31,7 +31,7 @@ import static org.quartz.JobBuilder.newJob; import static org.quartz.TriggerBuilder.newTrigger; -public class QTZ179_TriggerLostAfterDbRestart_Test extends QuartzDatabaseTestSupport { +public class QTZ179_TriggerLostAfterDbRestart_Test extends QuartzDerbyTestSupport { private static final long DURATION_OF_FIRST_SCHEDULING = 9L; private static final long DURATION_OF_NETWORK_FAILURE = 10L; diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QTZ283_IgnoreMisfirePolicyJdbcStore_Test.java b/quartz/src/test/java/org/quartz/integrations/tests/QTZ283_IgnoreMisfirePolicyJdbcStore_Test.java index 2ebd63c80..07c8c4081 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QTZ283_IgnoreMisfirePolicyJdbcStore_Test.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QTZ283_IgnoreMisfirePolicyJdbcStore_Test.java @@ -36,7 +36,7 @@ import static org.quartz.SimpleScheduleBuilder.simpleSchedule; import static org.quartz.TriggerBuilder.newTrigger; -public class QTZ283_IgnoreMisfirePolicyJdbcStore_Test extends QuartzDatabaseTestSupport { +public class QTZ283_IgnoreMisfirePolicyJdbcStore_Test extends QuartzDerbyTestSupport { private static final long DURATION_OF_FIRST_SCHEDULING = 10L; private static final Logger LOG = LoggerFactory.getLogger(QTZ283_IgnoreMisfirePolicyJdbcStore_Test.class); diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabasePauseAndResumeTest.java b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabasePauseAndResumeTest.java index 588691d8d..ca6f59ea4 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabasePauseAndResumeTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabasePauseAndResumeTest.java @@ -34,7 +34,7 @@ /** * Created by zemian on 10/25/16. */ -public class QuartzDatabasePauseAndResumeTest extends QuartzDatabaseTestSupport { +public class QuartzDatabasePauseAndResumeTest extends QuartzDerbyTestSupport { @Test void testPauseAndResumeTriggers() throws Exception { diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseSimplePropertiesTest.java b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseSimplePropertiesTest.java index 011132b50..1d710df08 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseSimplePropertiesTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseSimplePropertiesTest.java @@ -36,7 +36,7 @@ import static org.quartz.JobBuilder.newJob; import static org.quartz.TriggerBuilder.newTrigger; -public class QuartzDatabaseSimplePropertiesTest extends QuartzDatabaseTestSupport { +public class QuartzDatabaseSimplePropertiesTest extends QuartzDerbyTestSupport { @Override protected Properties createSchedulerProperties() { diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseCronTriggerTest.java b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyCronTriggerTest.java similarity index 96% rename from quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseCronTriggerTest.java rename to quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyCronTriggerTest.java index 34240fbdb..cdacbf4d7 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseCronTriggerTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyCronTriggerTest.java @@ -37,7 +37,7 @@ * A integration test for Quartz Database Scheduler with Cron Trigger. * @author Zemian Deng */ -public class QuartzDatabaseCronTriggerTest extends QuartzDatabaseTestSupport { +public class QuartzDerbyCronTriggerTest extends QuartzDerbyTestSupport { @Test void testCronRepeatCount() throws Exception { CronTrigger trigger = TriggerBuilder.newTrigger() diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseTestSupport.java b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyTestSupport.java similarity index 97% rename from quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseTestSupport.java rename to quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyTestSupport.java index 8042fe37b..22b8f03bd 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QuartzDatabaseTestSupport.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QuartzDerbyTestSupport.java @@ -36,8 +36,8 @@ * * @author Zemian Deng */ -public class QuartzDatabaseTestSupport extends QuartzMemoryTestSupport { - protected static final Logger LOG = LoggerFactory.getLogger(QuartzDatabaseTestSupport.class); +public class QuartzDerbyTestSupport extends QuartzMemoryTestSupport { + protected static final Logger LOG = LoggerFactory.getLogger(QuartzDerbyTestSupport.class); protected static NetworkServerControl derbyServer; @BeforeAll diff --git a/quartz/src/test/java/org/quartz/integrations/tests/QuartzMSSQLTestSupport.java b/quartz/src/test/java/org/quartz/integrations/tests/QuartzMSSQLTestSupport.java index 6f29cb552..5feb83d38 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/QuartzMSSQLTestSupport.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/QuartzMSSQLTestSupport.java @@ -18,14 +18,14 @@ import java.sql.SQLException; import java.util.Properties; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.quartz.impl.jdbcjobstore.JdbcQuartzMSSQLUtilities; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.impl.jdbcjobstore.MSSQLDelegate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.MSSQLServerContainer; -import org.testcontainers.utility.DockerImageName; /** * A base class to support database (MSSQL) scheduler integration testing. Each @@ -37,17 +37,14 @@ */ public class QuartzMSSQLTestSupport extends QuartzMemoryTestSupport { protected static final Logger LOG = LoggerFactory.getLogger(QuartzMSSQLTestSupport.class); - static MSSQLServerContainer mssqlserver = new MSSQLServerContainer( - DockerImageName.parse(MSSQLServerContainer.IMAGE).withTag("latest")).acceptLicense(); + + private static final DatabaseType DATABASE_TYPE = DatabaseType.MSSQL; @BeforeAll public static void initialize() throws Exception { - LOG.info("Starting MSSQL database."); - mssqlserver.start(); - LOG.info("Database started."); try { LOG.info("Creating Database tables for Quartz."); - JdbcQuartzMSSQLUtilities.createDatabase(mssqlserver); + JdbcQuartzTestUtilities.createDatabase(DATABASE_TYPE.name(), DATABASE_TYPE); LOG.info("Database tables created."); } catch (SQLException e) { throw new Exception("Failed to create Quartz tables.", e); @@ -56,7 +53,7 @@ public static void initialize() throws Exception { @AfterAll public static void shutdownDb() throws Exception { - mssqlserver.stop(); + JdbcQuartzTestUtilities.shutdownDatabase(DATABASE_TYPE.name(),DATABASE_TYPE); LOG.info("Database shutdown."); } @@ -70,17 +67,11 @@ protected Properties createSchedulerProperties() { properties.put("org.quartz.threadPool.threadPriority", "5"); properties.put("org.quartz.jobStore.misfireThreshold", "10000"); properties.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); - properties.put("org.quartz.jobStore.driverDelegateClass", MSSQLDelegate.class.getName()); + properties.put("org.quartz.jobStore.driverDelegateClass", DATABASE_TYPE.getDelegateClassName()); properties.put("org.quartz.jobStore.useProperties", "true"); - properties.put("org.quartz.jobStore.dataSource", "myDS"); + properties.put("org.quartz.jobStore.dataSource", DATABASE_TYPE.name()); properties.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); properties.put("org.quartz.jobStore.isClustered", "false"); - properties.put("org.quartz.dataSource.myDS.driver", mssqlserver.getDriverClassName()); - properties.put("org.quartz.dataSource.myDS.URL", mssqlserver.getJdbcUrl()); - properties.put("org.quartz.dataSource.myDS.user", mssqlserver.getUsername()); - properties.put("org.quartz.dataSource.myDS.password", mssqlserver.getPassword()); - properties.put("org.quartz.dataSource.myDS.maxConnections", "5"); - properties.put("org.quartz.dataSource.myDS.provider", "hikaricp"); return properties; } } \ No newline at end of file diff --git a/quartz/src/test/java/org/quartz/integrations/tests/StdRowLockSemaphoreTest.java b/quartz/src/test/java/org/quartz/integrations/tests/StdRowLockSemaphoreTest.java index 944297d44..42a7bc48a 100644 --- a/quartz/src/test/java/org/quartz/integrations/tests/StdRowLockSemaphoreTest.java +++ b/quartz/src/test/java/org/quartz/integrations/tests/StdRowLockSemaphoreTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.MatcherAssert.assertThat; -public class StdRowLockSemaphoreTest extends QuartzDatabaseTestSupport { +public class StdRowLockSemaphoreTest extends QuartzDerbyTestSupport { static volatile boolean myLockInvoked = false; static volatile int maxRetry = -1; static volatile long retryPeriod = -1; diff --git a/quartz/src/test/java/org/quartz/simpl/SystemPropertyInstanceIdGeneratorTest.java b/quartz/src/test/java/org/quartz/simpl/SystemPropertyInstanceIdGeneratorTest.java index 982c4b98e..12dbb6987 100644 --- a/quartz/src/test/java/org/quartz/simpl/SystemPropertyInstanceIdGeneratorTest.java +++ b/quartz/src/test/java/org/quartz/simpl/SystemPropertyInstanceIdGeneratorTest.java @@ -25,6 +25,7 @@ import org.quartz.Scheduler; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -94,7 +95,7 @@ void testGetInstanceIdFromCustomSystemProperty() throws Exception { @Test void testGeneratorThroughSchedulerInstantiation() throws Exception { try { - JdbcQuartzTestUtilities.createDatabase("MeSchedulerDatabase"); + JdbcQuartzTestUtilities.createDatabase("MeSchedulerDatabase", DatabaseType.DERBY); } catch (SQLException e) { throw new AssertionError(e); } diff --git a/quartz/src/test/java/org/quartz/utils/C3p0PoolingConnectionProviderTest.java b/quartz/src/test/java/org/quartz/utils/C3p0PoolingConnectionProviderTest.java index 51ebd2ed8..9f64251e9 100644 --- a/quartz/src/test/java/org/quartz/utils/C3p0PoolingConnectionProviderTest.java +++ b/quartz/src/test/java/org/quartz/utils/C3p0PoolingConnectionProviderTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.quartz.integrations.tests.JdbcQuartzDerbyUtilities; -import org.quartz.integrations.tests.QuartzDatabaseTestSupport; +import org.quartz.integrations.tests.QuartzDerbyTestSupport; import java.util.Properties; @@ -32,7 +32,7 @@ /** * A integration test to ensure PoolConnectionProvider is working properly. */ -public class C3p0PoolingConnectionProviderTest extends QuartzDatabaseTestSupport { +public class C3p0PoolingConnectionProviderTest extends QuartzDerbyTestSupport { boolean testConnectionProviderClass = false; @Test diff --git a/quartz/src/test/java/org/quartz/utils/HikariCpPoolingConnectionProviderTest.java b/quartz/src/test/java/org/quartz/utils/HikariCpPoolingConnectionProviderTest.java index 5acb68d90..2808b2bef 100644 --- a/quartz/src/test/java/org/quartz/utils/HikariCpPoolingConnectionProviderTest.java +++ b/quartz/src/test/java/org/quartz/utils/HikariCpPoolingConnectionProviderTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.quartz.integrations.tests.JdbcQuartzDerbyUtilities; -import org.quartz.integrations.tests.QuartzDatabaseTestSupport; +import org.quartz.integrations.tests.QuartzDerbyTestSupport; import java.util.Properties; @@ -33,7 +33,7 @@ /** * A integration test to ensure PoolConnectionProvider is working properly. */ -public class HikariCpPoolingConnectionProviderTest extends QuartzDatabaseTestSupport { +public class HikariCpPoolingConnectionProviderTest extends QuartzDerbyTestSupport { boolean testConnectionProviderClass = false; @Test diff --git a/quartz/src/test/java/org/quartz/xml/XMLSchedulingDataProcessorTest.java b/quartz/src/test/java/org/quartz/xml/XMLSchedulingDataProcessorTest.java index dea615df8..969f8b2a2 100755 --- a/quartz/src/test/java/org/quartz/xml/XMLSchedulingDataProcessorTest.java +++ b/quartz/src/test/java/org/quartz/xml/XMLSchedulingDataProcessorTest.java @@ -1,7 +1,10 @@ package org.quartz.xml; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.quartz.JobBuilder.newJob; import static org.quartz.SimpleScheduleBuilder.repeatHourlyForever; import static org.quartz.TriggerBuilder.newTrigger; @@ -19,18 +22,25 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; - -import org.hamcrest.Matchers; - - - - -import org.quartz.*; +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.JobKey; +import org.quartz.ObjectAlreadyExistsException; +import org.quartz.Scheduler; +import org.quartz.SimpleTrigger; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; import org.quartz.impl.DirectSchedulerFactory; import org.quartz.impl.SchedulerRepository; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities; +import org.quartz.impl.jdbcjobstore.JdbcQuartzTestUtilities.DatabaseType; import org.quartz.impl.jdbcjobstore.JobStoreTX; import org.quartz.impl.matchers.GroupMatcher; import org.quartz.simpl.CascadingClassLoadHelper; @@ -275,7 +285,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { void testRemoveJobClassNotFound() throws Exception { String DB_NAME = "XmlDeleteNonExistsJobTestDatabase"; String SCHEDULER_NAME = "XmlDeleteNonExistsJobTestScheduler"; - JdbcQuartzTestUtilities.createDatabase(DB_NAME); + JdbcQuartzTestUtilities.createDatabase(DB_NAME, DatabaseType.DERBY); JobStoreTX jobStore = new JobStoreTX(); jobStore.setDataSource(DB_NAME); @@ -318,7 +328,7 @@ void testRemoveJobClassNotFound() throws Exception { assertThat(trigger2, Matchers.instanceOf(SimpleTrigger.class)); } finally { scheduler.shutdown(false); - JdbcQuartzTestUtilities.destroyDatabase(DB_NAME); + JdbcQuartzTestUtilities.destroyDatabase(DB_NAME, DatabaseType.DERBY); } } @@ -326,7 +336,7 @@ void testRemoveJobClassNotFound() throws Exception { void testOverwriteJobClassNotFound() throws Exception { String DB_NAME = "XmlDeleteNonExistsJobTestDatabase"; String SCHEDULER_NAME = "XmlDeleteNonExistsJobTestScheduler"; - JdbcQuartzTestUtilities.createDatabase(DB_NAME); + JdbcQuartzTestUtilities.createDatabase(DB_NAME, DatabaseType.DERBY); JobStoreTX jobStore = new JobStoreTX(); jobStore.setDataSource(DB_NAME); @@ -364,7 +374,7 @@ void testOverwriteJobClassNotFound() throws Exception { assertThat(trigger2, Matchers.instanceOf(SimpleTrigger.class)); } finally { scheduler.shutdown(false); - JdbcQuartzTestUtilities.destroyDatabase(DB_NAME); + JdbcQuartzTestUtilities.destroyDatabase(DB_NAME, DatabaseType.DERBY); } } diff --git a/quartz/src/test/resources/container-license-acceptance.txt b/quartz/src/test/resources/container-license-acceptance.txt new file mode 100644 index 000000000..f17e683de --- /dev/null +++ b/quartz/src/test/resources/container-license-acceptance.txt @@ -0,0 +1 @@ +mcr.microsoft.com/mssql/server:latest \ No newline at end of file