Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/liquibase configuration #340

Draft
wants to merge 65 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0bc6d9f
devon4j mannual correction
dixyushi Dec 1, 2020
2f66b73
fixed casesc -> cases
hohwille Dec 4, 2020
31b8375
Merge branch 'develop' into develop
hohwille Dec 4, 2020
50ec86c
Merge remote-tracking branch 'upstream/master' into master
dixyushi Jan 27, 2021
899e978
changed configuration of flyway into liquibase
dixyushi Feb 5, 2021
7023dc6
added both flyway and liquibase configuration
dixyushi Feb 15, 2021
27adf36
Merge remote-tracking branch 'upstream/master' into master
Mar 26, 2021
805b5ea
Merge remote-tracking branch 'upstream/master' into master
Apr 7, 2021
2005578
Merge remote-tracking branch 'upstream/master' into master
Apr 8, 2021
94b38ab
Merge branch 'master' of https://github.com/dixyushi/devon4j into master
Apr 8, 2021
c2ba0aa
Merge remote-tracking branch 'upstream/master' into master
Apr 12, 2021
1c9b7f8
resolved testcleanerplugin issue
Apr 12, 2021
2a797ae
resolved conflicts
Apr 13, 2021
af85a10
Merge remote-tracking branch 'upstream/master' into master
Apr 13, 2021
96ce077
Merge branch 'master' into feature/liquibase-configuration
dixyushi Apr 14, 2021
32ba73d
Merge branch 'master' into feature/liquibase-configuration
hohwille Apr 16, 2021
b461dfb
added conditions for dbMigration in testDBConfig
Apr 20, 2021
2f14c02
merged conflicts solved
May 11, 2021
13de274
Merge remote-tracking branch 'upstream/master' into master
May 11, 2021
8f704fd
All required configurations and changes are done to implement
May 19, 2021
42ad82e
Merge branch 'master' into feature/liquibase-configuration
dixyushi May 19, 2021
db79005
fixed review comments
May 20, 2021
163ebe9
Merge branch 'feature/liquibase-configuration' of https://github.com/…
May 20, 2021
cae564a
Update pom.xml
dixyushi May 20, 2021
e49273e
fixed the existing error of SpringBatchIntegrationTes file
May 20, 2021
6e2eb69
fixed merged conflicts
May 20, 2021
b2f1dd8
Code after review comments implementation
May 21, 2021
ee7f6a5
Update TestWebSecurityConfig.java
dixyushi May 21, 2021
d2d0e0e
fixed review comments
May 24, 2021
80641d8
Implemented review comments
May 31, 2021
7610cb1
fixed indendation
hohwille May 31, 2021
cd8291b
fixed indendation
hohwille May 31, 2021
a6d3fea
Merge branch 'devonfw:master' into master
dixyushi Jun 1, 2021
47ef2ec
Merge branch 'master' into feature/liquibase-configuration
Jun 2, 2021
5afd20a
handled DatabaseException
Jun 2, 2021
ea8dd24
fixed merge conflicts
Jun 2, 2021
9e0f3fa
changed configuration of flyway into liquibase
dixyushi Feb 5, 2021
a46fad1
added both flyway and liquibase configuration
dixyushi Feb 15, 2021
77f0161
resolved testcleanerplugin issue
Apr 12, 2021
49a7d71
resolved conflicts
Apr 13, 2021
50c91ae
added conditions for dbMigration in testDBConfig
Apr 20, 2021
8233899
All required configurations and changes are done to implement
May 19, 2021
3b9d0ea
fixed review comments
May 20, 2021
9a4b7a1
fixed the existing error of SpringBatchIntegrationTes file
May 20, 2021
c17e4f3
Update pom.xml
dixyushi May 20, 2021
89c23b8
Update TestWebSecurityConfig.java
dixyushi May 21, 2021
4042d7a
fixed review comments
May 24, 2021
246a4d7
Implemented review comments
May 31, 2021
8bfb77f
handled DatabaseException
Jun 2, 2021
2f6f5fe
fixed merging conflicts
Jun 2, 2021
7014b49
resolved syncing issue with master
Jun 2, 2021
679b970
removed commented code
dixyushi Jun 2, 2021
f850517
Cleared the formatting
dixyushi Jun 2, 2021
6c39c54
Cleared the formatting
dixyushi Jun 2, 2021
3d50fe3
removed EAR as a key and cleared the formatting
Jun 2, 2021
9ba5ef5
Merge branch 'feature/liquibase-configuration' of https://github.com/…
Jun 2, 2021
4540198
modified Groovy scripts
Jun 3, 2021
b29c704
removed commented code from Groovy
Jun 4, 2021
dc54073
rearranged as per review comment
dixyushi Jun 4, 2021
dabd4c8
after rethrowing the error-fixed error handling
Jun 7, 2021
bab5a5f
fixed runtime exception and Added proper injects
Jun 8, 2021
e00c2e7
review comment-minor change on Qualifier implemented
Jun 10, 2021
5ef5923
Fixed Liquibase bean configuration Issue
Jun 14, 2021
ee9318b
removed DbTest which is not required
Jun 14, 2021
06ea818
Merge branch 'master' into feature/liquibase-configuration
hohwille Jun 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/test-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.devonfw.module.test.common.base.clean;

import javax.inject.Inject;
import liquibase.Liquibase;

/**
* @author ayudixit
*
*/
hohwille marked this conversation as resolved.
Show resolved Hide resolved
public class TestCleanerPluginLiquibase implements TestCleanerPlugin {

@Inject
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 (Exception e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never use printStackTrace() in productive code. IMHO better than logging is to rethrow as runtime exception and let the test fail instead of silently ignoring a severe error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to rethrow this exception

}

}

}
1 change: 1 addition & 0 deletions modules/test/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- Minimize infrastructure debug logs -->
<logger name="com.github.dozermapper" level="INFO"/>
<logger name="org.flywaydb" level="INFO"/>
<logger name="liquibase.Liquibase" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="org.hibernate" level="INFO"/>
<logger name="kafka" level="WARN"/>
Expand Down
140 changes: 73 additions & 67 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,67 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.devonfw</groupId>
<artifactId>maven-parent</artifactId>
<version>6</version>
</parent>
<groupId>com.devonfw.java.dev</groupId>
<artifactId>devon4j</artifactId>
<version>dev-SNAPSHOT</version> <!-- This POM will never be released -->
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Java stack of devonfw.com (devon4j): develop Java apps standardized, faster and with less risk.</description>
<inceptionYear>2014</inceptionYear>

<modules>
<module>boms</module>
<module>modules</module>
<module>starters</module>
<module>templates</module>
<module>documentation</module>
</modules>

<properties>
<revision>dev-SNAPSHOT</revision>
<github.repository>devon4j</github.repository>
<devon4j.version>${revision}</devon4j.version>
<spring.boot.version>2.4.4</spring.boot.version>
<!-- Spring boot and spring cloud version has to match -->
<spring.cloud.dependencies.version>2020.0.0</spring.cloud.dependencies.version>
<jackson.version>2.12.2</jackson.version> <!-- Overriding Jackson for fixing vulnerabilities -->
<guava.version>30.1.1-jre</guava.version>
<junit.version>5.7.1</junit.version>
<cxf.version>3.4.3</cxf.version>
<mmm.util.version>8.7.0</mmm.util.version>
<slf4j.version>1.7.30</slf4j.version>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>devonfw</sonar.organization>
</properties>

<build>
<plugins>

<!-- avoid version in local war files, exclude development properties from WARs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/classes/config/application.properties,*.jsp</packagingExcludes>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>

</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what has been changed here?
The diff shows every line has changed. EOL stlye changed between unix and linux?
The only content change I can see here is that you added standalone="no". What was the reason for that change? I can not see any...

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.devonfw</groupId>
<artifactId>maven-parent</artifactId>
<version>6</version>
</parent>

<groupId>com.devonfw.java.dev</groupId>
<artifactId>devon4j</artifactId>
<version>dev-SNAPSHOT</version>

<!-- This POM will never be released -->
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Java stack of devonfw.com (devon4j): develop Java apps standardized, faster and with less risk.</description>

<inceptionYear>2014</inceptionYear>

<modules>
<module>boms</module>
<module>modules</module>
<module>starters</module>
<module>templates</module>
<module>documentation</module>
</modules>

<properties>
<revision>dev-SNAPSHOT</revision>
<github.repository>devon4j</github.repository>
<devon4j.version>${revision}</devon4j.version>
<spring.boot.version>2.4.4</spring.boot.version>
<!-- Spring boot and spring cloud version has to match -->
<spring.cloud.dependencies.version>2020.0.0</spring.cloud.dependencies.version>
<jackson.version>2.12.2</jackson.version>
<!-- Overriding Jackson for fixing vulnerabilities -->
<guava.version>30.1.1-jre</guava.version>
<junit.version>5.7.1</junit.version>
<cxf.version>3.4.3</cxf.version>
<mmm.util.version>8.7.0</mmm.util.version>
<slf4j.version>1.7.30</slf4j.version>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>devonfw</sonar.organization>
</properties>

<build>
<plugins>
<!-- avoid version in local war files, exclude development properties from WARs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/classes/config/application.properties,*.jsp</packagingExcludes>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
38 changes: 19 additions & 19 deletions templates/pom.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.devonfw.java.dev</groupId>
<artifactId>devon4j</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>devon4j-templates</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Templates (maven archetypes) of devon4j.</description>

<modules>
<module>server</module>
</modules>

</project>
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here? No change at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review it again and restore the file if changes not required

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.devonfw.java.dev</groupId>
<artifactId>devon4j</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>devon4j-templates</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Templates (maven archetypes) of devon4j.</description>
<modules>
<module>server</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<defaultValue>h2</defaultValue>
<!-- <validationRegex>h2|postgresql|mysql|mariadb|oracle|hana|db2</validationRegex> -->
</requiredProperty>
<requiredProperty key="dbMigration">
<defaultValue>flyway</defaultValue>
<!-- <validationRegex>flyway|liquibase</validationRegex> -->
</requiredProperty>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented code.

<requiredProperty key="batch">
<defaultValue>.</defaultValue>
<validationRegex>batch|[.]</validationRegex>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again the diff is not readable. IMHO you have a general problem with your setup of git and are changing all EOLs accidentally. Can you please change and fix this?

Copy link
Contributor Author

@dixyushi dixyushi May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this setup issue and will make it work.


import javax.inject.Inject;
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;
#if ($dbMigration == 'liquibase')
import liquibase.Liquibase;
#else
import org.flywaydb.core.Flyway;
#end

hohwille marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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;

#if ($dbMigration == 'liquibase')
@Inject
private Liquibase liquibase;
#else
@Inject
private Flyway flyway;
#end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indendation with velocity is tricky: every whitespace will be written to the output. That is " " before the #if as well as " " before @Inject resulting in 6 spaces before annotation and 4 spaces before private field whereas we should only have two spaces each.
BTW: I am wondering why we do not use the TestCleanerPlugin in this test to abstract from liquibase of flyway instead...


#if ($dbMigration == 'liquibase')
@Override
protected void doSetUp() {
super.doSetUp();
try {
this.liquibase.dropAll();
} catch (Exception e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see TestCleanerPluginLiquibase. IMHO we can avoid all this redundancy and velocity macro complexity by injecting and using TestCleanerPlugin.

}
}
#else
@Override
protected void doSetUp() {

super.doSetUp();
this.flyway.clean();
this.flyway.migrate();
}
#end


@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;
}
}
Loading