diff --git a/jbpm-db-scripts/src/test/filtered-resources/META-INF/persistence.xml b/jbpm-db-scripts/src/test/filtered-resources/META-INF/persistence.xml
index 1dc0bf5bc4..f57a254f4b 100644
--- a/jbpm-db-scripts/src/test/filtered-resources/META-INF/persistence.xml
+++ b/jbpm-db-scripts/src/test/filtered-resources/META-INF/persistence.xml
@@ -134,7 +134,7 @@
-
+
diff --git a/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/DDLScriptsTest.java b/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/DDLScriptsTest.java
index 4a26452808..821783b780 100644
--- a/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/DDLScriptsTest.java
+++ b/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/DDLScriptsTest.java
@@ -19,7 +19,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-
+import java.io.IOException;
import org.jbpm.test.persistence.scripts.DatabaseType;
import org.jbpm.test.persistence.scripts.PersistenceUnit;
import org.jbpm.test.persistence.scripts.ScriptsBase;
@@ -55,14 +55,17 @@ public static Collection data() {
ScriptFilter[] sbPg = new ScriptFilter[]{filter("postgresql-springboot-jbpm-schema.sql",
"quartz_tables_postgres.sql").setSupportedDatabase(DatabaseType.POSTGRESQL)
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR),
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR,
+ Option.NEW_GENERATOR_MAPPINGS_TRUE),
filter("postgresql-springboot-jbpm-drop-schema.sql",
"quartz_tables_drop_postgres.sql")};
ScriptFilter[] pqlBytea = new ScriptFilter[]{filter("postgresql-bytea-jbpm-schema.sql",
"quartz_tables_postgres.sql")
.setSupportedDatabase(DatabaseType.POSTGRESQL)
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR)
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR)
.env("org.kie.persistence.postgresql.useBytea", "true"),
filter("postgresql-bytea-jbpm-drop-schema.sql",
"quartz_tables_drop_postgres.sql")};
@@ -70,25 +73,30 @@ public static Collection data() {
ScriptFilter[] pqlSpringBootBytea = new ScriptFilter[]{filter("postgresql-springboot-bytea-jbpm-schema.sql",
"quartz_tables_postgres.sql")
.setSupportedDatabase(DatabaseType.POSTGRESQL)
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR)
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR,
+ Option.NEW_GENERATOR_MAPPINGS_TRUE)
.env("org.kie.persistence.postgresql.useBytea", "true"),
filter("postgresql-springboot-bytea-jbpm-drop-schema.sql",
"quartz_tables_drop_postgres.sql")};
ScriptFilter[] sbOracle = new ScriptFilter[]{filter("oracle-springboot-jbpm-schema.sql",
"quartz_tables_oracle.sql").setSupportedDatabase(DatabaseType.ORACLE)
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR),
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR),
filter("oracle-springboot-jbpm-drop-schema.sql",
"quartz_tables_drop_oracle.sql")};
ScriptFilter[] mySqlCluster = new ScriptFilter[]{filter("mysql-innodb-cluster-jbpm-schema.sql",
"quartz_tables_mysql_innodb.sql").setSupportedDatabase(DatabaseType.MYSQLINNODB)
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR),
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR),
filter("mysql-innodb-jbpm-drop-schema.sql",
"quartz_tables_drop_mysql_innodb.sql")};
ScriptFilter[] taskAssigningTables = new ScriptFilter[]{filter(Filter.OUT, "drop", "bytea", "springboot", "cluster")
- .setOptions(Option.DISALLOW_EMPTY_RESULTS, Option.THROW_ON_SCRIPT_ERROR),
+ .setOptions(Option.DISALLOW_EMPTY_RESULTS,
+ Option.THROW_ON_SCRIPT_ERROR),
filter("jbpm-drop-schema.sql",
"quartz_tables_drop_",
"task_assigning_tables_drop_")};
@@ -107,7 +115,8 @@ public DDLScriptsTest(ScriptFilter createScript, ScriptFilter dropScript) {
private Map oldEnvironment;
@Before
- public void prepare() {
+ public void prepare() throws IOException {
+ replaceNewGeneratorMappingsValue(createScript);
oldEnvironment = new HashMap<>();
Map newEnvironment = createScript.getEnvironment();
for (Map.Entry entry : newEnvironment.entrySet()) {
diff --git a/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/UpgradeScriptsTest.java b/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/UpgradeScriptsTest.java
index ec15834434..78d4e9b92a 100644
--- a/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/UpgradeScriptsTest.java
+++ b/jbpm-db-scripts/src/test/java/org/jbpm/persistence/scripts/UpgradeScriptsTest.java
@@ -28,6 +28,7 @@
import org.jbpm.test.persistence.scripts.ScriptsBase;
import org.jbpm.test.persistence.scripts.util.ScriptFilter;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -80,6 +81,11 @@ public static void hasToBeTested() {
assumeTrue(dbType!=DB2 && dbType!=SYBASE);
}
+ @Before
+ public void prepare() throws IOException {
+ replaceNewGeneratorMappingsValue(ScriptFilter.init(false, false));
+ }
+
private void createSchema60UsingDDLs() throws IOException, SQLException {
//create 6.0 schema
executeScriptRunner(DB_60_SCRIPTS_RESOURCE_PATH, ScriptFilter.init(false, true));
diff --git a/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/ScriptsBase.java b/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/ScriptsBase.java
index bfb4250b6e..f02f4b9457 100644
--- a/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/ScriptsBase.java
+++ b/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/ScriptsBase.java
@@ -18,12 +18,17 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.sql.SQLException;
-
import javax.sql.DataSource;
import org.jbpm.test.persistence.scripts.util.TestsUtil;
+import org.jbpm.test.persistence.scripts.util.ScriptFilter.Option;
import org.jbpm.test.persistence.scripts.util.ScriptFilter;
+import org.junit.After;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TestRule;
@@ -32,6 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.jbpm.test.persistence.scripts.TestPersistenceContextBase.createAndInitContext;
import static org.jbpm.test.persistence.scripts.util.ScriptFilter.filter;
@@ -39,7 +45,9 @@ public class ScriptsBase {
protected static final String DB_DDL_SCRIPTS_RESOURCE_PATH = "/db/ddl-scripts";
protected static final String TEST_PROCESS_ID = "minimalProcess";
-
+ protected static final String PERSISTENCE_XML_PATH = "target/test-classes/META-INF/persistence.xml";
+ protected static final String BACKUP_PERSISTENCE_XML_PATH = "target/test-classes/META-INF/persistence-backup.xml";
+
private static final Logger logger = LoggerFactory.getLogger(ScriptsBase.class);
public ScriptsBase() {
@@ -60,6 +68,17 @@ public static void cleanUp() throws IOException, SQLException {
// Drop optional table "PlanningTask" if exists
executeScriptRunner(DB_DDL_SCRIPTS_RESOURCE_PATH, filter("task_assigning_tables_drop_"));
}
+
+ @Before
+ public void setUp() throws IOException {
+ // Create a backup of the original persistence.xml for not losing placeholder for next tests
+ Files.copy(Paths.get(PERSISTENCE_XML_PATH), Paths.get(BACKUP_PERSISTENCE_XML_PATH), REPLACE_EXISTING);
+ }
+
+ @After
+ public void restoreBackup() throws IOException {
+ Files.copy(Paths.get(BACKUP_PERSISTENCE_XML_PATH), Paths.get(PERSISTENCE_XML_PATH), StandardCopyOption.REPLACE_EXISTING);
+ }
public static void executeScriptRunner(String resourcePath, ScriptFilter scriptFilter) throws IOException, SQLException {
final TestPersistenceContextBase scriptRunnerContext = createAndInitContext(PersistenceUnit.SCRIPT_RUNNER);
@@ -80,4 +99,17 @@ public static void executeScriptRunner(String resourcePath, ScriptFilter scriptF
scriptRunnerContext.clean();
}
}
+
+ protected void replaceNewGeneratorMappingsValue(ScriptFilter script) throws IOException {
+ if (script.hasOption(Option.NEW_GENERATOR_MAPPINGS_TRUE)) {
+ Files.write(Paths.get(PERSISTENCE_XML_PATH), getUpdatedXml("true").getBytes());
+ } else {
+ Files.write(Paths.get(PERSISTENCE_XML_PATH), getUpdatedXml("false").getBytes());
+ }
+ }
+
+ protected String getUpdatedXml(String placeholderValue) throws IOException {
+ String templateXml = new String(Files.readAllBytes(Paths.get(BACKUP_PERSISTENCE_XML_PATH)));
+ return templateXml.replace("${new_generator_mappings.value}", placeholderValue);
+ }
}
diff --git a/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/util/ScriptFilter.java b/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/util/ScriptFilter.java
index a4c435cd6a..d36e25a6c9 100644
--- a/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/util/ScriptFilter.java
+++ b/jbpm-test-util/src/main/java/org/jbpm/test/persistence/scripts/util/ScriptFilter.java
@@ -35,6 +35,7 @@ public class ScriptFilter {
public enum Option {
DISALLOW_EMPTY_RESULTS, // if the filter allow no results
THROW_ON_SCRIPT_ERROR, // if the filter allows script errors
+ NEW_GENERATOR_MAPPINGS_TRUE //if the new_generator_mappings property switches to true
}
public enum Filter {