This page is out of date: content has moved there.
Introduction
Previously, all hibernate modules were featuring a hibernate.properties file that was bound to H2 connection properties only.
To run tests on a different database, the hibernate-matrix-testing was required.
To allow running any test on any database, I created the following PR which I also integrated on master.
Running tests
In the hibernate-orm project root, there is a new configuration file called: databases.gradle which looks this:
ext {
db = 'h2'
dbBundle = [
h2 : [
'db.dialect' : 'org.hibernate.dialect.H2Dialect',
'jdbc.driver': 'org.h2.Driver',
'jdbc.user' : 'sa',
'jdbc.pass' : '',
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000',
],
hsqldb : [
'db.dialect' : 'org.hibernate.dialect.HSQLDialect',
'jdbc.driver': 'org.hsqldb.jdbc.JDBCDriver',
'jdbc.user' : 'sa',
'jdbc.pass' : '',
'jdbc.url' : 'jdbc:hsqldb:mem:test'
],
pgsql : [
'db.dialect' : 'org.hibernate.dialect.PostgreSQL94Dialect',
'jdbc.driver': 'org.postgresql.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:postgresql:hibernate_orm_test'
]
]
}
This is where we can add every database specific configuration properties. Having a new file, allows us to git-ignore it so that each developer can add its own local environment configuration properties.
By default, all tests are run against H2, and to switch to a different database (e.g. PostgreSQL) you can run the following Gradle command:
gradle clean test -Pdb=pgsql
Debugging
To debug a certain test in your favorite IDE, you could first run the following command:
gradle clean testClasses -Pdb=pgsql
This command will generate the target/resources/test/hibernate.properties configuration file with the right configuration properties taken from the databases.gradle file.
Then you can just
Comments