5
5
*/
6
6
package org .hibernate .reactive ;
7
7
8
+ import java .util .Locale ;
8
9
import java .util .concurrent .CompletableFuture ;
9
10
import javax .persistence .Entity ;
10
11
import javax .persistence .Id ;
37
38
*/
38
39
public class MultipleContextTest extends BaseReactiveTest {
39
40
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 );
41
43
42
44
// These tests will fail before touching the database, so there is no reason
43
45
// to run them on all databases
@@ -64,7 +66,6 @@ public void testPersistWithStage(TestContext testContext) {
64
66
// Run test in the new context
65
67
newContext .runOnContext ( event -> test ( async , testContext , session
66
68
.persist ( new Competition ( "Cheese Rolling" ) )
67
- .thenCompose ( v -> session .flush () )
68
69
.handle ( (v , e ) -> assertExceptionThrown ( e ).join () ) )
69
70
);
70
71
}
@@ -99,7 +100,6 @@ public void testOnPersistWithMutiny(TestContext testContext) {
99
100
// Run test in the new context
100
101
newContext .runOnContext ( event -> test ( async , testContext , session
101
102
.persist ( new Competition ( "Cheese Rolling" ) )
102
- .call ( session ::flush )
103
103
.onItemOrFailure ()
104
104
.transformToUni ( (unused , e ) -> Uni .createFrom ().completionStage ( assertExceptionThrown ( e ) ) ) )
105
105
);
@@ -129,7 +129,7 @@ private static CompletableFuture<Void> assertExceptionThrown(Throwable e) {
129
129
Throwable t = e ;
130
130
while ( t != null ) {
131
131
if ( t .getClass ().equals ( IllegalStateException .class )
132
- && t . getMessage (). contains ( ERROR_MESSAGE ) ) {
132
+ && expectedMessage ( t ) ) {
133
133
result .complete ( null );
134
134
return result ;
135
135
}
@@ -139,6 +139,11 @@ private static CompletableFuture<Void> assertExceptionThrown(Throwable e) {
139
139
return result ;
140
140
}
141
141
142
+ private static boolean expectedMessage (Throwable t ) {
143
+ return t .getMessage ().toLowerCase ( Locale .ROOT )
144
+ .contains ( ERROR_MESSAGE_LOWER_CASED );
145
+ }
146
+
142
147
@ Entity
143
148
static class Competition {
144
149
@ Id
0 commit comments