Skip to content

Commit 195941c

Browse files
DavideDSanne
authored andcommitted
[#1686] Clean up bytecode-enhancements-it
1 parent 04bdaaa commit 195941c

File tree

4 files changed

+47
-58
lines changed

4 files changed

+47
-58
lines changed
Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
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+
116
description = 'Bytecode enhancements integration tests'
217

318
ext {
@@ -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
11599
tasks.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+
}

integration-tests/bytecode-enhancements-it/src/test/java/org/hibernate/reactive/it/BaseReactiveIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.vertx.core.Promise;
3333
import io.vertx.core.VertxOptions;
3434
import io.vertx.junit5.RunTestOnContext;
35-
import io.vertx.junit5.Timeout;
3635
import io.vertx.junit5.VertxExtension;
3736
import io.vertx.junit5.VertxTestContext;
3837
import jakarta.persistence.criteria.CriteriaQuery;
@@ -48,7 +47,6 @@
4847
*/
4948
@ExtendWith(VertxExtension.class)
5049
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
51-
@Timeout(value = 10, timeUnit = TimeUnit.MINUTES)
5250
public abstract class BaseReactiveIT {
5351

5452
// These properties are in DatabaseConfiguration in core

integration-tests/bytecode-enhancements-it/src/test/java/org/hibernate/reactive/it/LazyBasicFieldTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
import java.util.Collection;
99
import java.util.List;
10+
import java.util.concurrent.TimeUnit;
1011

1112
import org.junit.jupiter.api.Test;
1213

14+
import io.vertx.junit5.Timeout;
1315
import io.vertx.junit5.VertxTestContext;
1416

1517
import static org.assertj.core.api.Assertions.assertThat;
@@ -18,6 +20,7 @@
1820
* Test fetching of basic lazy fields when
1921
* bytecode enhancements is enabled.
2022
*/
23+
@Timeout(value = 10, timeUnit = TimeUnit.MINUTES)
2124
public class LazyBasicFieldTest extends BaseReactiveIT {
2225
@Override
2326
protected Collection<Class<?>> annotatedEntities() {

integration-tests/bytecode-enhancements-it/src/test/java/org/hibernate/reactive/it/LazyOneToOneBETest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
import java.util.Collection;
99
import java.util.List;
10+
import java.util.concurrent.TimeUnit;
1011

1112
import org.hibernate.reactive.it.lazytoone.Captain;
1213
import org.hibernate.reactive.it.lazytoone.Ship;
1314
import org.hibernate.reactive.mutiny.Mutiny;
1415

1516
import org.junit.jupiter.api.Test;
1617

18+
import io.vertx.junit5.Timeout;
1719
import io.vertx.junit5.VertxTestContext;
1820
import jakarta.persistence.metamodel.Attribute;
1921

@@ -22,6 +24,7 @@
2224
/**
2325
* Test bytecode enhancements on a lazy one-to-one bidirectional association
2426
*/
27+
@Timeout(value = 10, timeUnit = TimeUnit.MINUTES)
2528
public class LazyOneToOneBETest extends BaseReactiveIT {
2629

2730
@Override

0 commit comments

Comments
 (0)