Skip to content

Replace DBSelectionExtension with annotations #1828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Class<?>> annotatedEntities() {
return List.of( Record.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Class<?>> annotatedEntities() {
return List.of( Family.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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." );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Class<?>> annotatedEntities() {
return List.of( Record.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Class<?>> annotatedEntities() {
return List.of( GeneratedWithIdentity.class, GeneratedRegular.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Class<?>> annotatedEntities() {
return List.of( GeneratedWithIdentity.class, GeneratedRegular.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -47,13 +45,11 @@
* </p>
*/
@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<Class<?>> annotatedEntities() {
return List.of( GeneratedRegular.class );
Expand Down
Loading