1+ buildscript {
2+ repositories {
3+ // Example: ./gradlew build -PenableMavenLocalRepo
4+ if ( project. hasProperty( ' enableMavenLocalRepo' ) ) {
5+ // Useful for local development, it should be disabled otherwise
6+ mavenLocal()
7+ }
8+ mavenCentral()
9+ }
10+ }
11+
12+ plugins {
13+ id " org.hibernate.orm" version " ${ hibernateOrmGradlePluginVersion} "
14+ }
15+
116description = ' Bytecode enhancements integration tests'
217
318ext {
@@ -13,16 +28,13 @@ dependencies {
1328
1429 // Testing on one database should be enough
1530 runtimeOnly " io.vertx:vertx-pg-client:${ vertxVersion} "
31+
1632 // Allow authentication to PostgreSQL using SCRAM:
1733 runtimeOnly ' com.ongres.scram:client:2.1'
1834
1935 // logging
2036 runtimeOnly " org.apache.logging.log4j:log4j-core:${ log4jVersion} "
2137
22- // JUnit5
23- testImplementation ' org.junit.jupiter:junit-jupiter-api:5.8.1'
24- testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.8.1'
25-
2638 // Testcontainers
2739 testImplementation " org.testcontainers:postgresql:${ testcontainersVersion} "
2840
@@ -31,34 +43,8 @@ dependencies {
3143 testImplementation " io.vertx:vertx-junit5:${ vertxVersion} "
3244}
3345
34- buildscript {
35- repositories {
36- // Example: ./gradlew build -PenableMavenLocalRepo
37- if ( project. hasProperty( ' enableMavenLocalRepo' ) ) {
38- // Useful for local development, it should be disabled otherwise
39- mavenLocal()
40- }
41- maven {
42- url ' https://plugins.gradle.org/m2/'
43- }
44- mavenCentral()
45- }
46- dependencies {
47- classpath " org.hibernate.orm:hibernate-gradle-plugin:${ hibernateOrmGradlePluginVersion} "
48- }
49- }
50-
51-
52- // Hibernate Gradle plugin to enable bytecode enhancements
53- apply plugin : ' org.hibernate.orm'
54-
55- hibernate {
56- enhancement {
57- lazyInitialization(true )
58- dirtyTracking(true )
59- associationManagement(false )
60- }
61- }
46+ // Optional: enable the bytecode enhancements
47+ hibernate { enhancement }
6248
6349// Print a summary of the results of the tests (number of failures, successes and skipped)
6450// This is the same as the one in hibernate-reactive-core
@@ -70,10 +56,24 @@ def loggingSummary(db, result, desc) {
7056 }
7157}
7258
59+ // Example:
60+ // gradle test -Pdb=MySQL
61+ test {
62+ def selectedDb = project. hasProperty( ' db' )
63+ ? project. properties[' db' ]
64+ : ' PostgreSQL'
65+ doFirst {
66+ systemProperty ' db' , selectedDb
67+ }
68+ afterSuite { desc , result ->
69+ loggingSummary( selectedDb, result, desc )
70+ }
71+ }
72+
7373// Configuration for the tests
74- // This is the same as the one in hibernate-reactive-core
75- tasks. withType(Test ) {
74+ tasks. withType( Test ). configureEach {
7675 defaultCharacterEncoding = " UTF-8"
76+ useJUnitPlatform()
7777 testLogging {
7878 displayGranularity 1
7979 showStandardStreams = project. hasProperty(' showStandardOutput' )
@@ -87,45 +87,30 @@ tasks.withType(Test) {
8787 if ( project. hasProperty( ' includeTests' ) ) {
8888 // Example: ./gradlew testAll -PincludeTests=DefaultPortTest
8989 filter {
90- includeTestsMatching project. getProperty( ' includeTests' ) ?: ' *'
90+ includeTestsMatching project. properties[ ' includeTests' ] ?: ' *' as String
9191 }
9292 }
9393}
9494
95- test {
96- useJUnitPlatform()
97- def selectedDb = project. hasProperty( ' db' )
98- ? project. getProperty( ' db' )
99- : ' PostgreSQL'
100-
101- // We only want to test this on Postgres
102- onlyIf { selectedDb. toLowerCase(). startsWith( ' p' ) }
103- afterSuite { desc , result ->
104- loggingSummary( ' PostgreSQL' , result, desc )
105- }
106- doFirst {
107- systemProperty ' db' , selectedDb
108- }
109- }
110-
11195// Rule to recognize calls to testDb<dbName>
11296// and run the tests on the selected db
11397// Example:
11498// gradle testDbMySQL testDbDB2
11599tasks. addRule( " Pattern testDb<id>" ) { String taskName ->
116100 if ( taskName. startsWith( " testDb" ) ) {
117- task( type : Test , taskName ) {
101+ tasks . register( taskName, Test ) {
118102 def dbName = taskName. substring( " testDb" . length() )
119103 description = " Run tests for ${ dbName} "
120104
121105 // We only want to test this on Postgres
122106 onlyIf { dbName. toLowerCase(). startsWith( ' p' ) }
123- afterSuite { desc , result ->
124- loggingSummary( dbName, result, desc )
125- }
126107 doFirst() {
127108 systemProperty ' db' , dbName
128109 }
110+ afterSuite { desc , result ->
111+ loggingSummary( dbName, result, desc )
112+ }
113+
129114 }
130115 }
131- }
116+ }
0 commit comments