diff --git a/modules/test-jpa/pom.xml b/modules/test-jpa/pom.xml
index 7030098c..e1e430d1 100644
--- a/modules/test-jpa/pom.xml
+++ b/modules/test-jpa/pom.xml
@@ -24,6 +24,12 @@
org.flywaydb
flyway-core
+ true
+
+
+ org.liquibase
+ liquibase-core
+ true
\ No newline at end of file
diff --git a/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginFlyway.java b/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginFlyway.java
index 909fb263..0aa1c1e8 100644
--- a/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginFlyway.java
+++ b/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginFlyway.java
@@ -3,12 +3,14 @@
import javax.inject.Inject;
import org.flywaydb.core.Flyway;
+import org.springframework.beans.factory.annotation.Qualifier;
/**
* Implementation of {@link TestCleanerPlugin} base on {@link Flyway}. It will {@link Flyway#clean() clean} and
* {@link Flyway#migrate() migrate} on {@link #cleanup()}. Therefore after {@link #cleanup()} only DDL and master-data
* will be left in the database.
*/
+@Qualifier("testCleanerPluginflyway")
public class TestCleanerPluginFlyway implements TestCleanerPlugin {
@Inject
diff --git a/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginLiquibase.java b/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginLiquibase.java
new file mode 100644
index 00000000..526bb764
--- /dev/null
+++ b/modules/test-jpa/src/main/java/com/devonfw/module/test/common/base/clean/TestCleanerPluginLiquibase.java
@@ -0,0 +1,46 @@
+package com.devonfw.module.test.common.base.clean;
+
+import javax.inject.Inject;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import liquibase.Liquibase;
+import liquibase.exception.DatabaseException;
+
+/**
+ * Implementation of {@link TestCleanerPlugin} base on {@link Liquibase}. It will {@link Liquibase#dropAll() clean} on
+ * {@link #cleanup()}. Therefore after {@link #cleanup()} it will drop all database objects.
+ */
+@Qualifier("testCleanerPluginliquibase")
+public class TestCleanerPluginLiquibase implements TestCleanerPlugin {
+
+ private Liquibase liquibase;
+
+ /**
+ * The constructor.
+ */
+ public TestCleanerPluginLiquibase() {
+
+ super();
+ }
+
+ /**
+ * The constructor.
+ *
+ * @param liquibase the {@link Liquibase} instance.
+ */
+ public TestCleanerPluginLiquibase(Liquibase liquibase) {
+
+ super();
+ this.liquibase = liquibase;
+ }
+
+ @Override
+ public void cleanup() {
+ try {
+ this.liquibase.dropAll();
+ } catch(DatabaseException databaseException ) {
+ throw new RuntimeException(databaseException);
+ }
+ }
+
+}
diff --git a/modules/test/src/main/resources/logback.xml b/modules/test/src/main/resources/logback.xml
index d4b83a52..d042e45d 100644
--- a/modules/test/src/main/resources/logback.xml
+++ b/modules/test/src/main/resources/logback.xml
@@ -16,6 +16,7 @@
+
diff --git a/pom.xml b/pom.xml
index 065357be..b6ba0484 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,67 +1,67 @@
-
-
- 4.0.0
-
- com.devonfw
- maven-parent
- 6
-
- com.devonfw.java.dev
- devon4j
- dev-SNAPSHOT
- pom
- ${project.artifactId}
- Java stack of devonfw.com (devon4j): develop Java apps standardized, faster and with less risk.
- 2014
-
-
- boms
- modules
- starters
- templates
- documentation
-
-
-
- dev-SNAPSHOT
- devon4j
- ${revision}
- 2.4.4
-
- 2020.0.0
- 2.12.2
- 30.1.1-jre
- 5.7.1
- 3.4.3
- 8.7.0
- 1.7.30
- https://sonarcloud.io
- devonfw
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
-
- WEB-INF/classes/config/application.properties,*.jsp
- ${project.artifactId}
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring.boot.version}
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.devonfw
+ maven-parent
+ 6
+
+ com.devonfw.java.dev
+ devon4j
+ dev-SNAPSHOT
+ pom
+ ${project.artifactId}
+ Java stack of devonfw.com (devon4j): develop Java apps standardized, faster and with less risk.
+ 2014
+
+
+ boms
+ modules
+ starters
+ templates
+ documentation
+
+
+
+ dev-SNAPSHOT
+ devon4j
+ ${revision}
+ 2.4.4
+
+ 2020.0.0
+ 2.12.2
+ 30.1.1-jre
+ 5.7.1
+ 3.4.3
+ 8.7.0
+ 1.7.30
+ https://sonarcloud.io
+ devonfw
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+ WEB-INF/classes/config/application.properties,*.jsp
+ ${project.artifactId}
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring.boot.version}
+
+
+
+
+
diff --git a/templates/pom.xml b/templates/pom.xml
index 157b7e4d..4322b9e8 100644
--- a/templates/pom.xml
+++ b/templates/pom.xml
@@ -1,19 +1,19 @@
-
-
- 4.0.0
-
- com.devonfw.java.dev
- devon4j
- dev-SNAPSHOT
-
- devon4j-templates
- pom
- ${project.artifactId}
- Templates (maven archetypes) of devon4j.
-
-
- server
-
-
-
+
+
+ 4.0.0
+
+ com.devonfw.java.dev
+ devon4j
+ dev-SNAPSHOT
+
+ devon4j-templates
+ pom
+ ${project.artifactId}
+ Templates (maven archetypes) of devon4j.
+
+
+ server
+
+
+
diff --git a/templates/server/src/main/resources/META-INF/archetype-post-generate.groovy b/templates/server/src/main/resources/META-INF/archetype-post-generate.groovy
index fc05afdc..58dcd880 100644
--- a/templates/server/src/main/resources/META-INF/archetype-post-generate.groovy
+++ b/templates/server/src/main/resources/META-INF/archetype-post-generate.groovy
@@ -1,30 +1,51 @@
-import java.nio.file.Files
-import java.nio.file.Path
-import java.nio.file.Paths
-import java.nio.file.LinkOption
-
-// the path where the project got generated
-Path projectPath = Paths.get(request.outputDirectory, request.artifactId)
-
-// the properties available to the archetype
-Properties properties = request.properties
-String batch = properties.get("batch")
-
-if (batch != "batch") {
- // delete folder batch recursively
- Path rootPath = projectPath.resolve("batch")
- deleteDirectoryRecursion(rootPath)
-}
-
-void deleteDirectoryRecursion(Path path) {
- if (Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS)) {
- try {
- for (Path entry : Files.newDirectoryStream(path)) {
- deleteDirectoryRecursion(entry);
- }
- } catch(IOException e) {
- e.printStackTrace()
- }
- }
- Files.delete(path);
-}
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.nio.file.LinkOption
+
+// the path where the project got generated
+Path projectPath = Paths.get(request.outputDirectory, request.artifactId)
+
+// the properties available to the archetype
+Properties properties = request.properties
+
+String batch = properties.get("batch")
+
+if (batch != "batch") {
+ // delete folder batch recursively
+ Path rootPath = projectPath.resolve("batch")
+ deleteDirectoryRecursion(rootPath)
+}
+
+//dbMigration is either flyway or liquibase
+String dbMigration = properties.get("dbMigration")
+
+if (dbMigration == "flyway") {
+//delete changelog and testchangelog folder which is not required for flyway
+ Path rootPath = projectPath.resolve("core/src/main/resources/db/changelog")
+ deleteDirectoryRecursion(rootPath)
+
+ Files.deleteIfExists projectPath.resolve("core/src/test/resources/db/test/changelog-master.xml")
+ Files.deleteIfExists projectPath.resolve("core/src/test/resources/db/test/changelog-v1.0.xml")
+
+} else if(dbMigration == "liquibase") {
+//delete migration and test folder which is not required for liquibase
+ Path rootPath = projectPath.resolve("core/src/main/resources/db/migration")
+ deleteDirectoryRecursion(rootPath)
+
+ Files.deleteIfExists projectPath.resolve("core/src/test/resources/db/test/V0001__InitDb.sql")
+
+}
+
+void deleteDirectoryRecursion(Path path) {
+ if (Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS)) {
+ try {
+ for (Path entry : Files.newDirectoryStream(path)) {
+ deleteDirectoryRecursion(entry);
+ }
+ } catch(IOException e) {
+ e.printStackTrace()
+ }
+ }
+ Files.delete(path);
+}
diff --git a/templates/server/src/main/resources/META-INF/maven/archetype-metadata.xml b/templates/server/src/main/resources/META-INF/maven/archetype-metadata.xml
index 2661ecec..9c64198b 100644
--- a/templates/server/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/templates/server/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -1,72 +1,75 @@
-
-
- devon4j-template-server
-
-
-
- h2
-
-
-
- .
- batch|[.]
-
-
-
-
- api
-
- **/*.*
-
-
-
- core
-
- **/*.*
-
-
-
-
- batch
-
- **/*.*
-
-
-
-
-
- .gitignore
-
-
-
- .mvn
-
- **/*.*
-
-
-
-
-
-
-
- src/main/java
-
-
- src/main/resources
-
-
- src/test/java
-
-
- src/test/resources
-
-
- src/main/webapp
-
-
-
-
-
+
+
+ devon4j-template-server
+
+
+
+ h2
+
+
+
+ flyway
+
+
+ .
+ batch|[.]
+
+
+
+
+ api
+
+ **/*.*
+
+
+
+ core
+
+ **/*.*
+
+
+
+
+ batch
+
+ **/*.*
+
+
+
+
+
+ .gitignore
+
+
+
+ .mvn
+
+ **/*.*
+
+
+
+
+
+
+
+ src/main/java
+
+
+ src/main/resources
+
+
+ src/test/java
+
+
+ src/test/resources
+
+
+ src/main/webapp
+
+
+
+
+
diff --git a/templates/server/src/main/resources/archetype-resources/batch/pom.xml b/templates/server/src/main/resources/archetype-resources/batch/pom.xml
index bf27e0bb..9f460c63 100644
--- a/templates/server/src/main/resources/archetype-resources/batch/pom.xml
+++ b/templates/server/src/main/resources/archetype-resources/batch/pom.xml
@@ -36,6 +36,12 @@
devon4j-test
test
+
+
+ com.devonfw.java.modules
+ devon4j-test-jpa
+ test
+
diff --git a/templates/server/src/main/resources/archetype-resources/batch/src/test/java/__packageInPathFormat__/general/batch/base/test/SpringBatchIntegrationTest.java b/templates/server/src/main/resources/archetype-resources/batch/src/test/java/__packageInPathFormat__/general/batch/base/test/SpringBatchIntegrationTest.java
index 6bea2912..f4eb3b58 100644
--- a/templates/server/src/main/resources/archetype-resources/batch/src/test/java/__packageInPathFormat__/general/batch/base/test/SpringBatchIntegrationTest.java
+++ b/templates/server/src/main/resources/archetype-resources/batch/src/test/java/__packageInPathFormat__/general/batch/base/test/SpringBatchIntegrationTest.java
@@ -1,53 +1,49 @@
-package ${package}.general.batch.base.test;
-
-import javax.inject.Inject;
-
-import org.flywaydb.core.Flyway;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.batch.core.Job;
-import org.springframework.batch.core.launch.JobLauncher;
-import org.springframework.batch.test.JobLauncherTestUtils;
-
-import ${package}.general.common.base.test.TestUtil;
-import com.devonfw.module.test.common.base.ComponentTest;
-
-/**
- * Base class for all spring batch integration tests. It helps to do End-to-End job tests.
- */
-public abstract class SpringBatchIntegrationTest extends ComponentTest {
-
- @Inject
- private JobLauncher jobLauncher;
-
- @Inject
- private Flyway flyway;
-
- @Override
- protected void doSetUp() {
-
- super.doSetUp();
- this.flyway.clean();
- this.flyway.migrate();
- }
-
- @Override
- protected void doTearDown() {
-
- super.doTearDown();
- TestUtil.logout();
- }
-
- /**
- * @param job job to configure
- * @return jobLauncherTestUtils
- */
- public JobLauncherTestUtils getJobLauncherTestUtils(Job job) {
-
- JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
- jobLauncherTestUtils.setJob(job);
- jobLauncherTestUtils.setJobLauncher(this.jobLauncher);
-
- return jobLauncherTestUtils;
- }
-}
+package ${package}.general.batch.base.test;
+
+import javax.inject.Inject;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.launch.JobLauncher;
+import org.springframework.batch.test.JobLauncherTestUtils;
+import ${package}.general.common.base.test.TestUtil;
+import com.devonfw.module.test.common.base.ComponentTest;
+import com.devonfw.module.test.common.base.DbTest;
+import com.devonfw.module.test.common.base.clean.TestCleanerPlugin;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+/**
+ * Base class for all spring batch integration tests. It helps to do End-to-End job tests.
+ */
+public abstract class SpringBatchIntegrationTest extends ComponentTest {
+
+ @Inject
+ private JobLauncher jobLauncher;
+
+ @Inject
+ @Qualifier("testCleanerPlugin$dbMigration")
+ private TestCleanerPlugin testCleanerPlugin;
+
+ @Override
+ protected void doSetUp() {
+ super.doSetUp();
+ testCleanerPlugin.cleanup();
+ }
+
+ protected void doTearDown() {
+
+ super.doTearDown();
+ TestUtil.logout();
+ }
+
+ /**
+ * @param job job to configure
+ * @return jobLauncherTestUtils
+ */
+ public JobLauncherTestUtils getJobLauncherTestUtils(Job job) {
+
+ JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
+ jobLauncherTestUtils.setJob(job);
+ jobLauncherTestUtils.setJobLauncher(this.jobLauncher);
+
+ return jobLauncherTestUtils;
+ }
+}
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/pom.xml b/templates/server/src/main/resources/archetype-resources/core/pom.xml
index de4b7c0d..9eb95866 100644
--- a/templates/server/src/main/resources/archetype-resources/core/pom.xml
+++ b/templates/server/src/main/resources/archetype-resources/core/pom.xml
@@ -1,4 +1,4 @@
-
+
4.0.0
@@ -36,6 +36,12 @@
devon4j-web
+
+ com.devonfw.java.modules
+ devon4j-test-jpa
+ test
+
+
com.devonfw.java.starters
@@ -66,7 +72,7 @@
+ -->
org.springframework.boot
spring-boot-starter-jdbc
@@ -132,7 +138,7 @@
#elseif ($dbType == 'postgresql')
org.postgresql
postgresql
-
+
#elseif ($dbType == 'mysql')
mysql
mysql-connector-java
@@ -167,11 +173,20 @@
#end
-
+
+#if ($dbMigration == 'flyway')
org.flywaydb
flyway-core
+#end
+
+#if ($dbMigration == 'liquibase')
+
+ org.liquibase
+ liquibase-core
+
+#end
@@ -254,7 +269,20 @@
+
+#if($dbMigration == 'liquibase')
+
+ org.liquibase
+ liquibase-maven-plugin
+ 3.8.0
+
+
+ liquibase
+
+
+
+#end
-
-
+
+
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/main/java/__packageInPathFormat__/SpringBootApp.java b/templates/server/src/main/resources/archetype-resources/core/src/main/java/__packageInPathFormat__/SpringBootApp.java
index 4c12884c..160113e0 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/main/java/__packageInPathFormat__/SpringBootApp.java
+++ b/templates/server/src/main/resources/archetype-resources/core/src/main/java/__packageInPathFormat__/SpringBootApp.java
@@ -5,7 +5,8 @@
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import com.devonfw.module.jpa.dataaccess.api.AdvancedRevisionEntity;
import com.devonfw.module.jpa.dataaccess.impl.data.GenericRepositoryFactoryBean;
@@ -15,6 +16,7 @@
@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = GenericRepositoryFactoryBean.class)
@EnableGlobalMethodSecurity(jsr250Enabled = true)
+@EnableAutoConfiguration(exclude = LiquibaseAutoConfiguration.class)
public class SpringBootApp {
/**
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/application.properties b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/application.properties
index be1ebdc9..e27bc1f9 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/application.properties
+++ b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/application.properties
@@ -69,5 +69,9 @@ spring.jpa.open-in-view=false
# see http://stackoverflow.com/questions/22318907/how-to-stop-spring-batch-scheduled-jobs-from-running-at-first-time-when-executin
spring.batch.job.enabled=false
-# Flyway for Database Setup and Migrations
+# Configuration for Database Setup and Migrations
+#if ($dbMigration == 'flyway')
spring.flyway.locations=classpath:db/migration
+#else
+spring.liquibase.change-log=classpath:db/changelog/changelog-master.xml
+#end
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/config/application.properties b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/config/application.properties
index 04ce2939..ccfa335c 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/config/application.properties
+++ b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/config/application.properties
@@ -47,6 +47,11 @@ spring.jpa.properties.hibernate.format_sql=true
# Enable JSON pretty printing
spring.jackson.serialization.INDENT_OUTPUT=true
-# Flyway for Database Setup and Migrations
+# Configuration for Database Setup and Migrations
+#if ($dbMigration == 'flyway')
spring.flyway.enabled=true
spring.flyway.clean-on-validation-error=true
+#else
+spring.liquibase.enabled=true
+#end
+
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-master.xml b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-master.xml
new file mode 100644
index 00000000..c7f1737b
--- /dev/null
+++ b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-master.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-v1.0.xml b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-v1.0.xml
new file mode 100644
index 00000000..50b8cbdb
--- /dev/null
+++ b/templates/server/src/main/resources/archetype-resources/core/src/main/resources/db/changelog/changelog-v1.0.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/base/test/DbTestHelper.java b/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/base/test/DbTestHelper.java
index 65ca1e44..24475397 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/base/test/DbTestHelper.java
+++ b/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/base/test/DbTestHelper.java
@@ -1,44 +1,32 @@
package ${package}.general.common.base.test;
import javax.inject.Named;
-
-import org.flywaydb.core.Flyway;
+import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Qualifier;
+import com.devonfw.module.test.common.base.clean.TestCleanerPlugin;
/**
* This class provides methods for handling the database during testing where resets (and other operations) may be
* necessary.
*/
@Named
-public class DbTestHelper {
+public class DbTestHelper{
+
+ @Inject
+ @Qualifier("testCleanerPlugin$dbMigration")
+ private TestCleanerPlugin testCleanerPlugin;
- private Flyway flyway;
+ public DbTestHelper(TestCleanerPlugin testCleanerPlugin) {
- /**
- * The constructor.
- *
- * @param flyway an instance of type {@link Flyway}.
- */
- public DbTestHelper(Flyway flyway) {
super();
- this.flyway = flyway;
+ this.testCleanerPlugin = testCleanerPlugin;
}
/**
* Drops the whole database.
*/
public void dropDatabase() {
-
- this.flyway.clean();
- }
-
- /**
- * Calls {@link #dropDatabase()} internally, and migrates to the highest available migration (default) or to the
- * {@code migrationVersion} specified by {@link #setMigrationVersion(String)}.
- */
- public void resetDatabase() {
-
- dropDatabase();
- this.flyway.migrate();
+ testCleanerPlugin.cleanup();
}
-}
+}
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/impl/config/TestDbConfig.java b/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/impl/config/TestDbConfig.java
index 5f33fcf9..9fbe776b 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/impl/config/TestDbConfig.java
+++ b/templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/impl/config/TestDbConfig.java
@@ -2,11 +2,20 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-
+import org.springframework.beans.factory.annotation.Value;#if($dbMigration=='liquibase')
+import liquibase.Liquibase;
+import liquibase.resource.ResourceAccessor;
+import liquibase.resource.FileSystemResourceAccessor;
+import liquibase.database.Database;
+import liquibase.exception.DatabaseException;
+import liquibase.database.DatabaseFactory;#end
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+import javax.sql.DataSource;
import com.devonfw.module.test.common.base.clean.TestCleaner;
import com.devonfw.module.test.common.base.clean.TestCleanerImpl;
-import com.devonfw.module.test.common.base.clean.TestCleanerPlugin;
-import com.devonfw.module.test.common.base.clean.TestCleanerPluginFlyway;
+import com.devonfw.module.test.common.base.clean.TestCleanerPlugin;#if($dbMigration=='liquibase')
+import com.devonfw.module.test.common.base.clean.TestCleanerPluginLiquibase;#else
+import com.devonfw.module.test.common.base.clean.TestCleanerPluginFlyway;#end
/**
* {@link Configuration} for Database in JUnit tests.
@@ -23,13 +32,49 @@ public TestCleaner testCleaner() {
return new TestCleanerImpl();
}
+ #if($dbMigration=='liquibase')
+
/**
- * @return the {@link TestCleanerPluginFlyway}.
- */
+ * @return the {@link TestCleanerPluginLiquibase}.
+ */
+ @Bean
+ public TestCleanerPlugin testCleanerPluginLiquibase() {
+
+ return new TestCleanerPluginLiquibase();
+ }
+
+ @Value("${spring.datasource.url}")
+ private String spring_datasource_url;
+
+ @Value("${spring.datasource.password}")
+ private String spring_datasource_password;
+
+ @Value("${spring.datasource.username}")
+ private String spring_datasource_username;
+
+ @Value("${spring.liquibase.change-log}")
+ private String spring_liquibase_change_log;
+
@Bean
- public TestCleanerPlugin testCleanerPluginFlyway() {
+ public Liquibase liquibase() throws DatabaseException {
+
+ ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
+ Database database = DatabaseFactory.getInstance().openDatabase(this.spring_datasource_url,
+ this.spring_datasource_username, this.spring_datasource_password, null, null, null, null,
+ resourceAccessor);
+ Liquibase liquibase = new Liquibase(this.spring_liquibase_change_log, resourceAccessor, database);
- return new TestCleanerPluginFlyway();
+ return liquibase;
}
-}
+ #else
+
+ /**
+ * @return the {@link TestCleanerPluginFlyway}.
+ */
+ @Bean
+ public TestCleanerPlugin testCleanerPluginFlyway() {
+
+ return new TestCleanerPluginFlyway();
+ }#end
+}
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/test/resources/config/application.properties b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/config/application.properties
index c6836bab..604a17bc 100644
--- a/templates/server/src/main/resources/archetype-resources/core/src/test/resources/config/application.properties
+++ b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/config/application.properties
@@ -8,10 +8,16 @@ spring.datasource.password=
spring.datasource.username=sa
spring.jpa.hibernate.ddl-auto=none
-# Flyway for Database Setup and Migrations
+# Configuration for Database Setup and Migrations
+#if ($dbMigration == 'flyway')
spring.flyway.enabled=true
#if ($dbType == 'h2')
spring.flyway.locations=classpath:db/migration
#else
spring.flyway.locations=classpath:db/test
#end
+#end
+#if ($dbMigration == 'liquibase')
+spring.liquibase.enabled=true
+spring.liquibase.change-log=classpath:db/test/changelog-master.xml
+#end
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-master.xml b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-master.xml
new file mode 100644
index 00000000..7f0803cc
--- /dev/null
+++ b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-master.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-v1.0.xml b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-v1.0.xml
new file mode 100644
index 00000000..50b8cbdb
--- /dev/null
+++ b/templates/server/src/main/resources/archetype-resources/core/src/test/resources/db/test/changelog-v1.0.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/templates/server/src/test/resources/projects/basic/archetype.properties b/templates/server/src/test/resources/projects/basic/archetype.properties
index a7fbc297..784b1127 100644
--- a/templates/server/src/test/resources/projects/basic/archetype.properties
+++ b/templates/server/src/test/resources/projects/basic/archetype.properties
@@ -5,3 +5,9 @@ groupId=archetype.it
artifactId=basic
batch=.
dbType=h2
+#if($dbMigration == 'liquibase')
+dbMigration=liquibase
+#end
+#if($dbMigration == 'flyway')
+dbMigration=flyway
+#end
\ No newline at end of file
diff --git a/templates/server/src/test/resources/projects/batch/archetype.properties b/templates/server/src/test/resources/projects/batch/archetype.properties
index 2583e2cb..6da2f730 100644
--- a/templates/server/src/test/resources/projects/batch/archetype.properties
+++ b/templates/server/src/test/resources/projects/batch/archetype.properties
@@ -5,3 +5,9 @@ groupId=archetype.it
artifactId=app-with-batch
batch=batch
dbType=mysql
+#if($dbMigration == 'liquibase')
+dbMigration=liquibase
+#end
+#if($dbMigration == 'flyway')
+dbMigration=flyway
+#end
\ No newline at end of file
diff --git a/templates/server/src/test/resources/projects/enterprise/archetype.properties b/templates/server/src/test/resources/projects/enterprise/archetype.properties
index 65103edb..aebe1f5f 100644
--- a/templates/server/src/test/resources/projects/enterprise/archetype.properties
+++ b/templates/server/src/test/resources/projects/enterprise/archetype.properties
@@ -5,3 +5,9 @@ groupId=archetype.it
artifactId=enterprise
batch=.
dbType=postgresql
+#if($dbMigration == 'liquibase')
+dbMigration=liquibase
+#end
+#if($dbMigration == 'flyway')
+dbMigration=flyway
+#end
\ No newline at end of file