Skip to content

Commit 663598d

Browse files
committed
[hibernate#929] Adapt or disable existing tests for H2
1 parent 85e1183 commit 663598d

13 files changed

+51
-10
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@
1414
import org.hibernate.reactive.containers.DatabaseConfiguration;
1515
import org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration;
1616
import org.hibernate.reactive.provider.Settings;
17+
import org.hibernate.reactive.testing.DatabaseSelectionRule;
1718

1819
import org.junit.Assert;
20+
import org.junit.Rule;
1921
import org.junit.Test;
2022

2123
import io.vertx.sqlclient.SqlConnectOptions;
2224
import org.assertj.core.api.Assertions;
2325

26+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2427
import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType;
2528

2629
/**
2730
* Test the default port is set correctly when using {@link DefaultSqlClientPoolConfiguration}
2831
*/
2932
public class DefaultPortTest {
3033

34+
@Rule
35+
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 );
36+
3137
@Test
3238
public void testDefaultPortIsSet() throws URISyntaxException {
3339
DefaultSqlClientPoolConfiguration configuration = new DefaultSqlClientPoolConfiguration();

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import java.util.Collection;
2323
import java.util.List;
2424

25+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2526
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA;
2627
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
2728

2829
public class FormulaTest extends BaseReactiveTest {
2930

3031
@Rule
31-
public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( MARIA, MYSQL );
32+
public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( MARIA, MYSQL, H2 );
3233

3334
@Override
3435
protected Collection<Class<?>> annotatedEntities() {

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
import org.hibernate.HibernateException;
1616
import org.hibernate.cfg.AvailableSettings;
1717
import org.hibernate.cfg.Configuration;
18+
import org.hibernate.reactive.containers.DatabaseConfiguration;
19+
import org.hibernate.reactive.exception.ConstraintViolationException;
1820
import org.hibernate.reactive.mutiny.Mutiny;
1921

2022
import org.junit.Test;
2123

2224
import io.vertx.ext.unit.TestContext;
2325

26+
import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType;
27+
2428
public class MutinyExceptionsTest extends BaseReactiveTest {
2529

2630
@Override
@@ -48,7 +52,12 @@ public void testDuplicateKeyException(TestContext context) {
4852
.onItem().call( Mutiny.Session::flush )
4953
.onItem().invoke( ignore -> context.fail( "Expected exception not thrown" ) )
5054
.onFailure().recoverWithItem( err -> {
51-
context.assertEquals( getExpectedException(), err.getClass() );
55+
if( dbType() == DatabaseConfiguration.DBType.H2 ) {
56+
context.assertTrue( ConstraintViolationException.class == err.getClass() ||
57+
getExpectedException() == err.getClass() );
58+
} else {
59+
context.assertEquals( getExpectedException(), err.getClass() );
60+
}
5261
return null;
5362
} )
5463
);

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.vertx.ext.unit.TestContext;
2323

2424
import static java.util.Arrays.asList;
25+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2526
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA;
2627
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL;
2728
import static org.hibernate.reactive.testing.DatabaseSelectionRule.runOnlyFor;
@@ -103,8 +104,8 @@ public String toString() {
103104

104105
public static class ForOtherDbsTest extends UUIDAsBinaryType {
105106

106-
@Rule
107-
public DatabaseSelectionRule rule = skipTestsFor( MYSQL, MARIA );
107+
@Rule // Select a UUID field doesn't work with Oracle
108+
public DatabaseSelectionRule rule = skipTestsFor( MYSQL, MARIA, H2 );
108109

109110
@Override
110111
protected Collection<Class<?>> annotatedEntities() {

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

+6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@
1717
import org.hibernate.dialect.SQLServer2012Dialect;
1818
import org.hibernate.reactive.containers.DatabaseConfiguration;
1919
import org.hibernate.reactive.provider.Settings;
20+
import org.hibernate.reactive.testing.DatabaseSelectionRule;
2021

22+
import org.junit.Rule;
2123
import org.junit.Test;
2224

2325
import io.vertx.ext.unit.TestContext;
2426

27+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2528
import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType;
2629

2730
public class UriConfigTest extends BaseReactiveTest {
2831

32+
@Rule
33+
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 );
34+
2935
@Override
3036
protected Configuration constructConfiguration() {
3137
Class<? extends Dialect> dialect;

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

+6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
import org.hibernate.cfg.Configuration;
1212
import org.hibernate.reactive.containers.DatabaseConfiguration;
1313
import org.hibernate.reactive.provider.Settings;
14+
import org.hibernate.reactive.testing.DatabaseSelectionRule;
1415

16+
import org.junit.Rule;
1517
import org.junit.Test;
1618

1719
import io.vertx.ext.unit.TestContext;
1820

1921
import static org.assertj.core.api.Assertions.assertThat;
22+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2023

2124
/**
2225
* Check that the right exception is thrown when there is an error with the credentials.
@@ -28,6 +31,9 @@
2831
*/
2932
public class WrongCredentialsTest extends BaseReactiveTest {
3033

34+
@Rule
35+
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( H2 );
36+
3137
@Override
3238
protected Configuration constructConfiguration() {
3339
Configuration configuration = super.constructConfiguration();

hibernate-reactive-core/src/test/java/org/hibernate/reactive/configuration/JdbcUrlParserTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
import org.hibernate.HibernateError;
1313
import org.hibernate.reactive.pool.impl.DefaultSqlClientPool;
1414
import org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration;
15+
import org.hibernate.reactive.testing.DatabaseSelectionRule;
1516

17+
import org.junit.Rule;
1618
import org.junit.Test;
1719

1820
import io.vertx.sqlclient.SqlConnectOptions;
1921

2022
import static org.assertj.core.api.Assertions.assertThat;
2123
import static org.assertj.core.api.Assertions.fail;
24+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2225
import static org.hibernate.reactive.containers.DatabaseConfiguration.createJdbcUrl;
2326
import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType;
2427
import static org.junit.Assert.assertThrows;
@@ -33,6 +36,9 @@ public class JdbcUrlParserTest {
3336

3437
private static final String DEFAULT_DB = "hreactDB";
3538

39+
@Rule
40+
public DatabaseSelectionRule rule = DatabaseSelectionRule.skipTestsFor( H2 );
41+
3642
@Test
3743
public void exceptionWhenNull() {
3844
final HibernateError error = assertThrows( HibernateError.class, () -> {

hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DatabaseConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public enum DBType {
2525
POSTGRESQL( PostgreSQLDatabase.INSTANCE, 5432, "POSTGRES", "PG" ),
2626
COCKROACHDB( CockroachDBDatabase.INSTANCE, 26257, "COCKROACH" ),
2727
SQLSERVER( MSSQLServerDatabase.INSTANCE, 1433, "MSSQL", "MSSQLSERVER" ),
28-
ORACLE( OracleDatabase.INSTANCE, 1521 );
28+
ORACLE( OracleDatabase.INSTANCE, 1521 ),
29+
H2( H2Database.INSTANCE, -1 );
2930

3031
private final TestableDatabase configuration;
3132
private final int defaultPort;

hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaUpdateTestBase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.vertx.ext.unit.TestContext;
2222

2323
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
24+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2425
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
2526
import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType;
2627
import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED;
@@ -53,7 +54,7 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
5354
}
5455

5556
@Rule
56-
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2 );
57+
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2, H2 );
5758

5859
protected Configuration constructConfiguration(String action) {
5960
Configuration configuration = super.constructConfiguration();

hibernate-reactive-core/src/test/java/org/hibernate/reactive/schema/SchemaValidationTestBase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import javax.persistence.Table;
1313

1414
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
15+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
1516
import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.GROUPED;
1617
import static org.hibernate.tool.schema.JdbcMetadaAccessStrategy.INDIVIDUALLY;
1718

@@ -59,7 +60,7 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
5960
}
6061

6162
@Rule
62-
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2 );
63+
public DatabaseSelectionRule dbRule = DatabaseSelectionRule.skipTestsFor( DB2, H2 );
6364

6465
protected Configuration constructConfiguration(String action) {
6566
Configuration configuration = super.constructConfiguration();

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.vertx.ext.unit.TestContext;
2626

2727
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
28+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2829
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
2930
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
3031

@@ -34,7 +35,7 @@
3435
public class JsonTypeTest extends BaseReactiveTest {
3536

3637
@Rule
37-
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE);
38+
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE, H2);
3839

3940
@Override
4041
protected Collection<Class<?>> annotatedEntities() {

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonTypeTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.function.Consumer;
2626

2727
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
28+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
2829
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA;
2930
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
3031
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
@@ -35,7 +36,7 @@
3536
public class StringToJsonTypeTest extends BaseReactiveTest {
3637

3738
@Rule
38-
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, MARIA, ORACLE );
39+
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, MARIA, ORACLE, H2 );
3940

4041
@Override
4142
protected Collection<Class<?>> annotatedEntities() {

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/UserJsonTypeTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.vertx.ext.unit.TestContext;
2828

2929
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
30+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.H2;
3031
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.ORACLE;
3132
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.SQLSERVER;
3233

@@ -36,7 +37,7 @@
3637
public class UserJsonTypeTest extends BaseReactiveTest {
3738

3839
@Rule
39-
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE );
40+
public DatabaseSelectionRule selectionRule = DatabaseSelectionRule.skipTestsFor( DB2, SQLSERVER, ORACLE, H2 );
4041

4142
@Override
4243
protected Collection<Class<?>> annotatedEntities() {

0 commit comments

Comments
 (0)