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
+
1
16
description = ' Bytecode enhancements integration tests'
2
17
3
18
ext {
@@ -13,16 +28,13 @@ dependencies {
13
28
14
29
// Testing on one database should be enough
15
30
runtimeOnly " io.vertx:vertx-pg-client:${ vertxVersion} "
31
+
16
32
// Allow authentication to PostgreSQL using SCRAM:
17
33
runtimeOnly ' com.ongres.scram:client:2.1'
18
34
19
35
// logging
20
36
runtimeOnly " org.apache.logging.log4j:log4j-core:${ log4jVersion} "
21
37
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
-
26
38
// Testcontainers
27
39
testImplementation " org.testcontainers:postgresql:${ testcontainersVersion} "
28
40
@@ -31,34 +43,8 @@ dependencies {
31
43
testImplementation " io.vertx:vertx-junit5:${ vertxVersion} "
32
44
}
33
45
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 }
62
48
63
49
// Print a summary of the results of the tests (number of failures, successes and skipped)
64
50
// This is the same as the one in hibernate-reactive-core
@@ -70,10 +56,24 @@ def loggingSummary(db, result, desc) {
70
56
}
71
57
}
72
58
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
+
73
73
// 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 {
76
75
defaultCharacterEncoding = " UTF-8"
76
+ useJUnitPlatform()
77
77
testLogging {
78
78
displayGranularity 1
79
79
showStandardStreams = project. hasProperty(' showStandardOutput' )
@@ -87,45 +87,30 @@ tasks.withType(Test) {
87
87
if ( project. hasProperty( ' includeTests' ) ) {
88
88
// Example: ./gradlew testAll -PincludeTests=DefaultPortTest
89
89
filter {
90
- includeTestsMatching project. getProperty( ' includeTests' ) ?: ' *'
90
+ includeTestsMatching project. properties[ ' includeTests' ] ?: ' *' as String
91
91
}
92
92
}
93
93
}
94
94
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
-
111
95
// Rule to recognize calls to testDb<dbName>
112
96
// and run the tests on the selected db
113
97
// Example:
114
98
// gradle testDbMySQL testDbDB2
115
99
tasks. addRule( " Pattern testDb<id>" ) { String taskName ->
116
100
if ( taskName. startsWith( " testDb" ) ) {
117
- task( type : Test , taskName ) {
101
+ tasks . register( taskName, Test ) {
118
102
def dbName = taskName. substring( " testDb" . length() )
119
103
description = " Run tests for ${ dbName} "
120
104
121
105
// We only want to test this on Postgres
122
106
onlyIf { dbName. toLowerCase(). startsWith( ' p' ) }
123
- afterSuite { desc , result ->
124
- loggingSummary( dbName, result, desc )
125
- }
126
107
doFirst() {
127
108
systemProperty ' db' , dbName
128
109
}
110
+ afterSuite { desc , result ->
111
+ loggingSummary( dbName, result, desc )
112
+ }
113
+
129
114
}
130
115
}
131
- }
116
+ }
0 commit comments