Skip to content

Commit 2de3ac7

Browse files
blafondDavideD
authored andcommitted
[#1827] Replace DBSelectionExtension with java annotations
1 parent 2d47479 commit 2de3ac7

File tree

58 files changed

+248
-602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+248
-602
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomOneToOneStoredProcedureSqlTest.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,41 @@
55
*/
66
package org.hibernate.reactive;
77

8-
import io.vertx.junit5.Timeout;
9-
import io.vertx.junit5.VertxTestContext;
10-
import jakarta.persistence.*;
8+
import java.time.LocalDateTime;
9+
import java.util.Collection;
10+
import java.util.List;
1111

1212
import org.hibernate.HibernateException;
1313
import org.hibernate.annotations.SQLDelete;
1414
import org.hibernate.annotations.SQLInsert;
15-
import org.hibernate.reactive.testing.DBSelectionExtension;
1615
import org.hibernate.reactive.testing.ReactiveAssertions;
16+
import org.hibernate.reactive.annotations.EnabledFor;
1717

1818
import org.junit.jupiter.api.Assertions;
1919
import org.junit.jupiter.api.BeforeEach;
2020
import org.junit.jupiter.api.Test;
21-
import org.junit.jupiter.api.extension.RegisterExtension;
22-
23-
import java.time.LocalDateTime;
24-
import java.util.Collection;
25-
import java.util.List;
2621

27-
import static java.util.concurrent.TimeUnit.*;
22+
import io.vertx.junit5.Timeout;
23+
import io.vertx.junit5.VertxTestContext;
24+
import jakarta.persistence.Basic;
25+
import jakarta.persistence.Column;
26+
import jakarta.persistence.Entity;
27+
import jakarta.persistence.GeneratedValue;
28+
import jakarta.persistence.Id;
29+
import jakarta.persistence.JoinColumn;
30+
import jakarta.persistence.OneToOne;
31+
import jakarta.persistence.Table;
32+
33+
import static java.util.concurrent.TimeUnit.MINUTES;
2834
import static org.assertj.core.api.Assertions.assertThat;
29-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.*;
30-
import static org.hibernate.reactive.testing.DBSelectionExtension.*;
31-
import static org.junit.jupiter.api.Assertions.*;
35+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
36+
import static org.junit.jupiter.api.Assertions.assertEquals;
37+
import static org.junit.jupiter.api.Assertions.assertNotNull;
3238

3339
@Timeout(value = 10, timeUnit = MINUTES)
34-
40+
@EnabledFor(POSTGRESQL)
3541
public class CustomOneToOneStoredProcedureSqlTest extends BaseReactiveTest {
3642

37-
@RegisterExtension
38-
public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL );
3943
private IndividualPerson individualPerson;
4044
private DriverLicence driverLicence;
4145
private static final String INITIAL_LICENCE_NO = "12545KLI12";

hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomSqlTest.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
import org.hibernate.annotations.SQLDelete;
1313
import org.hibernate.annotations.SQLInsert;
1414
import org.hibernate.annotations.SQLUpdate;
15-
import org.hibernate.reactive.testing.DBSelectionExtension;
15+
import org.hibernate.reactive.annotations.EnabledFor;
1616

1717
import org.junit.jupiter.api.Test;
18-
import org.junit.jupiter.api.extension.RegisterExtension;
1918

2019
import io.vertx.junit5.Timeout;
2120
import io.vertx.junit5.VertxTestContext;
@@ -29,18 +28,15 @@
2928
import static java.util.concurrent.TimeUnit.MINUTES;
3029
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB;
3130
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
32-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
3331
import static org.junit.jupiter.api.Assertions.assertEquals;
3432
import static org.junit.jupiter.api.Assertions.assertNotNull;
3533
import static org.junit.jupiter.api.Assertions.assertNull;
3634

3735
@Timeout(value = 10, timeUnit = MINUTES)
38-
36+
@EnabledFor(POSTGRESQL)
37+
@EnabledFor(COCKROACHDB)
3938
public class CustomSqlTest extends BaseReactiveTest {
4039

41-
@RegisterExtension
42-
public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL, COCKROACHDB );
43-
4440
@Override
4541
protected Collection<Class<?>> annotatedEntities() {
4642
return List.of( Record.class );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomStoredProcedureSqlTest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
import org.hibernate.annotations.SQLDelete;
1414
import org.hibernate.annotations.SQLInsert;
1515
import org.hibernate.annotations.SQLUpdate;
16-
import org.hibernate.reactive.testing.DBSelectionExtension;
1716
import org.hibernate.reactive.testing.ReactiveAssertions;
17+
import org.hibernate.reactive.annotations.EnabledFor;
1818

1919
import org.junit.jupiter.api.Assertions;
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.extension.RegisterExtension;
2322

2423
import io.vertx.junit5.Timeout;
2524
import io.vertx.junit5.VertxTestContext;
@@ -33,18 +32,14 @@
3332
import static java.util.concurrent.TimeUnit.MINUTES;
3433
import static org.assertj.core.api.Assertions.assertThat;
3534
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
36-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
3735
import static org.junit.jupiter.api.Assertions.assertEquals;
3836
import static org.junit.jupiter.api.Assertions.assertNotNull;
3937
import static org.junit.jupiter.api.Assertions.assertNull;
4038

4139
@Timeout(value = 10, timeUnit = MINUTES)
42-
40+
@EnabledFor(POSTGRESQL)
4341
public class CustomStoredProcedureSqlTest extends BaseReactiveTest {
4442

45-
@RegisterExtension
46-
public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL );
47-
4843
private SimpleRecord theRecord;
4944

5045
private static final String INITIAL_TEXT = "blue suede shoes";

hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmptyCompositeCollectionKeyTest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
import org.hibernate.Hibernate;
1414
import org.hibernate.cfg.Configuration;
1515
import org.hibernate.cfg.Environment;
16-
import org.hibernate.reactive.testing.DBSelectionExtension;
16+
import org.hibernate.reactive.annotations.DisabledFor;
1717

1818
import org.junit.jupiter.api.Test;
19-
import org.junit.jupiter.api.extension.RegisterExtension;
2019

2120
import io.vertx.junit5.Timeout;
2221
import io.vertx.junit5.VertxTestContext;
@@ -28,19 +27,15 @@
2827

2928
import static java.util.concurrent.TimeUnit.MINUTES;
3029
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
31-
import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor;
3230
import static org.junit.jupiter.api.Assertions.assertFalse;
3331
import static org.junit.jupiter.api.Assertions.assertNotNull;
3432
import static org.junit.jupiter.api.Assertions.assertNull;
3533
import static org.junit.jupiter.api.Assertions.assertTrue;
3634

3735
@Timeout(value = 10, timeUnit = MINUTES)
36+
@DisabledFor( value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0" )
3837
public class EmptyCompositeCollectionKeyTest extends BaseReactiveTest {
3938

40-
// Db2: Throws java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. In JDBC we would normally block here but need to find a non-blocking solution
41-
@RegisterExtension
42-
public DBSelectionExtension dbSelection = skipTestsFor( DB2 );
43-
4439
@Override
4540
protected Collection<Class<?>> annotatedEntities() {
4641
return List.of( Family.class );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
1313
import org.hibernate.cfg.Configuration;
14-
import org.hibernate.reactive.testing.DBSelectionExtension;
1514
import org.hibernate.reactive.testing.SqlStatementTracker;
15+
import org.hibernate.reactive.annotations.EnabledFor;
1616

1717
import org.junit.jupiter.api.Test;
18-
import org.junit.jupiter.api.extension.RegisterExtension;
1918

2019
import io.vertx.junit5.Timeout;
2120
import io.vertx.junit5.VertxTestContext;
@@ -32,18 +31,14 @@
3231
import static java.util.concurrent.TimeUnit.MINUTES;
3332
import static org.assertj.core.api.Assertions.assertThat;
3433
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
35-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
3634

3735
/**
3836
* Test that's not necessary to do a fetch when we want to add a new element to an association.
3937
*/
4038
@Timeout(value = 10, timeUnit = MINUTES)
41-
39+
@EnabledFor(value = POSTGRESQL, reason = "We use native queries, they might be different for other DBs")
4240
public class FetchedAssociationTest extends BaseReactiveTest {
4341

44-
@RegisterExtension // We use native queries, they might be different for other DBs
45-
public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL );
46-
4742
private SqlStatementTracker sqlTracker;
4843

4944
@Override

hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterWithPaginationTest.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
import org.hibernate.annotations.ParamDef;
1616
import org.hibernate.reactive.mutiny.Mutiny;
1717
import org.hibernate.reactive.stage.Stage;
18-
import org.hibernate.reactive.testing.DBSelectionExtension;
18+
import org.hibernate.reactive.annotations.DisabledFor;
1919
import org.hibernate.type.descriptor.java.StringJavaType;
2020

2121
import org.junit.jupiter.api.BeforeEach;
2222
import org.junit.jupiter.api.Test;
23-
import org.junit.jupiter.api.extension.RegisterExtension;
2423

2524
import io.smallrye.mutiny.Uni;
2625
import io.vertx.junit5.Timeout;
@@ -36,19 +35,14 @@
3635
import static org.hibernate.query.Page.first;
3736
import static org.hibernate.query.Page.page;
3837
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
39-
import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor;
4038

4139
/**
4240
* Test the combination of filters, max results, first result, and {@link org.hibernate.query.Page}.
4341
*/
4442
@Timeout(value = 10, timeUnit = MINUTES)
45-
43+
@DisabledFor(value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0")
4644
public class FilterWithPaginationTest extends BaseReactiveTest {
4745

48-
// Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0
49-
@RegisterExtension
50-
public final DBSelectionExtension skip = skipTestsFor( DB2 );
51-
5246
FamousPerson margaret = new FamousPerson( 1L, "Margaret Howe Lovatt", Status.LIVING, "the woman who lived in a half-flooded home with a dolphin." );
5347
FamousPerson nellie = new FamousPerson( 2L, "Nellie Bly", Status.DECEASED, "In 1888, she traveled around the world in 72 days." );
5448
FamousPerson hedy = new FamousPerson( 3L, "Hedy Lamarr", Status.DECEASED, "Actress and co-inventor of an early version of frequency-hopping spread spectrum communication for torpedo guidance." );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/FormulaTest.java

-8
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
import java.util.List;
1111

1212
import org.hibernate.annotations.Formula;
13-
import org.hibernate.reactive.testing.DBSelectionExtension;
1413

1514
import org.junit.jupiter.api.Assertions;
1615
import org.junit.jupiter.api.Test;
17-
import org.junit.jupiter.api.extension.RegisterExtension;
1816

1917
import io.vertx.junit5.Timeout;
2018
import io.vertx.junit5.VertxTestContext;
@@ -25,16 +23,10 @@
2523
import jakarta.persistence.Table;
2624

2725
import static java.util.concurrent.TimeUnit.MINUTES;
28-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA;
29-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
3026

3127
@Timeout(value = 10, timeUnit = MINUTES)
32-
3328
public class FormulaTest extends BaseReactiveTest {
3429

35-
@RegisterExtension
36-
public DBSelectionExtension dbSelection = DBSelectionExtension.skipTestsFor( MARIA, MYSQL );
37-
3830
@Override
3931
protected Collection<Class<?>> annotatedEntities() {
4032
return List.of( Record.class );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyJoinedTableTest.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
import org.hibernate.annotations.GenerationTime;
1515
import org.hibernate.cfg.AvailableSettings;
1616
import org.hibernate.cfg.Configuration;
17-
import org.hibernate.reactive.testing.DBSelectionExtension;
17+
import org.hibernate.reactive.annotations.DisabledFor;
1818

1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.RegisterExtension;
2120

2221
import io.vertx.junit5.Timeout;
2322
import io.vertx.junit5.VertxTestContext;
@@ -32,10 +31,9 @@
3231
import jakarta.persistence.TemporalType;
3332

3433
import static java.util.concurrent.TimeUnit.MINUTES;
35-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB;
36-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
37-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
38-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
34+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
35+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
36+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
3937
import static org.junit.jupiter.api.Assertions.assertEquals;
4038
import static org.junit.jupiter.api.Assertions.assertNotNull;
4139
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -44,13 +42,9 @@
4442
* Test the @{@link Generated} annotation with {@link InheritanceType#JOINED}
4543
*/
4644
@Timeout(value = 10, timeUnit = MINUTES)
47-
45+
@DisabledFor(value = {SQLSERVER, ORACLE, DB2}, reason = "test uses SQL queries")
4846
public class GeneratedPropertyJoinedTableTest extends BaseReactiveTest {
4947

50-
// It requires native queries, so it won't work for every db
51-
@RegisterExtension
52-
public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL );
53-
5448
@Override
5549
protected Collection<Class<?>> annotatedEntities() {
5650
return List.of( GeneratedWithIdentity.class, GeneratedRegular.class );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertySingleTableTest.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
import org.hibernate.annotations.GenerationTime;
1515
import org.hibernate.cfg.AvailableSettings;
1616
import org.hibernate.cfg.Configuration;
17-
import org.hibernate.reactive.testing.DBSelectionExtension;
17+
import org.hibernate.reactive.annotations.DisabledFor;
1818

1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.RegisterExtension;
2120

2221
import io.vertx.junit5.Timeout;
2322
import io.vertx.junit5.VertxTestContext;
@@ -31,10 +30,9 @@
3130
import jakarta.persistence.TemporalType;
3231

3332
import static java.util.concurrent.TimeUnit.MINUTES;
34-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB;
35-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
36-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
37-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
33+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
34+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
35+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
3836
import static org.junit.jupiter.api.Assertions.assertEquals;
3937
import static org.junit.jupiter.api.Assertions.assertNotNull;
4038
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -43,13 +41,9 @@
4341
* Test the @{@link Generated} annotation
4442
*/
4543
@Timeout(value = 10, timeUnit = MINUTES)
46-
44+
@DisabledFor(value = {SQLSERVER, ORACLE, DB2}, reason = "test uses SQL queries")
4745
public class GeneratedPropertySingleTableTest extends BaseReactiveTest {
4846

49-
// It requires native queries, so it won't work for every db
50-
@RegisterExtension
51-
public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL );
52-
5347
@Override
5448
protected Collection<Class<?>> annotatedEntities() {
5549
return List.of( GeneratedWithIdentity.class, GeneratedRegular.class );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyUnionSubclassesTest.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
import org.hibernate.annotations.GenerationTime;
1515
import org.hibernate.cfg.AvailableSettings;
1616
import org.hibernate.cfg.Configuration;
17-
import org.hibernate.reactive.testing.DBSelectionExtension;
17+
import org.hibernate.reactive.annotations.DisabledFor;
1818

1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.RegisterExtension;
2120

2221
import io.vertx.junit5.Timeout;
2322
import io.vertx.junit5.VertxTestContext;
@@ -32,10 +31,9 @@
3231
import jakarta.persistence.TemporalType;
3332

3433
import static java.util.concurrent.TimeUnit.MINUTES;
35-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB;
36-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
37-
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
38-
import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor;
34+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
35+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
36+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
3937
import static org.junit.jupiter.api.Assertions.assertEquals;
4038
import static org.junit.jupiter.api.Assertions.assertNotNull;
4139
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -47,13 +45,9 @@
4745
* </p>
4846
*/
4947
@Timeout(value = 10, timeUnit = MINUTES)
50-
48+
@DisabledFor(value = {SQLSERVER, ORACLE, DB2}, reason = "test uses SQL queries")
5149
public class GeneratedPropertyUnionSubclassesTest extends BaseReactiveTest {
5250

53-
// It requires native queries, so it won't work for every db
54-
@RegisterExtension
55-
public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL );
56-
5751
@Override
5852
protected Collection<Class<?>> annotatedEntities() {
5953
return List.of( GeneratedRegular.class );

0 commit comments

Comments
 (0)