Skip to content

Commit c0633f1

Browse files
committed
[#689] Fix MultipleContextTest
1 parent 58ae6c8 commit c0633f1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package org.hibernate.reactive;
77

8+
import java.util.Locale;
89
import java.util.concurrent.CompletableFuture;
910
import javax.persistence.Entity;
1011
import javax.persistence.Id;
@@ -37,7 +38,8 @@
3738
*/
3839
public class MultipleContextTest extends BaseReactiveTest {
3940

40-
private static final String ERROR_MESSAGE = "Detected use of the reactive Session from a different Thread";
41+
private static final String ERROR_MESSAGE_LOWER_CASED = "Detected use of the reactive Session from a different Thread"
42+
.toLowerCase( Locale.ROOT );
4143

4244
// These tests will fail before touching the database, so there is no reason
4345
// to run them on all databases
@@ -64,7 +66,6 @@ public void testPersistWithStage(TestContext testContext) {
6466
// Run test in the new context
6567
newContext.runOnContext( event -> test( async, testContext, session
6668
.persist( new Competition( "Cheese Rolling" ) )
67-
.thenCompose( v -> session.flush() )
6869
.handle( (v, e) -> assertExceptionThrown( e ).join() ) )
6970
);
7071
}
@@ -99,7 +100,6 @@ public void testOnPersistWithMutiny(TestContext testContext) {
99100
// Run test in the new context
100101
newContext.runOnContext( event -> test( async, testContext, session
101102
.persist( new Competition( "Cheese Rolling" ) )
102-
.call( session::flush )
103103
.onItemOrFailure()
104104
.transformToUni( (unused, e) -> Uni.createFrom().completionStage( assertExceptionThrown( e ) ) ) )
105105
);
@@ -129,7 +129,7 @@ private static CompletableFuture<Void> assertExceptionThrown(Throwable e) {
129129
Throwable t = e;
130130
while ( t != null ) {
131131
if ( t.getClass().equals( IllegalStateException.class )
132-
&& t.getMessage().contains( ERROR_MESSAGE ) ) {
132+
&& expectedMessage( t ) ) {
133133
result.complete( null );
134134
return result;
135135
}
@@ -139,6 +139,11 @@ private static CompletableFuture<Void> assertExceptionThrown(Throwable e) {
139139
return result;
140140
}
141141

142+
private static boolean expectedMessage(Throwable t) {
143+
return t.getMessage().toLowerCase( Locale.ROOT )
144+
.contains( ERROR_MESSAGE_LOWER_CASED );
145+
}
146+
142147
@Entity
143148
static class Competition {
144149
@Id

0 commit comments

Comments
 (0)