From 0ed39c7746fd2c2a91612243e11f87aebe8cac14 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Tue, 15 Mar 2016 18:23:53 +0200 Subject: [PATCH] Change hibernate.properties to take configurable environment settings --- build.gradle | 11 ++++++ databases.gradle | 34 +++++++++++++++++++ .../src/test/resources/hibernate.properties | 9 ++--- .../src/test/resources/hibernate.properties | 10 +++--- .../src/test/resources/hibernate.properties | 9 ++--- .../hibernate-entitymanager.gradle | 12 +++---- .../src/test/resources/hibernate.properties | 15 ++++---- .../src/test/resources/hibernate.properties | 9 ++--- .../src/test/resources/hibernate.properties | 9 ++--- .../src/test/resources/hibernate.properties | 10 +++--- .../src/test/resources/hibernate.properties | 9 ++--- .../src/test/resources/hibernate.properties | 9 ++--- .../src/test/resources/hibernate.properties | 9 ++--- libraries.gradle | 2 ++ 14 files changed, 104 insertions(+), 53 deletions(-) create mode 100644 databases.gradle diff --git a/build.gradle b/build.gradle index 56e6ac198a..a444754a7e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.apache.tools.ant.filters.ReplaceTokens + /* * Hibernate, Relational Persistence for Idiomatic Java * @@ -8,6 +10,7 @@ apply plugin: 'eclipse' apply plugin: 'idea' apply from: "./libraries.gradle" +apply from: "./databases.gradle" buildscript { @@ -136,6 +139,8 @@ subprojects { subProject -> testRuntime( libraries.log4j ) testRuntime( libraries.javassist ) testRuntime( libraries.h2 ) + testRuntime( libraries.hsqldb ) + testRuntime( libraries.postgresql ) testRuntime( libraries.woodstox ) // 6.6 gave me some NPE problems from within checkstyle... @@ -211,6 +216,12 @@ subprojects { subProject -> } into sourceSets.test.output.classesDir } + copy { + ext.targetDir = file( "${buildDir}/resources/test" ) + from file('src/test/resources') + into targetDir + filter( ReplaceTokens, tokens: dbBundle[db] ); + } } ) idea { diff --git a/databases.gradle b/databases.gradle new file mode 100644 index 0000000000..972dcbca75 --- /dev/null +++ b/databases.gradle @@ -0,0 +1,34 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +// build a map of the database settings to use. +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' + ] + ] +} diff --git a/hibernate-c3p0/src/test/resources/hibernate.properties b/hibernate-c3p0/src/test/resources/hibernate.properties index 1f8fc08760..332d78bd38 100644 --- a/hibernate-c3p0/src/test/resources/hibernate.properties +++ b/hibernate-c3p0/src/test/resources/hibernate.properties @@ -4,10 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 hibernate.c3p0.min_size 50 diff --git a/hibernate-core/src/test/resources/hibernate.properties b/hibernate-core/src/test/resources/hibernate.properties index 982c787b37..b67f40359d 100644 --- a/hibernate-core/src/test/resources/hibernate.properties +++ b/hibernate-core/src/test/resources/hibernate.properties @@ -5,11 +5,11 @@ # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 diff --git a/hibernate-ehcache/src/test/resources/hibernate.properties b/hibernate-ehcache/src/test/resources/hibernate.properties index 3672cce19a..a643fcdfae 100644 --- a/hibernate-ehcache/src/test/resources/hibernate.properties +++ b/hibernate-ehcache/src/test/resources/hibernate.properties @@ -4,10 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 diff --git a/hibernate-entitymanager/hibernate-entitymanager.gradle b/hibernate-entitymanager/hibernate-entitymanager.gradle index ad3011e416..6c8ccb6df2 100755 --- a/hibernate-entitymanager/hibernate-entitymanager.gradle +++ b/hibernate-entitymanager/hibernate-entitymanager.gradle @@ -93,14 +93,9 @@ task copyBundleResources (type: Copy) { ext.bundlesTargetDir = file( "${buildDir}/bundles" ) from file('src/test/bundles') into bundlesTargetDir - filter(ReplaceTokens, tokens: [ - buildDirName: buildDir.absolutePath, - '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', - ]); + ext.bundleTokens = dbBundle[db] + ext.bundleTokens["buildDirName"] = buildDir.absolutePath + filter(ReplaceTokens, tokens: bundleTokens); doFirst { bundlesTargetDir.mkdirs() } @@ -116,3 +111,4 @@ task testJar(type: Jar, dependsOn: testClasses) { artifacts { tests testJar } + diff --git a/hibernate-entitymanager/src/test/resources/hibernate.properties b/hibernate-entitymanager/src/test/resources/hibernate.properties index cda8dd0f91..c13ec45597 100644 --- a/hibernate-entitymanager/src/test/resources/hibernate.properties +++ b/hibernate-entitymanager/src/test/resources/hibernate.properties @@ -5,20 +5,21 @@ # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 -hibernate.show_sql true +hibernate.show_sql false hibernate.format_sql true + hibernate.max_fetch_depth 5 hibernate.cache.region_prefix hibernate.test hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory -hibernate.jdbc.batch_size 0 - hibernate.service.allow_crawling=false +hibernate.session.events.log=true \ No newline at end of file diff --git a/hibernate-envers/src/test/resources/hibernate.properties b/hibernate-envers/src/test/resources/hibernate.properties index c6ee0c2a51..f983fab1f4 100644 --- a/hibernate-envers/src/test/resources/hibernate.properties +++ b/hibernate-envers/src/test/resources/hibernate.properties @@ -4,10 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 diff --git a/hibernate-hikaricp/src/test/resources/hibernate.properties b/hibernate-hikaricp/src/test/resources/hibernate.properties index 35478a5520..6225215d97 100644 --- a/hibernate-hikaricp/src/test/resources/hibernate.properties +++ b/hibernate-hikaricp/src/test/resources/hibernate.properties @@ -4,10 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.jdbc.batch_size 10 hibernate.connection.provider_class HikariCPConnectionProvider diff --git a/hibernate-infinispan/src/test/resources/hibernate.properties b/hibernate-infinispan/src/test/resources/hibernate.properties index 64a4e4d5fb..b072964d63 100755 --- a/hibernate-infinispan/src/test/resources/hibernate.properties +++ b/hibernate-infinispan/src/test/resources/hibernate.properties @@ -4,11 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa -# hibernate.connection.password +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 diff --git a/hibernate-java8/src/test/resources/hibernate.properties b/hibernate-java8/src/test/resources/hibernate.properties index fecee9f733..b67f40359d 100644 --- a/hibernate-java8/src/test/resources/hibernate.properties +++ b/hibernate-java8/src/test/resources/hibernate.properties @@ -5,10 +5,11 @@ # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 diff --git a/hibernate-proxool/src/test/resources/hibernate.properties b/hibernate-proxool/src/test/resources/hibernate.properties index 5db1fd9654..8343ae53a4 100644 --- a/hibernate-proxool/src/test/resources/hibernate.properties +++ b/hibernate-proxool/src/test/resources/hibernate.properties @@ -4,10 +4,11 @@ # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ hibernate.connection.pool_size 5 hibernate.jdbc.batch_size 10 diff --git a/hibernate-spatial/src/test/resources/hibernate.properties b/hibernate-spatial/src/test/resources/hibernate.properties index 28817f6644..c1d5468370 100644 --- a/hibernate-spatial/src/test/resources/hibernate.properties +++ b/hibernate-spatial/src/test/resources/hibernate.properties @@ -13,10 +13,11 @@ hibernate.show_sql true hibernate.max_fetch_depth 5 -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE -hibernate.connection.username sa +hibernate.dialect @db.dialect@ +hibernate.connection.driver_class @jdbc.driver@ +hibernate.connection.url @jdbc.url@ +hibernate.connection.username @jdbc.user@ +hibernate.connection.password @jdbc.pass@ #hibernate.cache.region_prefix hibernate.test #hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory diff --git a/libraries.gradle b/libraries.gradle index e801429e39..e19168a214 100644 --- a/libraries.gradle +++ b/libraries.gradle @@ -83,7 +83,9 @@ ext { shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-beta-6', shrinkwrap: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-beta-6', h2: "com.h2database:h2:${h2Version}", + hsqldb: "org.hsqldb:hsqldb:2.3.2", derby: "org.apache.derby:derby:10.11.1.1", + postgresql: 'org.postgresql:postgresql:9.4-1202-jdbc41', jboss_jta: "org.jboss.jbossts:jbossjta:4.16.4.Final", xapool: "com.experlog:xapool:1.5.0", mockito: 'org.mockito:mockito-core:1.9.0',