Liquibase liquibase-maven-plugin does not run Integration Tests in Apache Maven

Hi
 
I am using Liquibase. I want the database tables to be created before the Integration Tests. What I can see is that the Integration Tests are not being run and the liquibase-maven-plugin version 3.2.2 runs last in the build process of Apache Maven.
 
The code is located on GitHib: https://github.com/rajivj2/example2/
 
The EmployeeJpaDAOIT.java is the class that contains the test. All I want to do is have the tables created before the test actually starts.
 
Can you please help?

 

What Maven goal do you run to cause this problem? This sounds like a configuration problem. You have the Liquibase plugin set to run in the pre-integration-test phase which means you will need to specifically need to target the integration-test goal for it to fire.

This didn’t fire the Liquibase plugin: mvn test

This did fire the Liquibase plugin: mvn integration-test

Try using the integration-test goal.

I have run the mvn integration-test phase on the Command Prompt but still there are problems. It throws the following Exception:

 

Caused by: org.hibernate.HibernateException: Missing table: employee

 

I am specificing the following in the pom.xml:

 

  1. < plugins >
  2.   < plugin >

  3.   < groupId > org.apache.maven.plugins </ groupId >
  4.   

    < artifactId > maven -failsafe-plugin </ artifactId>

  1.    < version > 2.12.4 </ version >

  1. < configuration >

  2. < encoding > utf-8 </ encoding >

  3. </ configuration >

  4. < executions >

  5. < execution >

  6. < goals >

  7. < goal > integration-test </ goal >

  8. < goal > verify </ goal >

  9. </ goals >

  10. </ execution >

  11. </ executions >

  12. </ plugin >

  13. < plugin >

  14. < groupId > org.liquibase </ groupId >

  15. < artifactId > liquibase -maven-plugin </ artifactId >

  16. < version > 3.2.2 </ version >

  17. < configuration >

  18. < propertyFile > src/main/resources/server-internal2.properties </ propertyFile >

  19. < changeLogFile > src/main/resources/db-changelog-employee.xml </ changeLogFile >

  20. < promptOnNonLocalDatabase > false </ promptOnNonLocalDatabase >

  21. < logging > debug </ logging >

  22. </ configuration >

  23. < executions >

  24. < execution >

  25. < phase > pre -integration-test </ phase >

  26. < goals >

  27. < goal > update </ goal >

  28. </ goals >

  29. </ execution >

  30. </ executions >

  31. </ plugin >

The liquibase plugin is creating the tables but they can’t be found. What is wrong? Could you please look at the example project: https://github.com/rajivj2/example2/ on GitHub.

Since the Liquibase plugin is creating the tables, it sounds like you got the Liquibase part working. Not sure I can help you with your general project issues.

It doesn’t sound like a Hibernate issue to me. I have a hunch it is your HSQLDB settings. I bet the failsafe plugin forks the process and the HSQLDB in-memory database is shutting down as it is only available to the creating JVM process. I would try not forking the failsafe plugin if you can or switching to file or server mode on the HSQLDB database so the data is persisted between processes.

That being said, this is probably not the best place for general Java project setup questions.