Skip to content

Commit 3b80f9c

Browse files
committed
[912] Make the tests work consistently
1 parent 22c213e commit 3b80f9c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.io.Serializable;
99
import java.util.Objects;
10+
import java.util.concurrent.CompletionStage;
1011
import javax.persistence.CascadeType;
1112
import javax.persistence.Entity;
1213
import javax.persistence.ForeignKey;
@@ -80,8 +81,24 @@ public void before(TestContext context) {
8081
createHbm2ddlConf.addAnnotatedClass( ASimpleFirst.class );
8182
createHbm2ddlConf.addAnnotatedClass( AOther.class );
8283

83-
test( context, setupSessionFactory( createHbm2ddlConf )
84-
.thenCompose( v -> factoryManager.stop() ) );
84+
test( context, dropSequenceIfExists( createHbm2ddlConf )
85+
.thenCompose( ignore -> setupSessionFactory( createHbm2ddlConf )
86+
.thenCompose( v -> factoryManager.stop() ) ) );
87+
}
88+
89+
// See HHH-14835: Vert.x throws an exception when the catalog is specified.
90+
// Because it happens during schema creation, the error is ignored and the build won't fail
91+
// if one of the previous tests has already created the sequence.
92+
// This method make sure that the sequence is deleted if it exists, so that these tests
93+
// fail consistently when the wrong ORM version is used.
94+
private CompletionStage<Void> dropSequenceIfExists(Configuration createHbm2ddlConf) {
95+
return setupSessionFactory( createHbm2ddlConf )
96+
.thenCompose( v -> getSessionFactory()
97+
.withTransaction( (session, transaction) -> session
98+
.createNativeQuery( "drop sequence if exists dbo.hibernate_sequence" )
99+
.executeUpdate() ) )
100+
.handle( (res, err) -> null )
101+
.thenCompose( v -> factoryManager.stop() );
85102
}
86103

87104
@After

0 commit comments

Comments
 (0)