1
1
package org .hibernate .reactive .env ;
2
2
3
- import org .gradle .api .tasks .CacheableTask ;
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+
4
6
import org .gradle .api .tasks .Input ;
5
7
import org .gradle .api .tasks .Optional ;
6
8
import org .gradle .api .tasks .testing .Test ;
7
9
import org .gradle .api .tasks .testing .TestDescriptor ;
10
+ import org .gradle .api .tasks .testing .TestListener ;
8
11
import org .gradle .api .tasks .testing .TestResult ;
9
12
10
- import groovy .lang .Closure ;
11
13
import org .jetbrains .annotations .NotNull ;
12
14
import org .jetbrains .annotations .Nullable ;
13
15
14
- @ CacheableTask
15
16
public abstract class TestDbTask extends Test {
16
17
17
18
@ NotNull
@@ -61,6 +62,14 @@ public void setShowStandardStreams(boolean showStandardStreams) {
61
62
this .showStandardStreams = showStandardStreams ;
62
63
}
63
64
65
+ @ Input
66
+ public Map <String , String > getCustomSystemProperties () {
67
+ final Map <String , String > props = new HashMap <>();
68
+ props .put ("db" , dbName );
69
+ props .put ("docker" , dockerEnabled ? "true" : "false" );
70
+ return props ;
71
+ }
72
+
64
73
public TestDbTask () {
65
74
// Default logging configuration
66
75
setDefaultCharacterEncoding ( "UTF-8" );
@@ -75,20 +84,35 @@ public TestDbTask() {
75
84
// enforcing Hibernate internal state
76
85
systemProperty ( "org.hibernate.reactive.common.InternalStateAssertions.ENFORCE" , "true" );
77
86
78
- // Add afterSuite hook
79
- afterSuite ( new Closure <Object >( this , this ) {
80
- public Object doCall (TestDescriptor desc , TestResult result ) {
81
- logSummary ( desc , result );
82
- return null ;
87
+ addTestListener ( new TestListener () {
88
+
89
+ @ Override
90
+ public void beforeSuite (TestDescriptor suite ) {
91
+ /* Do nothing */
92
+ }
93
+
94
+ // Add afterSuite hook
95
+ @ Override
96
+ public void afterSuite (TestDescriptor suite , TestResult result ) {
97
+ logSummary ( suite , result );
98
+ }
99
+
100
+ @ Override
101
+ public void beforeTest (TestDescriptor testDescriptor ) {
102
+ /* Do nothing */
103
+ }
104
+
105
+ @ Override
106
+ public void afterTest (TestDescriptor testDescriptor , TestResult result ) {
107
+ /* Do nothing */
83
108
}
84
109
} );
85
110
}
86
111
87
112
@ Override
88
113
public void executeTests () {
89
114
// Apply system properties before running
90
- systemProperty ( "db" , dbName );
91
- systemProperty ( "docker" , dockerEnabled ? "true" : "false" );
115
+ getCustomSystemProperties ().forEach (this ::systemProperty );
92
116
getTestLogging ().setShowStandardStreams ( showStandardStreams );
93
117
94
118
if ( includeTests != null && !includeTests .isEmpty () ) {
0 commit comments