diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ReactiveConnectionPoolInitiator.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ReactiveConnectionPoolInitiator.java index 1e141939f..407ced196 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ReactiveConnectionPoolInitiator.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ReactiveConnectionPoolInitiator.java @@ -40,7 +40,7 @@ public ReactiveConnectionPool initiateService(Map configurationValues, ServiceRe Object configValue = configurationValues.get( Settings.SQL_CLIENT_POOL ); String dbType = (String) configurationValues.get( "db" ); - if ( dbType.equalsIgnoreCase( "h2" ) ) { + if ( dbType != null && dbType.equalsIgnoreCase( "h2" ) ) { configValue = "org.hibernate.reactive.pool.impl.H2SqlClientPool"; } diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BaseReactiveTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BaseReactiveTest.java index d364cca07..5c1db2db0 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BaseReactiveTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BaseReactiveTest.java @@ -136,6 +136,8 @@ protected Configuration constructConfiguration() { configuration.setProperty( Settings.HBM2DDL_IMPORT_FILES, "/db2.sql" ); doneTablespace = true; } + + configuration.setProperty( Settings.URL, DatabaseConfiguration.getJdbcUrl() ); //Use JAVA_TOOL_OPTIONS='-Dhibernate.show_sql=true' configuration.setProperty( Settings.SHOW_SQL, System.getProperty(Settings.SHOW_SQL, "false") ); configuration.setProperty( Settings.FORMAT_SQL, System.getProperty(Settings.FORMAT_SQL, "false") ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java index 364845c91..bf5520869 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java @@ -18,17 +18,23 @@ import org.hibernate.reactive.pool.impl.OracleParameters; import org.hibernate.reactive.pool.impl.PostgresParameters; import org.hibernate.reactive.pool.impl.SQLServerParameters; +import org.hibernate.reactive.testing.DatabaseSelectionRule; +import org.junit.Rule; import org.junit.Test; import io.vertx.ext.unit.TestContext; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; public class BatchQueryOnConnectionTest extends BaseReactiveTest { private static final int BATCH_SIZE = 20; + @Rule + public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Override protected Set> annotatedEntities() { return Set.of( DataPoint.class ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java index 6c4fe6705..3f370ce7c 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java @@ -13,17 +13,23 @@ import org.hibernate.reactive.pool.impl.SqlClientConnection; import org.hibernate.reactive.stage.impl.StageSessionImpl; import org.hibernate.reactive.stage.impl.StageStatelessSessionImpl; +import org.hibernate.reactive.testing.DatabaseSelectionRule; +import org.junit.Rule; import org.junit.Test; import io.vertx.ext.unit.TestContext; import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.util.impl.CompletionStages.loop; import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; public class BatchingConnectionTest extends ReactiveSessionTest { + @Rule + public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/DefaultPortTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/DefaultPortTest.java index 13d54b4d6..293a7f2b6 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/DefaultPortTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/DefaultPortTest.java @@ -14,13 +14,16 @@ import org.hibernate.reactive.containers.DatabaseConfiguration; import org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration; import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.testing.DatabaseSelectionRule; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; import io.vertx.sqlclient.SqlConnectOptions; import org.assertj.core.api.Assertions; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; /** @@ -28,6 +31,9 @@ */ public class DefaultPortTest { + @Rule + public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Test public void testDefaultPortIsSet() throws URISyntaxException { DefaultSqlClientPoolConfiguration configuration = new DefaultSqlClientPoolConfiguration(); 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 699164b46..2e866cc3f 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 @@ -22,13 +22,14 @@ import java.util.Collection; import java.util.List; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; public class FormulaTest extends BaseReactiveTest { @Rule - public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( MARIA, MYSQL ); + public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( MARIA, MYSQL, H2 ); @Override protected Collection> annotatedEntities() { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinyExceptionsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinyExceptionsTest.java index 3790dcd2a..d02b96455 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinyExceptionsTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinyExceptionsTest.java @@ -15,12 +15,16 @@ import org.hibernate.HibernateException; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.containers.DatabaseConfiguration; +import org.hibernate.reactive.exception.ConstraintViolationException; import org.hibernate.reactive.mutiny.Mutiny; import org.junit.Test; import io.vertx.ext.unit.TestContext; +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; + public class MutinyExceptionsTest extends BaseReactiveTest { @Override @@ -48,7 +52,12 @@ public void testDuplicateKeyException(TestContext context) { .onItem().call( Mutiny.Session::flush ) .onItem().invoke( ignore -> context.fail( "Expected exception not thrown" ) ) .onFailure().recoverWithItem( err -> { - context.assertEquals( getExpectedException(), err.getClass() ); + if( dbType() == DatabaseConfiguration.DBType.H2 ) { + context.assertTrue( ConstraintViolationException.class == err.getClass() || + getExpectedException() == err.getClass() ); + } else { + context.assertEquals( getExpectedException(), err.getClass() ); + } return null; } ) ); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java index 77b6b50cc..b94a6818a 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java @@ -22,6 +22,7 @@ import io.vertx.ext.unit.TestContext; import static java.util.Arrays.asList; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; @@ -105,7 +106,7 @@ public String toString() { public static class ForOtherDbsTest extends UUIDAsBinaryType { @Rule // Select a UUID field doesn't work with Oracle - public DatabaseSelectionRule rule = skipTestsFor( MYSQL, MARIA, ORACLE ); + public DatabaseSelectionRule rule = skipTestsFor( MYSQL, MARIA, ORACLE, H2 ); @Override protected Collection> annotatedEntities() { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UriConfigTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UriConfigTest.java index 7a0c96a0a..1996fe469 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UriConfigTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UriConfigTest.java @@ -17,15 +17,21 @@ import org.hibernate.dialect.SQLServer2012Dialect; import org.hibernate.reactive.containers.DatabaseConfiguration; import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.testing.DatabaseSelectionRule; +import org.junit.Rule; import org.junit.Test; import io.vertx.ext.unit.TestContext; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; public class UriConfigTest extends BaseReactiveTest { + @Rule + public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Override protected Configuration constructConfiguration() { Class dialect; diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/WrongCredentialsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/WrongCredentialsTest.java index 2cddf24d7..bc8d53d59 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/WrongCredentialsTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/WrongCredentialsTest.java @@ -11,12 +11,15 @@ import org.hibernate.cfg.Configuration; import org.hibernate.reactive.containers.DatabaseConfiguration; import org.hibernate.reactive.provider.Settings; +import org.hibernate.reactive.testing.DatabaseSelectionRule; +import org.junit.Rule; import org.junit.Test; import io.vertx.ext.unit.TestContext; import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; /** * Check that the right exception is thrown when there is an error with the credentials. @@ -28,6 +31,9 @@ */ public class WrongCredentialsTest extends BaseReactiveTest { + @Rule + public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/JdbcUrlParserTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/JdbcUrlParserTest.java index 51b679062..99e972dac 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/JdbcUrlParserTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/JdbcUrlParserTest.java @@ -12,13 +12,16 @@ import org.hibernate.HibernateError; import org.hibernate.reactive.pool.impl.DefaultSqlClientPool; import org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration; +import org.hibernate.reactive.testing.DatabaseSelectionRule; +import org.junit.Rule; import org.junit.Test; import io.vertx.sqlclient.SqlConnectOptions; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.createJdbcUrl; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; import static org.junit.Assert.assertThrows; @@ -33,6 +36,9 @@ public class JdbcUrlParserTest { private static final String DEFAULT_DB = "hreactDB"; + @Rule + public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( H2 ); + @Test public void exceptionWhenNull() { final HibernateError error = assertThrows( HibernateError.class, () -> { diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DatabaseConfiguration.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DatabaseConfiguration.java index 3bd7f11b2..7584ebf38 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DatabaseConfiguration.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DatabaseConfiguration.java @@ -25,7 +25,8 @@ public enum DBType { POSTGRESQL( PostgreSQLDatabase.INSTANCE, 5432, "POSTGRES", "PG" ), COCKROACHDB( CockroachDBDatabase.INSTANCE, 26257, "COCKROACH" ), SQLSERVER( MSSQLServerDatabase.INSTANCE, 1433, "MSSQL", "MSSQLSERVER" ), - ORACLE( OracleDatabase.INSTANCE, 1521 ); + ORACLE( OracleDatabase.INSTANCE, 1521 ), + H2( H2Database.INSTANCE, -1 ); private final TestableDatabase configuration; private final int defaultPort; 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 692e63d26..b0dac7d0e 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 @@ -21,6 +21,7 @@ import io.vertx.ext.unit.TestContext; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; @@ -53,7 +54,7 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Rule - public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2 ); + public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2, H2 ); protected Configuration constructConfiguration(String action) { Configuration configuration = super.constructConfiguration(); 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 8b67e2b35..9afdaf537 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 @@ -12,6 +12,7 @@ import javax.persistence.Table; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED; import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.INDIVIDUALLY; @@ -59,7 +60,7 @@ protected Configuration constructConfiguration(String hbm2DdlOption) { } @Rule - public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2 ); + public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2, H2 ); protected Configuration constructConfiguration(String action) { Configuration configuration = super.constructConfiguration(); 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 be7446d90..83a9b08ce 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 @@ -25,6 +25,7 @@ import io.vertx.ext.unit.TestContext; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; @@ -34,7 +35,7 @@ public class JsonTypeTest extends BaseReactiveTest { @Rule - public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE); + public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE, H2); @Override protected Collection> annotatedEntities() { 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 992e7f656..916e5d190 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 @@ -25,6 +25,7 @@ import java.util.function.Consumer; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; 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; @@ -35,7 +36,7 @@ public class StringToJsonTypeTest extends BaseReactiveTest { @Rule - public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, MARIA, ORACLE ); + public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, MARIA, ORACLE, H2 ); @Override protected Collection> annotatedEntities() { 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 fa8e1165e..907a2d942 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 @@ -27,6 +27,7 @@ import io.vertx.ext.unit.TestContext; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE; import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER; @@ -36,7 +37,7 @@ public class UserJsonTypeTest extends BaseReactiveTest { @Rule - public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE ); + public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE, H2 ); @Override protected Collection> annotatedEntities() {