diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomOneToOneStoredProcedureSqlTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomOneToOneStoredProcedureSqlTest.java index 451c95fee..df5dbbf7a 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomOneToOneStoredProcedureSqlTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomOneToOneStoredProcedureSqlTest.java @@ -5,37 +5,41 @@ */ package org.hibernate.reactive; -import io.vertx.junit5.Timeout; -import io.vertx.junit5.VertxTestContext; -import jakarta.persistence.*; +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; import org.hibernate.HibernateException; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.ReactiveAssertions; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import static java.util.concurrent.TimeUnit.*; +import io.vertx.junit5.Timeout; +import io.vertx.junit5.VertxTestContext; +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; + +import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.*; -import static org.hibernate.reactive.testing.DBSelectionExtension.*; -import static org.junit.jupiter.api.Assertions.*; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(POSTGRESQL) public class CustomOneToOneStoredProcedureSqlTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); private IndividualPerson individualPerson; private DriverLicence driverLicence; private static final String INITIAL_LICENCE_NO = "12545KLI12"; diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomSqlTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomSqlTest.java index bf6806253..6d95113d1 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomSqlTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomSqlTest.java @@ -12,10 +12,9 @@ import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,18 +28,15 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(POSTGRESQL) +@EnableFor(COCKROACHDB) public class CustomSqlTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL, COCKROACHDB ); - @Override protected Collection> annotatedEntities() { return List.of( Record.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomStoredProcedureSqlTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomStoredProcedureSqlTest.java index 512b23dda..19c7f3377 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomStoredProcedureSqlTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CustomStoredProcedureSqlTest.java @@ -13,13 +13,12 @@ import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.ReactiveAssertions; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -33,18 +32,14 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(POSTGRESQL) public class CustomStoredProcedureSqlTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); - private SimpleRecord theRecord; private static final String INITIAL_TEXT = "blue suede shoes"; diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmptyCompositeCollectionKeyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmptyCompositeCollectionKeyTest.java index fe5b007f6..e31c96daf 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmptyCompositeCollectionKeyTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmptyCompositeCollectionKeyTest.java @@ -13,10 +13,9 @@ import org.hibernate.Hibernate; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -28,19 +27,15 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor( value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0" ) public class EmptyCompositeCollectionKeyTest extends BaseReactiveTest { - // 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 - @RegisterExtension - public DBSelectionExtension dbSelection = skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Family.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java index 87e264ff5..ae65b39f5 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java @@ -11,11 +11,10 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -32,18 +31,14 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; /** * Test that's not necessary to do a fetch when we want to add a new element to an association. */ @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(value = POSTGRESQL, reason = "We use native queries, they might be different for other DBs") public class FetchedAssociationTest extends BaseReactiveTest { - @RegisterExtension // We use native queries, they might be different for other DBs - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); - private SqlStatementTracker sqlTracker; @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterWithPaginationTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterWithPaginationTest.java index 6ba86662d..c90a96678 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterWithPaginationTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterWithPaginationTest.java @@ -15,12 +15,11 @@ import org.hibernate.annotations.ParamDef; import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.stage.Stage; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.hibernate.type.descriptor.java.StringJavaType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.smallrye.mutiny.Uni; import io.vertx.junit5.Timeout; @@ -36,19 +35,14 @@ import static org.hibernate.query.Page.first; import static org.hibernate.query.Page.page; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; /** * Test the combination of filters, max results, first result, and {@link org.hibernate.query.Page}. */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0") public class FilterWithPaginationTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = skipTestsFor( DB2 ); - FamousPerson margaret = new FamousPerson( 1L, "Margaret Howe Lovatt", Status.LIVING, "the woman who lived in a half-flooded home with a dolphin." ); FamousPerson nellie = new FamousPerson( 2L, "Nellie Bly", Status.DECEASED, "In 1888, she traveled around the world in 72 days." ); 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." ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FormulaTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FormulaTest.java index 202c322b5..64b5ca098 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FormulaTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FormulaTest.java @@ -10,11 +10,9 @@ import java.util.List; import org.hibernate.annotations.Formula; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -25,16 +23,10 @@ import jakarta.persistence.Table; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; @Timeout(value = 10, timeUnit = MINUTES) - public class FormulaTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbSelection = DBSelectionExtension.skipTestsFor( MARIA, MYSQL ); - @Override protected Collection> annotatedEntities() { return List.of( Record.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyJoinedTableTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyJoinedTableTest.java index ec4c20840..517dd4692 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyJoinedTableTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyJoinedTableTest.java @@ -14,10 +14,9 @@ import org.hibernate.annotations.GenerationTime; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -32,10 +31,9 @@ import jakarta.persistence.TemporalType; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -44,13 +42,11 @@ * Test the @{@link Generated} annotation with {@link InheritanceType#JOINED} */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = SQLSERVER, reason = "Will fail because custom native queries would be required") +@DisableFor(value = ORACLE, reason = "Will fail because custom native queries would be required") +@DisableFor(value = DB2, reason = "Will fail because custom native queries would be required") public class GeneratedPropertyJoinedTableTest extends BaseReactiveTest { - // It requires native queries, so it won't work for every db - @RegisterExtension - public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL ); - @Override protected Collection> annotatedEntities() { return List.of( GeneratedWithIdentity.class, GeneratedRegular.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertySingleTableTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertySingleTableTest.java index ee64c2aab..00c1e4e24 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertySingleTableTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertySingleTableTest.java @@ -14,10 +14,9 @@ import org.hibernate.annotations.GenerationTime; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -31,10 +30,9 @@ import jakarta.persistence.TemporalType; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -43,13 +41,11 @@ * Test the @{@link Generated} annotation */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = SQLSERVER, reason = "Will fail because custom native queries would be required") +@DisableFor(value = ORACLE, reason = "Will fail because custom native queries would be required") +@DisableFor(value = DB2, reason = "Will fail because custom native queries would be required") public class GeneratedPropertySingleTableTest extends BaseReactiveTest { - // It requires native queries, so it won't work for every db - @RegisterExtension - public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL ); - @Override protected Collection> annotatedEntities() { return List.of( GeneratedWithIdentity.class, GeneratedRegular.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyUnionSubclassesTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyUnionSubclassesTest.java index fe9c6b455..6171d0ff5 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyUnionSubclassesTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/GeneratedPropertyUnionSubclassesTest.java @@ -14,10 +14,9 @@ import org.hibernate.annotations.GenerationTime; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -32,10 +31,9 @@ import jakarta.persistence.TemporalType; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -47,13 +45,11 @@ *

*/ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = SQLSERVER, reason = "Will fail because custom native queries would be required") +@DisableFor(value = ORACLE, reason = "Will fail because custom native queries would be required") +@DisableFor(value = DB2, reason = "Will fail because custom native queries would be required") public class GeneratedPropertyUnionSubclassesTest extends BaseReactiveTest { - // It requires native queries, so it won't work for every db - @RegisterExtension - public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL, COCKROACHDB, MYSQL ); - @Override protected Collection> annotatedEntities() { return List.of( GeneratedRegular.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java index 7e4871ece..41059733d 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java @@ -9,11 +9,10 @@ import java.util.List; import java.util.Objects; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -24,7 +23,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -32,13 +30,9 @@ * as defined by the JPA specification, along with limit parameters */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Different exceptions for the existing tests") public class HQLQueryParameterNamedLimitTest extends BaseReactiveTest { - // Db2:java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. - @RegisterExtension - public DBSelectionExtension skip = skipTestsFor( DB2 ); - Flour spelt = new Flour( 1, "Spelt", "An ancient grain, is a hexaploid species of wheat.", "Wheat flour" ); Flour rye = new Flour( 2, "Rye", "Used to bake the traditional sourdough breads of Germany.", "Wheat flour" ); Flour almond = new Flour( 3, "Almond", "made from ground almonds.", "Gluten free" ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java index af24ec69f..67e4f4971 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java @@ -9,11 +9,10 @@ import java.util.List; import java.util.Objects; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -24,7 +23,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -35,13 +33,8 @@ * that should be considered an internal implementation detail. */ @Timeout(value = 10, timeUnit = MINUTES) - public class HQLQueryParameterPositionalLimitTest extends BaseReactiveTest { - // Db2: java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. - @RegisterExtension - public DBSelectionExtension skip = skipTestsFor( DB2 ); - Flour spelt = new Flour( 1, "Spelt", "An ancient grain, is a hexaploid species of wheat.", "Wheat flour" ); Flour rye = new Flour( 2, "Rye", "Used to bake the traditional sourdough breads of Germany.", "Wheat flour" ); Flour almond = new Flour( 3, "Almond", "made from ground almonds.", "Gluten free" ); @@ -83,6 +76,7 @@ public void testFirstResultNoResults(VertxTestContext context) { } @Test + @DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public void testFirstResultSingleResult(VertxTestContext context) { test( context, openSession() .thenCompose( s -> s @@ -96,6 +90,7 @@ public void testFirstResultSingleResult(VertxTestContext context) { } @Test + @DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public void testFirstResultMultipleResults(VertxTestContext context) { test( context, openSession() .thenCompose( s -> s @@ -108,6 +103,7 @@ public void testFirstResultMultipleResults(VertxTestContext context) { } @Test + @DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public void testFirstResultMaxResultsSingleResult(VertxTestContext context) { test( context, openSession() .thenCompose( s -> s diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java index bcd0f9d0b..c9e938e3d 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java @@ -10,10 +10,9 @@ import java.util.List; import java.util.Objects; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -25,7 +24,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -36,14 +34,10 @@ * @see org.hibernate.reactive.id.impl.IdentifierGeneration */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0. " + + "See https://github.com/eclipse-vertx/vertx-sql-client/issues/899") public class IdentifierGenerationTypeTest extends BaseReactiveTest { - // Vertx DB2 client is throwing "java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0." - // See https://github.com/eclipse-vertx/vertx-sql-client/issues/899 - @RegisterExtension - public DBSelectionExtension skip = skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( LongEntity.class, IntegerEntity.class, ShortEntity.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeForCockroachDBTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeForCockroachDBTest.java index 58321ba3e..3d16a72f8 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeForCockroachDBTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeForCockroachDBTest.java @@ -10,10 +10,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -27,7 +26,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.hibernate.reactive.testing.ReactiveAssertions.assertThrown; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -43,12 +41,9 @@ * @see IdentityGeneratorTypeTest */ @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(COCKROACHDB) public class IdentityGeneratorTypeForCockroachDBTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension runOnly = runOnlyFor( COCKROACHDB ); - /** * When {@link AvailableSettings#USE_GET_GENERATED_KEYS} is enabled, different * queries will be used for each datastore to get the id diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeTest.java index a48c9bc0d..34fe39705 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTypeTest.java @@ -10,10 +10,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -25,7 +24,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -37,12 +35,9 @@ *

* @see IdentityGeneratorTest */ +@DisableFor(value = COCKROACHDB, reason = "ids cannot be cast to short or int (they are too big)") public class IdentityGeneratorTypeTest extends BaseReactiveTest { - // CockroachDB ids cannot be cast to short or int (they are too big) - @RegisterExtension - public DBSelectionExtension skip = skipTestsFor( COCKROACHDB ); - @Override protected Collection> annotatedEntities() { return List.of( IntegerTypeEntity.class, LongTypeEntity.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InsertOrderingReferenceSeveralDifferentSubclassBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InsertOrderingReferenceSeveralDifferentSubclassBase.java index 919ed4e69..e9fa80577 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InsertOrderingReferenceSeveralDifferentSubclassBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InsertOrderingReferenceSeveralDifferentSubclassBase.java @@ -11,11 +11,10 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -34,7 +33,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -44,11 +42,9 @@ * Verify that duplicate sql insert statements are collapsed to a single insert per entity and are ordered based on * parent/child relationships` */ +@EnableFor(POSTGRESQL) public abstract class InsertOrderingReferenceSeveralDifferentSubclassBase extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); - public static class OrderedTest extends InsertOrderingReferenceSeveralDifferentSubclassBase { @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InternalStateAssertionsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InternalStateAssertionsTest.java index 4a8d286dc..acebb253c 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InternalStateAssertionsTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/InternalStateAssertionsTest.java @@ -12,10 +12,9 @@ import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.stage.Stage.Session; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.smallrye.mutiny.Uni; import io.vertx.junit5.Timeout; @@ -26,7 +25,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.hibernate.reactive.testing.ReactiveAssertions.assertThrown; /** @@ -34,6 +32,10 @@ * @see org.hibernate.reactive.common.InternalStateAssertions */ @Timeout(value = 10, timeUnit = MINUTES) +@EnableFor( + value = POSTGRESQL, + reason = "These tests will fail before touching the database, so there is no reason to run them on all databases" +) public class InternalStateAssertionsTest extends BaseReactiveTest { /** @@ -43,11 +45,6 @@ public class InternalStateAssertionsTest extends BaseReactiveTest { private Object currentSession; - // These tests will fail before touching the database, so there is no reason - // to run them on all databases - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); - @Override protected Collection> annotatedEntities() { return List.of( Competition.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyReplaceOrphanedEntityTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyReplaceOrphanedEntityTest.java index d14ef3114..1576bf5a3 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyReplaceOrphanedEntityTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyReplaceOrphanedEntityTest.java @@ -11,11 +11,10 @@ import java.util.List; import java.util.UUID; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -38,13 +37,9 @@ import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class LazyReplaceOrphanedEntityTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - private Campaign theCampaign; @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyUniqueKeyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyUniqueKeyTest.java index b9ce6b0a5..38f43def9 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyUniqueKeyTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyUniqueKeyTest.java @@ -11,10 +11,9 @@ import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,20 +28,15 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; /** * @see EagerUniqueKeyTest */ @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class LazyUniqueKeyTest extends BaseReactiveTest { - // Db2: java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. In JDBC we would normally block here - @RegisterExtension - public DBSelectionExtension skip = skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Foo.class, Bar.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NativeQueryPlaceholderSubstitutionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NativeQueryPlaceholderSubstitutionTest.java index 1fa546a22..12eacdf40 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NativeQueryPlaceholderSubstitutionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NativeQueryPlaceholderSubstitutionTest.java @@ -11,11 +11,10 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -27,7 +26,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; /** * The processing of the query is done by Hibernate ORM in {@link org.hibernate.reactive.query.sql.internal.ReactiveNativeSelectQueryPlanImpl} @@ -39,11 +37,9 @@ * */ @Timeout(value = 10, timeUnit = MINUTES) +@EnableFor(POSTGRESQL) public class NativeQueryPlaceholderSubstitutionTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbRule = runOnlyFor( POSTGRESQL ); - @Override protected Collection> annotatedEntities() { return List.of( Widget.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ORMReactivePersistenceTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ORMReactivePersistenceTest.java index e0166881e..6fa5d78da 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ORMReactivePersistenceTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ORMReactivePersistenceTest.java @@ -14,12 +14,11 @@ import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -41,13 +40,10 @@ * This test class verifies that data can be persisted and queried on the same database * using both JPA/hibernate and reactive session factories. */ +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") +@DisableFor(value = COCKROACHDB, reason = "We need to change the URL schema we normally use for testing") public class ORMReactivePersistenceTest extends BaseReactiveTest { - // DB2: The CompletionStage test throw java.lang.IllegalStateException: Needed to have 6 in buffer... - // Cockroach: We need to change the URL schema we normally use for testing - @RegisterExtension - public DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2, COCKROACHDB ); - private SessionFactory ormFactory; @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderQueriesTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderQueriesTestBase.java index c7788e4e2..806dc5315 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderQueriesTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderQueriesTestBase.java @@ -13,12 +13,11 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.smallrye.mutiny.Uni; import io.vertx.junit5.Timeout; @@ -30,7 +29,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; /** * Test {@code hibernate.order_updates} and {@code hibernate.order_inserts} configurations. @@ -38,11 +36,9 @@ * @see Settings#ORDER_INSERTS * @see Settings#ORDER_UPDATES */ -public abstract class OrderQueriesTestBase extends BaseReactiveTest { - //Db2: java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. In JDBC we would normally block - @RegisterExtension - public final DBSelectionExtension skip = skipTestsFor( DB2 ); +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") +public abstract class OrderQueriesTestBase extends BaseReactiveTest { public static class OrderUpdatesTest extends OrderQueriesTestBase { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java index 509ce08fc..93b6d9ec0 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java @@ -10,7 +10,12 @@ import java.util.List; import java.util.Objects; +import org.hibernate.Hibernate; + +import org.junit.jupiter.api.Test; + import io.vertx.junit5.Timeout; +import io.vertx.junit5.VertxTestContext; import jakarta.persistence.Basic; import jakarta.persistence.CollectionTable; import jakarta.persistence.ElementCollection; @@ -20,17 +25,9 @@ import jakarta.persistence.Id; import jakarta.persistence.OrderColumn; import jakarta.persistence.Table; - -import org.hibernate.Hibernate; -import org.hibernate.reactive.testing.DBSelectionExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.vertx.junit5.VertxTestContext; import org.assertj.core.api.Assertions; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -38,9 +35,6 @@ @Timeout(value = 10, timeUnit = MINUTES) public class OrderedEmbeddableCollectionTest extends BaseReactiveTest { - @RegisterExtension // This exposes a strange bug in the DB2 client - public DBSelectionExtension dbRule = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Author.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java index 7077fdbe5..2ac7bd8e1 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java @@ -10,10 +10,10 @@ import java.util.List; import java.util.Set; -import org.hibernate.reactive.testing.DBSelectionExtension; + +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,15 +29,12 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; @Timeout( value = 10, timeUnit = MINUTES) +@DisableFor( value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0" ) public class OrphanRemovalTest extends BaseReactiveTest { - //Db2: java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. In JDBC we would normally block - @RegisterExtension - public final DBSelectionExtension skip = skipTestsFor( DB2 ); @Override protected Collection> annotatedEntities() { return List.of( Shop.class, Version.class, Product.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantNoResolverTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantNoResolverTest.java index cdc14829f..522a40022 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantNoResolverTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantNoResolverTest.java @@ -15,10 +15,9 @@ import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.provider.Settings; import org.hibernate.reactive.stage.Stage; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.smallrye.mutiny.Uni; import io.vertx.junit5.Timeout; @@ -34,7 +33,6 @@ import static org.hibernate.reactive.MyCurrentTenantIdentifierResolver.Tenant.TENANT_1; import static org.hibernate.reactive.MyCurrentTenantIdentifierResolver.Tenant.TENANT_2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.hibernate.reactive.testing.ReactiveAssertions.assertThrown; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -51,13 +49,9 @@ * @see ReactiveMultitenantTest */ @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(value = POSTGRESQL, reason = "Native queries for this test are targeted for PostgreSQL") public class ReactiveMultitenantNoResolverTest extends BaseReactiveTest { - // To check if we are using the right database we run native queries for PostgreSQL - @RegisterExtension - public DBSelectionExtension selectionRule = runOnlyFor( POSTGRESQL ); - @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantTest.java index 626a17b9c..b39921a27 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveMultitenantTest.java @@ -11,10 +11,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -38,15 +37,11 @@ * on the database for the selected tenant. */ @Timeout(value = 10, timeUnit = MINUTES) - +@EnableFor(value = POSTGRESQL, reason = "Native queries for this test are targeted for PostgreSQL") public class ReactiveMultitenantTest extends BaseReactiveTest { private static final MyCurrentTenantIdentifierResolver TENANT_RESOLVER = new MyCurrentTenantIdentifierResolver(); - // To check if we are using the right database we run native queries for PostgreSQL - @RegisterExtension - public DBSelectionExtension selectionRule = DBSelectionExtension.runOnlyFor( POSTGRESQL ); - @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/RowIdUpdateAndDeleteTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/RowIdUpdateAndDeleteTest.java index af84be1e0..c359493cf 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/RowIdUpdateAndDeleteTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/RowIdUpdateAndDeleteTest.java @@ -11,12 +11,11 @@ import org.hibernate.annotations.RowId; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.CascadeType; @@ -30,18 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; /** * Adapted from the test with the same name in Hibernate ORM: {@literal org.hibernate.orm.test.rowid.RowIdUpdateAndDeleteTest} */ +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") +@DisableFor(value = ORACLE, reason = "Vert.x driver doesn't support RowId type parameters") public class RowIdUpdateAndDeleteTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - // Oracle: Vert.x driver doesn't support RowId type parameters - @RegisterExtension - public final DBSelectionExtension skip = skipTestsFor( DB2, ORACLE ); - private static SqlStatementTracker sqlTracker; @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SQLSelectTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SQLSelectTest.java index e7990e486..517cc1208 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SQLSelectTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SQLSelectTest.java @@ -12,12 +12,11 @@ import org.hibernate.annotations.SQLSelect; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.SqlStatementTracker; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.Entity; @@ -25,12 +24,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.reactive.SQLSelectTest.Person.SELECT_QUERY; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.COCKROACHDB; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; +@EnableFor(value = POSTGRESQL, reason = "Native queries for this test are targeted for PostgreSQL") +@EnableFor(value = COCKROACHDB, reason = "Native queries for this test are targeted for CockroachDB") public class SQLSelectTest extends BaseReactiveTest { - @RegisterExtension // We use native queries, which may be different for other DBs - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); private SqlStatementTracker sqlTracker; diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SecondaryTableTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SecondaryTableTest.java index 66d9cd30f..5caade9c5 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SecondaryTableTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SecondaryTableTest.java @@ -10,10 +10,10 @@ import java.util.List; import java.util.Objects; -import org.hibernate.reactive.testing.DBSelectionExtension; + +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,7 +29,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -37,12 +36,9 @@ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor( value = DB2, reason = "IllegalStateException: Needed to have 6 in buffer but only had 0" ) public class SecondaryTableTest extends BaseReactiveTest { - //Db2: java.lang.IllegalStateException: Needed to have 6 in buffer but only had 0. In JDBC we would normally block - @RegisterExtension - public final DBSelectionExtension skip = skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Book.class, Author.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SequenceGeneratorTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SequenceGeneratorTest.java index 7f7f996e8..c26cea145 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SequenceGeneratorTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SequenceGeneratorTest.java @@ -12,10 +12,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.containers.DatabaseConfiguration; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -35,7 +34,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = MYSQL, reason = "See https://github.com/hibernate/hibernate-reactive/issues/1525") +@DisableFor(value = COCKROACHDB, reason = "we don't have permission to create schema in the CI!") public class SequenceGeneratorTest extends BaseReactiveTest { @Override @@ -74,11 +74,6 @@ public void testSequenceGenerator(VertxTestContext context) { public static class SequenceGeneratorDefaultSchemaTest extends SequenceGeneratorTest { - // COCKROACHDB: we don't have permission to create schema in the CI! - // MYSQL: See https://github.com/hibernate/hibernate-reactive/issues/1525 - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.skipTestsFor( COCKROACHDB, MYSQL ); - @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDGeneratorTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDGeneratorTest.java index b9bf175f8..76ac3f4f2 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDGeneratorTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDGeneratorTest.java @@ -10,10 +10,8 @@ import java.util.Objects; import java.util.UUID; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -25,17 +23,12 @@ import jakarta.persistence.Version; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @Timeout(value = 10, timeUnit = MINUTES) - public class UUIDGeneratorTest extends BaseReactiveTest { - @RegisterExtension // Storing UUID doesn't work with DB2 - public DBSelectionExtension dbRule = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( TableId.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableFor.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableFor.java new file mode 100644 index 000000000..49eb2c365 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableFor.java @@ -0,0 +1,57 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Annotation that allows disabling tests or test methods for specific database types. + *

+ * Types are defined in {@link DatabaseConfiguration.DBType} and can be + * applied to a test class or a test method + * + *

{@code
+ *
+ * @DisableFor( value = MYSQL, reason = "Reason #1")
+ * public class DisableDBForClassTest {
+ *
+ * 		@Test
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ *
+ * public class DisableDBForMethodTest {
+ *
+ * 		@Test
+ * 		@DisableFor( value = POSTGRES, reason = "Reason #2")
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ * }
+ * + */ + +@SuppressWarnings("JavadocReference") +@Inherited +@Retention( RetentionPolicy.RUNTIME ) +@Target({ ElementType.TYPE, ElementType.METHOD}) +@Repeatable( DisableForGroup.class ) +@ExtendWith( DisableForDBTypeCondition.class ) +public @interface DisableFor { + DatabaseConfiguration.DBType value(); + String reason() default ""; +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForDBTypeCondition.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForDBTypeCondition.java new file mode 100644 index 000000000..a0ed9a1c1 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForDBTypeCondition.java @@ -0,0 +1,41 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.util.Optional; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; + +class DisableForDBTypeCondition implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + Optional disabledForGroup = findAnnotation( context.getElement(), DisableForGroup.class ); + if ( disabledForGroup != null && disabledForGroup.isPresent() ) { + for ( DisableFor annotation : disabledForGroup.get().value() ) { + if ( annotation.value() == DatabaseConfiguration.dbType() ) { + return ConditionEvaluationResult.disabled( annotation.reason() ); + } + } + return ConditionEvaluationResult.enabled( "" ); + } + + Optional disabledFor = findAnnotation( context.getElement(), DisableFor.class ); + if ( disabledFor.isPresent() ) { + DatabaseConfiguration.DBType type = disabledFor.get().value(); + return type == DatabaseConfiguration.dbType() ? + ConditionEvaluationResult.disabled( disabledFor.get().reason() ) : + ConditionEvaluationResult.enabled( "" ); + } + return ConditionEvaluationResult.enabled( "" ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForGroup.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForGroup.java new file mode 100644 index 000000000..f4e55d608 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/DisableForGroup.java @@ -0,0 +1,59 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Annotation that allows disabling tests or test methods for specific database types. + * + * Types are defined in {@link DatabaseConfiguration.DBType} and can be + * applied to a test class or a test method + * + *
{@code
+ *
+ * @DisableForGroup( {
+ *     @DisableFor(value = MYSQL, reason = "Reason #1"),
+ *     @DisableFor(value = DB2, reason = "Reason #2")
+ * } )
+ * public class DisableDBsForClassTest {
+ *
+ * 		@Test
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ *
+ * public class DisableDBsForMethodTest {
+ *
+ * 		@Test
+ * 		@DisableForGroup( {
+ *      	   @DisableFor(value = POSTGRES, reason = "Reason #3"),
+ *      	   @DisableFor(value = MYSQL, reason = "Reason #4")
+ *         } )
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ * }
+ * + */ + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE, ElementType.METHOD}) +@ExtendWith( DisableForDBTypeCondition.class ) +public @interface DisableForGroup { + DisableFor[] value(); +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableFor.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableFor.java new file mode 100644 index 000000000..ce4d6c38c --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableFor.java @@ -0,0 +1,57 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Annotation that allows disabling tests or test methods only for specific database types. + *

+ * Types are defined in {@link DatabaseConfiguration.DBType} and can be + * applied to a test class or a test method + * + *

{@code
+ *
+ * @EnableFor( MYSQL )
+ * public class EnableDBForClassTest {
+ *
+ * 		@Test
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ *
+ * public class EnableDBForMethodTest {
+ *
+ * 		@Test
+ * 		@EnableFor( value = POSTGRES, "optional reason" )
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ * }
+ * + */ + +@SuppressWarnings("JavadocReference") +@Inherited +@Retention( RetentionPolicy.RUNTIME ) +@Target({ ElementType.TYPE, ElementType.METHOD}) +@Repeatable( EnableForGroup.class ) +@ExtendWith( EnableForDBTypeCondition.class ) +public @interface EnableFor { + DatabaseConfiguration.DBType value(); + String reason() default ""; +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForDBTypeCondition.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForDBTypeCondition.java new file mode 100644 index 000000000..5c63f5154 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForDBTypeCondition.java @@ -0,0 +1,41 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.util.Optional; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; + +public class EnableForDBTypeCondition
implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + Optional enableForGroup = findAnnotation( context.getElement(), EnableForGroup.class ); + if ( enableForGroup != null && enableForGroup.isPresent() ) { + for ( EnableFor annotation : enableForGroup.get().value() ) { + if ( annotation.value() == DatabaseConfiguration.dbType() ) { + return ConditionEvaluationResult.enabled( annotation.reason() ); + } + } + return ConditionEvaluationResult.disabled( "" ); + } + + Optional enableFor = findAnnotation( context.getElement(), EnableFor.class ); + if( enableFor != null && enableFor.isPresent() ) { + DatabaseConfiguration.DBType type = enableFor.get().value(); + return type == DatabaseConfiguration.dbType() ? + ConditionEvaluationResult.enabled( "" ) : + ConditionEvaluationResult.disabled( "" ); + } + return ConditionEvaluationResult.enabled( "" ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForGroup.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForGroup.java new file mode 100644 index 000000000..7ada51fa7 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/EnableForGroup.java @@ -0,0 +1,59 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Annotation that allows enabling tests or test methods only for specific database types. + * + * Types are defined in {@link DatabaseConfiguration.DBType} and can be + * applied to a test class or a test method + * + *
{@code
+ *
+ * @EnableForGroup( {
+ *     @EnableFor( MYSQL ),
+ *     @EnableFor( DB2 )
+ * } )
+ * public class EnableDBsForClassTest {
+ *
+ * 		@Test
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ *
+ * public class EnableDBsForMethodTest {
+ *
+ * 		@Test
+ * 		@EnableForGroup( {
+ *      	   @EnableFor( POSTGRES),
+ *      	   @EnableFor( MYSQL )
+ *         } )
+ * 		public void test(VertxTestContext context) {
+ *          ....
+ * 		}
+ * }
+ * }
+ * + */ + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE, ElementType.METHOD}) +@ExtendWith( EnableForDBTypeCondition.class ) +public @interface EnableForGroup { + EnableFor[] value(); +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForClassTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForClassTest.java new file mode 100644 index 000000000..7773e8d93 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForClassTest.java @@ -0,0 +1,25 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + + +import org.hibernate.reactive.annotations.DisableFor; +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.Test; + +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +@DisableFor(value = POSTGRESQL, reason = "some reason") +public class DisableForClassTest { + + @Test + public void test() { + // Throw exception if this test is run with POSTGRESQL database + assertNotEquals( POSTGRESQL, DatabaseConfiguration.dbType() ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMethodTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMethodTest.java new file mode 100644 index 000000000..7250411fa --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMethodTest.java @@ -0,0 +1,24 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.DisableFor; +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.Test; + +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +public class DisableForMethodTest { + + @Test + @DisableFor(value = POSTGRESQL, reason = "some reason") + public void test() { + // Throw exception if this test is run with POSTGRESQL database + assertNotEquals( POSTGRESQL, DatabaseConfiguration.dbType() ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleClassTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleClassTest.java new file mode 100644 index 000000000..e58c1e4e4 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleClassTest.java @@ -0,0 +1,26 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.DisableFor; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; + +@DisableFor(value = MYSQL, reason = "some reason") +@DisableFor(value = POSTGRESQL, reason = "some reason") +public class DisableForMultipleClassTest { + + @Test + public void test() { + // Throw exception if this test is run with POSTGRESQL or MYSQL database + assertThat( dbType() ).isNotIn( MYSQL, POSTGRESQL ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleMethodTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleMethodTest.java new file mode 100644 index 000000000..72c415f74 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/DisableForMultipleMethodTest.java @@ -0,0 +1,28 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + + +import org.hibernate.reactive.annotations.DisableFor; +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.Test; + +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class DisableForMultipleMethodTest { + + @Test + @DisableFor(value = MYSQL, reason = "some reason") + @DisableFor(value = POSTGRESQL, reason = "some reason") + public void test() { + // Throw exception if this test is run with POSTGRESQL or MYSQL database + assertTrue( DatabaseConfiguration.dbType() != POSTGRESQL && + DatabaseConfiguration.dbType() != MYSQL ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForClassTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForClassTest.java new file mode 100644 index 000000000..ff8e87a4d --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForClassTest.java @@ -0,0 +1,24 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.EnableFor; +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.Test; + +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertEquals; + +@EnableFor(value = POSTGRESQL) +public class EnableForClassTest { + + @Test + public void test() { + // Throw exception if this test is database is NOT POSTGRESQL + assertEquals( POSTGRESQL, DatabaseConfiguration.dbType() ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForGroupClassTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForGroupClassTest.java new file mode 100644 index 000000000..30a9a2290 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForGroupClassTest.java @@ -0,0 +1,29 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.EnableFor; +import org.hibernate.reactive.annotations.EnableForGroup; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; + +@EnableForGroup({ + @EnableFor(value = MYSQL), + @EnableFor(value = POSTGRESQL) +}) +public class EnableForGroupClassTest { + + @Test + public void test() { + // Throw exception if this test is run with POSTGRESQL or MYSQL database + assertThat( dbType() ).isIn( MYSQL, POSTGRESQL ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMethodTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMethodTest.java new file mode 100644 index 000000000..52c11e966 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMethodTest.java @@ -0,0 +1,24 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.EnableFor; +import org.hibernate.reactive.containers.DatabaseConfiguration; + +import org.junit.jupiter.api.Test; + +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class EnableForMethodTest { + + @Test + @EnableFor(value = POSTGRESQL) + public void test() { + // Throw exception if this test is database is NOT POSTGRESQL + assertEquals( POSTGRESQL, DatabaseConfiguration.dbType() ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleClassTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleClassTest.java new file mode 100644 index 000000000..c78308b25 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleClassTest.java @@ -0,0 +1,26 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.EnableFor; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; + +@EnableFor(value = MYSQL) +@EnableFor(value = POSTGRESQL) +public class EnableForMultipleClassTest { + + @Test + public void test() { + // Throw exception if this test is run with POSTGRESQL or MYSQL database + assertThat( dbType() ).isIn( MYSQL, POSTGRESQL ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleMethodTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleMethodTest.java new file mode 100644 index 000000000..9c5a2670d --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests/EnableForMultipleMethodTest.java @@ -0,0 +1,26 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.annotations.tests; + +import org.hibernate.reactive.annotations.EnableFor; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; + +public class EnableForMultipleMethodTest { + + @Test + @EnableFor(value = MYSQL) + @EnableFor(value = POSTGRESQL) + public void test() { + // Throw exception if this test is run with POSTGRESQL or MYSQL database + assertThat( dbType() ).isIn( MYSQL, POSTGRESQL ); + } +} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/ReactiveConnectionPoolTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/ReactiveConnectionPoolTest.java index 06f904671..71c368979 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/ReactiveConnectionPoolTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/ReactiveConnectionPoolTest.java @@ -18,15 +18,14 @@ import org.hibernate.reactive.pool.impl.DefaultSqlClientPool; import org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration; import org.hibernate.reactive.pool.impl.SqlClientPoolConfiguration; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.hibernate.reactive.testing.TestingRegistryExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; -import io.vertx.junit5.RunTestOnContext; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxExtension; import io.vertx.junit5.VertxTestContext; @@ -39,24 +38,18 @@ import static org.hibernate.reactive.BaseReactiveTest.test; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; import static org.hibernate.reactive.containers.DatabaseConfiguration.getJdbcUrl; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.hibernate.reactive.testing.ReactiveAssertions.assertThrown; import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(VertxExtension.class) @TestInstance(TestInstance.Lifecycle.PER_METHOD) @Timeout(value = 10, timeUnit = TimeUnit.MINUTES) +@EnableFor(value = POSTGRESQL, reason = "Create new scratch file from selection") public class ReactiveConnectionPoolTest { - @RegisterExtension - public DBSelectionExtension dbSelection = runOnlyFor( POSTGRESQL ); - @RegisterExtension public TestingRegistryExtension registryExtension = new TestingRegistryExtension(); - @RegisterExtension - public RunTestOnContext testOnContext = new RunTestOnContext(); - private ReactiveConnectionPool configureAndStartPool(Map config) { DefaultSqlClientPoolConfiguration poolConfig = new DefaultSqlClientPoolConfiguration(); poolConfig.configure( config ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateCockroachDBTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateCockroachDBTestBase.java index 4a9b78217..6f2ac1ca5 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateCockroachDBTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateCockroachDBTestBase.java @@ -11,12 +11,11 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -41,10 +40,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(COCKROACHDB) public abstract class SchemaUpdateCockroachDBTestBase extends BaseReactiveTest { @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuEachySchemaUpdateCockroachTestBase extends SchemaUpdateCockroachDBTestBase { @Override @@ -56,7 +55,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedSchemaUpdateCockroachTestBase extends SchemaUpdateCockroachDBTestBase { @Override @@ -74,9 +72,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { return configuration; } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.runOnlyFor( COCKROACHDB ); - @BeforeEach @Override public void before(VertxTestContext context) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMariaDBTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMariaDBTestBase.java index a66b68c42..d225ef2ce 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMariaDBTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMariaDBTestBase.java @@ -8,6 +8,15 @@ import java.io.Serializable; import java.util.Objects; +import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.annotations.EnableFor; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.CascadeType; @@ -23,28 +32,17 @@ import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; -import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - import static java.util.concurrent.TimeUnit.MINUTES; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.INDIVIDUALLY; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(MARIA) public abstract class SchemaUpdateMariaDBTestBase extends BaseReactiveTest { @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallySchemaUpdateMariaDBTestBase extends SchemaUpdateMariaDBTestBase { @@ -74,9 +72,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { return configuration; } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.runOnlyFor( MARIA ); - @BeforeEach @Override public void before(VertxTestContext context) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMySqlTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMySqlTestBase.java index bef5a6a53..700782fae 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMySqlTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateMySqlTestBase.java @@ -11,12 +11,11 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -40,6 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(MYSQL) public abstract class SchemaUpdateMySqlTestBase extends BaseReactiveTest { @Timeout(value = 10, timeUnit = MINUTES) @@ -71,9 +71,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { return configuration; } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.runOnlyFor( MYSQL ); - @BeforeEach @Override public void before(VertxTestContext context) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateOracleTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateOracleTestBase.java index 147cba94a..c18f43f04 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateOracleTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateOracleTestBase.java @@ -8,6 +8,15 @@ import java.io.Serializable; import java.util.Objects; +import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.annotations.EnableFor; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.CascadeType; @@ -23,31 +32,17 @@ import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; -import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.INDIVIDUALLY; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(ORACLE) public abstract class SchemaUpdateOracleTestBase extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension dbRule = runOnlyFor( ORACLE ); - @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallySchemaUpdateOracleTestBase extends SchemaUpdateOracleTestBase { @Override @@ -59,7 +54,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedSchemaUpdateOracleTestBase extends SchemaUpdateOracleTestBase { @Override diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdatePostgreSqlTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdatePostgreSqlTestBase.java index 972aea7de..45c7e69c8 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdatePostgreSqlTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdatePostgreSqlTestBase.java @@ -8,6 +8,15 @@ import java.io.Serializable; import java.util.Objects; +import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.annotations.EnableFor; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.CascadeType; @@ -23,16 +32,6 @@ import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; -import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; @@ -41,10 +40,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(POSTGRESQL) public abstract class SchemaUpdatePostgreSqlTestBase extends BaseReactiveTest { @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallySchemaUpdatePostgreSqlTestBase extends SchemaUpdatePostgreSqlTestBase { @Override @@ -56,7 +55,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedSchemaUpdatePostgreSqlTestBase extends SchemaUpdatePostgreSqlTestBase { @Override @@ -74,9 +72,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { return configuration; } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.runOnlyFor( POSTGRESQL ); - @BeforeEach @Override public void before(VertxTestContext context) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateSqlServerTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateSqlServerTestBase.java index c93a3a4de..da0b9df1c 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateSqlServerTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateSqlServerTestBase.java @@ -12,12 +12,11 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.EnableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -41,6 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@EnableFor(SQLSERVER) public abstract class SchemaUpdateSqlServerTestBase extends BaseReactiveTest { // This is the default chosen by MSSQL @@ -50,7 +50,6 @@ public abstract class SchemaUpdateSqlServerTestBase extends BaseReactiveTest { * Test INDIVIDUALLY option without setting the default catalog name */ @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallySchemaUpdateSqlServerTest extends SchemaUpdateSqlServerTestBase { @Override @@ -65,7 +64,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { * Test INDIVIDUALLY option when we set the catalog name to the default name */ @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallySchemaUpdateWithCatalogTest extends SchemaUpdateSqlServerTestBase { @Override @@ -80,7 +78,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { * Test GROUPED option without setting the default catalog name */ @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedSchemaUpdateSqlServerTest extends SchemaUpdateSqlServerTestBase { @Override @@ -95,7 +92,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { * Test GROUPED option when we set the catalog name to default name */ @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedSchemaUpdateWithCatalogNameTest extends SchemaUpdateSqlServerTestBase { @Override @@ -113,9 +109,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { return configuration; } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.runOnlyFor( SQLSERVER ); - @BeforeEach @Override public void before(VertxTestContext context) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateTestBase.java index 86d30df19..87f0295da 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateTestBase.java @@ -11,12 +11,11 @@ import org.hibernate.reactive.BaseReactiveTest; import org.hibernate.reactive.provider.Settings; import org.hibernate.reactive.stage.Stage; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -25,7 +24,6 @@ import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.INDIVIDUALLY; @@ -33,10 +31,10 @@ * Schema update will run different queries when the table already exists or * when columns are missing. */ +@DisableFor(value = DB2, reason = "No InformationExtractor for Dialect [org.hibernate.dialect.DB2Dialect..]") public abstract class SchemaUpdateTestBase extends BaseReactiveTest { @Timeout(value = 10, timeUnit = MINUTES) - public static class IndividuallyStrategyTest extends SchemaUpdateTestBase { @Override @@ -48,7 +46,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Timeout(value = 10, timeUnit = MINUTES) - public static class GroupedStrategyTest extends SchemaUpdateTestBase { @Override @@ -59,9 +56,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } } - @RegisterExtension - public DBSelectionExtension dbRule = skipTestsFor( DB2 ); - protected Configuration constructConfiguration(String action) { Configuration configuration = super.constructConfiguration(); configuration.setProperty( Settings.HBM2DDL_AUTO, action ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaValidationTestBase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaValidationTestBase.java index 814344cdb..afc6d0b90 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaValidationTestBase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaValidationTestBase.java @@ -10,13 +10,12 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; import org.hibernate.reactive.provider.Settings; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.hibernate.tool.schema.spi.SchemaManagementException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -39,6 +38,7 @@ * - TODO: Missing column * - TODO: Wrong column type */ +@DisableFor(value = DB2, reason = "No InformationExtractor for Dialect [org.hibernate.dialect.DB2Dialect..]") public abstract class SchemaValidationTestBase extends BaseReactiveTest { public static class IndividuallyStrategyTest extends SchemaValidationTestBase { @@ -61,9 +61,6 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } } - @RegisterExtension - public DBSelectionExtension dbRule = DBSelectionExtension.skipTestsFor( DB2 ); - protected Configuration constructConfiguration(String action) { Configuration configuration = super.constructConfiguration(); configuration.setProperty( Settings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY, INDIVIDUALLY.toString() ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/testing/DBSelectionExtension.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/testing/DBSelectionExtension.java deleted file mode 100644 index 9038f01f0..000000000 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/testing/DBSelectionExtension.java +++ /dev/null @@ -1,96 +0,0 @@ -/* Hibernate, Relational Persistence for Idiomatic Java - * - * SPDX-License-Identifier: Apache-2.0 - * Copyright: Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.reactive.testing; - -import java.util.Arrays; -import java.util.stream.Collectors; - -import org.hibernate.reactive.containers.DatabaseConfiguration.DBType; - -import org.junit.jupiter.api.extension.ConditionEvaluationResult; -import org.junit.jupiter.api.extension.ExecutionCondition; -import org.junit.jupiter.api.extension.ExtensionContext; - -import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; -import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled; -import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled; - -/** - * Define which db is enabled for the tests in a class. - *

- * Examples of use: - *

- * {@code - * - * @RegisterExtension public DBSelectionExtension dbSelection = DBSelectionExtension.skipTestsFor( DBType.POSTGRESQL ); - * } - *

- * {@code - * @RegisterExtension public DBSelectionExtension dbSelection = DBSelectionExtension.runOnlyFor( DBType.POSTGRESQL ); - * } - *

- * @see DBType - */ -public class DBSelectionExtension implements ExecutionCondition { - - /** - * The selected db for running the tests - */ - private final DBType selectedDb = dbType(); - - /** - * Skip the tests for these dbs - */ - private final DBType[] skippable; - private final String description; - - private DBSelectionExtension(DBType[] skippable, String description) { - this.skippable = skippable; - this.description = description; - } - - /** - * Create an extension that will skip the tests for the selected dbs - * - * @param dbTypes the dbs we want to skip - * - * @return an instance of {@link DBSelectionExtension} - */ - public static DBSelectionExtension skipTestsFor(DBType... dbTypes) { - return new DBSelectionExtension( dbTypes, "Skip tests for " + Arrays.toString( dbTypes ) ); - } - - /** - * Create an extension that will run the tests only for the selected dbs - * - * @param dbTypes the dbs we want to use for running the tests - * - * @return an instance of {@link DBSelectionExtension} - */ - public static DBSelectionExtension runOnlyFor(DBType... dbTypes) { - DBType[] skippable = Arrays.stream( DBType.values() ) - .filter( dbType -> !Arrays.asList( dbTypes ).contains( dbType ) ) - .collect( Collectors.toList() ) - .toArray( new DBType[dbTypes.length] ); - return new DBSelectionExtension( skippable, "Run only for " + Arrays.toString( dbTypes ) ); - } - - private boolean isSkippable(DBType dbType) { - for ( DBType db : skippable ) { - if ( db == dbType ) { - return true; - } - } - return false; - } - - @Override - public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { - return isSkippable( selectedDb ) - ? disabled( "Test is not applicable for " + dbType().toString() ) - : enabled( "" ); - } -} diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/AutoZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/AutoZonedTest.java index cad133056..fd9ceca97 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/AutoZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/AutoZonedTest.java @@ -13,7 +13,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import java.time.OffsetDateTime; import java.time.ZoneId; @@ -23,7 +23,6 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; @@ -33,13 +32,9 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class AutoZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/ColumnZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/ColumnZonedTest.java index 37c37a60b..d752e86b9 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/ColumnZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/ColumnZonedTest.java @@ -5,16 +5,6 @@ */ package org.hibernate.reactive.timezones; -import io.vertx.junit5.Timeout; -import io.vertx.junit5.VertxTestContext; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; - -import org.hibernate.cfg.Configuration; -import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; - import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -22,8 +12,17 @@ import java.util.Collection; import java.util.List; +import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.annotations.DisableFor; + import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; + +import io.vertx.junit5.Timeout; +import io.vertx.junit5.VertxTestContext; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; @@ -33,13 +32,9 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "java.sql.SQLException: An error occurred with a DB2 operation, SQLCODE=-180 SQLSTATE=22007") public class ColumnZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/DefaultZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/DefaultZonedTest.java index 598693364..948e6098d 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/DefaultZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/DefaultZonedTest.java @@ -5,16 +5,6 @@ */ package org.hibernate.reactive.timezones; -import io.vertx.junit5.Timeout; -import io.vertx.junit5.VertxTestContext; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; - -import org.hibernate.dialect.TimeZoneSupport; -import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; - import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -22,8 +12,17 @@ import java.util.Collection; import java.util.List; +import org.hibernate.dialect.TimeZoneSupport; +import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.annotations.DisableFor; + import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; + +import io.vertx.junit5.Timeout; +import io.vertx.junit5.VertxTestContext; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; @@ -32,13 +31,9 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class DefaultZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/JDBCTimeZoneZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/JDBCTimeZoneZonedTest.java index 5df4c0326..a4b092d4b 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/JDBCTimeZoneZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/JDBCTimeZoneZonedTest.java @@ -15,10 +15,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -35,13 +34,9 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class JDBCTimeZoneZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/PassThruZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/PassThruZonedTest.java index d8463102b..4bcbc4edf 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/PassThruZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/PassThruZonedTest.java @@ -15,10 +15,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,18 +28,14 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.cfg.AvailableSettings.TIMEZONE_DEFAULT_STORAGE; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: SQLException: An error occurred with a DB2 operation, SQLCODE=-180 SQLSTATE=22007") public class PassThruZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/TimeZoneStorageMappingTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/TimeZoneStorageMappingTest.java index 5539223df..86d017d60 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/TimeZoneStorageMappingTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/TimeZoneStorageMappingTest.java @@ -21,11 +21,10 @@ import org.hibernate.annotations.TimeZoneStorageType; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -58,12 +57,9 @@ *

*/ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor(value = SQLSERVER, reason = "currently does not support java.time.OffsetTime") public class TimeZoneStorageMappingTest extends BaseReactiveTest { - // SQLSERVER currently does not support java.time.OffsetTime - @RegisterExtension - public DBSelectionExtension selectionRule = DBSelectionExtension.skipTestsFor( SQLSERVER ); - private static final ZoneOffset JVM_TIMEZONE_OFFSET = OffsetDateTime.now().getOffset(); private static final OffsetTime OFFSET_TIME = OffsetTime.of( diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedInstantTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedInstantTest.java index b9d0822b2..7f1934d19 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedInstantTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedInstantTest.java @@ -12,10 +12,9 @@ import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,13 +28,9 @@ import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class UTCNormalizedInstantTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedZonedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedZonedTest.java index fd686b543..590d4ecd1 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedZonedTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/timezones/UTCNormalizedZonedTest.java @@ -14,10 +14,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -33,13 +32,9 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision; @Timeout(value = 10, timeUnit = MINUTES) - +@DisableFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0") public class UTCNormalizedZonedTest extends BaseReactiveTest { - // Db2: Exception: IllegalStateException: Needed to have 6 in buffer but only had 0 - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); - @Override protected Collection> annotatedEntities() { return List.of( Zoned.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/BasicTypesAndCallbacksForAllDBsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/BasicTypesAndCallbacksForAllDBsTest.java index 9d8a34d9f..9644cc3f0 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/BasicTypesAndCallbacksForAllDBsTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/BasicTypesAndCallbacksForAllDBsTest.java @@ -29,12 +29,10 @@ import org.hibernate.annotations.Type; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.VertxTestContext; import jakarta.persistence.AttributeConverter; @@ -64,7 +62,6 @@ import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -73,11 +70,8 @@ /** * Test all the types and lifecycle callbacks that we expect to work on all supported DBs */ -public class BasicTypesAndCallbacksForAllDBsTest extends BaseReactiveTest { - //Db2: testUUIDType throws NoStackTraceThrowable: parameter of type BufferImpl cannot be coerced to ByteBuf - @RegisterExtension - public final DBSelectionExtension skip = DBSelectionExtension.skipTestsFor( DB2 ); +public class BasicTypesAndCallbacksForAllDBsTest extends BaseReactiveTest { @Override protected Set> annotatedEntities() { @@ -381,7 +375,6 @@ public void testBigIntegerType(VertxTestContext context) { } @Test - @Disabled // Fail for MSSQL because the value changes before it's saved on the db. This also fails for ORM public void testLocalTimeType(VertxTestContext context) { Basic basic = new Basic(); basic.localTime = LocalTime.now(); @@ -418,6 +411,7 @@ public void testDuration(VertxTestContext context) { } @Test + @DisableFor(value = DB2, reason = "java.sql.SQLException: An error occurred with a DB2 operation, SQLCODE=-180 SQLSTATE=22007 in insert query") public void testInstant(VertxTestContext context) { Basic basic = new Basic(); basic.instant = Instant.now(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JavaTypesArrayTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JavaTypesArrayTest.java index 739fb18a0..ed593f8e4 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JavaTypesArrayTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JavaTypesArrayTest.java @@ -18,9 +18,9 @@ import java.util.function.Consumer; import org.hibernate.reactive.BaseReactiveTest; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledIf; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -34,13 +34,12 @@ import static java.lang.Boolean.TRUE; import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; -import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @Timeout(value = 10, timeUnit = MINUTES) -@DisabledIf("isNotSupported") +@DisableFor( value = ORACLE, reason = "Vert.x does not support arrays for Oracle" ) public class JavaTypesArrayTest extends BaseReactiveTest { @Override @@ -48,11 +47,6 @@ protected Set> annotatedEntities() { return Set.of( Basic.class ); } - public static boolean isNotSupported() { - // Vert.x does not support arrays for Oracle - return dbType() == ORACLE; - } - private void testField( VertxTestContext context, Basic original, Consumer consumer) { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java index 7c9a02730..d0b35932b 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java @@ -12,10 +12,9 @@ import java.util.function.Consumer; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.core.json.JsonObject; import io.vertx.junit5.Timeout; @@ -40,13 +39,12 @@ */ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor(value = DB2, reason = "java.sql.SQLException: The object 'HREACT.JSONENTITY' provided is not defined, SQLCODE=-204 SQLSTATE=42704") +@DisableFor(value = SQLSERVER, reason = "java.lang.IllegalArgumentException: Unsupported value class: class io.vertx.core.json.JsonObject") +@DisableFor(value = ORACLE, reason = "java.sql.SQLException: ORA-17004: Invalid column type: https://docs.oracle.com/error-help/db/ora-17004/") +@DisableFor(value = MARIA, reason = "ORM 6 regression, see: https://github.com/hibernate/hibernate-reactive/issues/1529") public class JsonTypeTest extends BaseReactiveTest { - // MARIA: ORM 6 regression, see: https://github.com/hibernate/hibernate-reactive/issues/1529 - @RegisterExtension - public DBSelectionExtension selectionRule = DBSelectionExtension - .skipTestsFor( DB2, SQLSERVER, ORACLE, MARIA ); - @Override protected Collection> annotatedEntities() { return List.of( Basic.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LobTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LobTypeTest.java index 5644aa9b9..e1482630b 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LobTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LobTypeTest.java @@ -11,10 +11,9 @@ import java.util.function.Consumer; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -29,7 +28,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -37,13 +35,10 @@ * Test types that we expect to work only on selected DBs. */ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor(value = DB2, reason = " Client doesn't support CLOB type. See https://github.com/hibernate/hibernate-reactive/issues/1662") +@DisableFor(value = POSTGRESQL, reason = "Client doesn't support OID type: See https://github.com/hibernate/hibernate-reactive/issues/1663") public class LobTypeTest extends BaseReactiveTest { - // Db2: Client doesn't support CLOB type. See https://github.com/hibernate/hibernate-reactive/issues/1662 - // Postgres: Client doesn't support OID type: See https://github.com/hibernate/hibernate-reactive/issues/1663 - @RegisterExtension - public DBSelectionExtension selectionRule = skipTestsFor( DB2, POSTGRESQL ); - @Override protected Collection> annotatedEntities() { return List.of( Basic.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LongLobTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LongLobTest.java index 4a4af38f0..80d8c6063 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LongLobTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LongLobTest.java @@ -11,10 +11,8 @@ import java.util.function.Consumer; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.junit5.Timeout; import io.vertx.junit5.VertxTestContext; @@ -26,18 +24,12 @@ import jakarta.persistence.Table; import static java.util.concurrent.TimeUnit.MINUTES; -import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; -import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @Timeout(value = 10, timeUnit = MINUTES) - public class LongLobTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension selectionRule = runOnlyFor( MYSQL ); - @Override protected Collection> annotatedEntities() { return List.of( Basic.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonTypeTest.java index 4319e37f9..e3786fe30 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonTypeTest.java @@ -12,10 +12,9 @@ import java.util.function.Consumer; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.core.json.JsonObject; import io.vertx.junit5.Timeout; @@ -33,7 +32,6 @@ import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.hibernate.reactive.util.impl.CompletionStages.loop; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -43,11 +41,12 @@ */ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor(value = DB2, reason = "SQLException: The object 'HREACT.JSONENTITY' provided is not defined, SQLCODE=-204 SQLSTATE=42704") +@DisableFor(value = SQLSERVER, reason = "Unsupported value class: class io.vertx.core.json.JsonObject from vertx.mssqlclient") +@DisableFor(value = MARIA, reason = " org.hibernate.HibernateException: Expecting raw JDBC value of type `io.vertx.core.json.JsonObject`, but found `java.lang.String` : [{\"int\":123,\"str\":\"hello\"}]") +@DisableFor(value = ORACLE, reason = "java.sql.SQLException: ORA-17004: Invalid column type: see https://docs.oracle.com/error-help/db/ora-17004/") public class StringToJsonTypeTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension selectionRule = skipTestsFor( DB2, SQLSERVER, MARIA, ORACLE ); - @Override protected Collection> annotatedEntities() { return List.of( Basic.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/UserJsonTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/UserJsonTypeTest.java index 8cb7ec99e..e483f847c 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/UserJsonTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/UserJsonTypeTest.java @@ -13,10 +13,9 @@ import org.hibernate.annotations.Type; import org.hibernate.reactive.BaseReactiveTest; -import org.hibernate.reactive.testing.DBSelectionExtension; +import org.hibernate.reactive.annotations.DisableFor; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import io.vertx.core.json.JsonObject; import io.vertx.junit5.Timeout; @@ -32,7 +31,6 @@ import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; -import static org.hibernate.reactive.testing.DBSelectionExtension.skipTestsFor; import static org.hibernate.reactive.util.impl.CompletionStages.loop; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -41,11 +39,11 @@ * Test types that we expect to work only on selected DBs. */ @Timeout(value = 10, timeUnit = MINUTES) +@DisableFor(value = DB2, reason = "SQLException: The object 'HREACT.JSONENTITY' provided is not defined, SQLCODE=-204 SQLSTATE=42704") +@DisableFor(value = SQLSERVER, reason = "Unsupported value class: class io.vertx.core.json.JsonObject") +@DisableFor(value = ORACLE, reason = "java.sql.SQLException: ORA-17004: Invalid column type: see https://docs.oracle.com/error-help/db/ora-17004/") public class UserJsonTypeTest extends BaseReactiveTest { - @RegisterExtension - public DBSelectionExtension selectionRule = skipTestsFor( DB2, SQLSERVER, ORACLE ); - @Override protected Collection> annotatedEntities() { return List.of( Basic.class );