From 26ce98fbcef69b9947d29ce8eb3eb9feb7ba3172 Mon Sep 17 00:00:00 2001 From: Davide Date: Tue, 3 Aug 2021 21:13:49 +0100 Subject: [PATCH] [#877] Refactor tests for batching connection We shouldn't ignore the return value of closeSession --- .../reactive/ReactiveSessionTest.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java index 88d403efa8..072968b799 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java @@ -11,7 +11,6 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.reactive.common.AffectedEntities; -import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.mutiny.impl.MutinySessionImpl; import org.hibernate.reactive.pool.BatchingConnection; import org.hibernate.reactive.stage.Stage; @@ -707,25 +706,19 @@ public void testBatching(TestContext context) { } @Test - public void testBatchingConnection() { - Stage.Session session = getSessionFactory().openSession(); - try { - assertThat(((StageSessionImpl)session).getReactiveConnection()).isInstanceOf( BatchingConnection.class ); - } - finally { - closeSession( session ); - } + public void testBatchingConnection(TestContext context) { + test( context, openSession() + .thenAccept( session -> assertThat( ( (StageSessionImpl) session ).getReactiveConnection() ) + .isInstanceOf( BatchingConnection.class ) ) + ); } @Test - public void testBatchingConnectionMutiny() { - Mutiny.Session session = getMutinySessionFactory().openSession(); - try { - assertThat(((MutinySessionImpl)session).getReactiveConnection() ).isInstanceOf( BatchingConnection.class ); - } - finally { - closeSession( session ); - } + public void testBatchingConnectionMutiny(TestContext context) { + test( context, openMutinySession() + .invoke( session -> assertThat( ( (MutinySessionImpl) session ).getReactiveConnection() ) + .isInstanceOf( BatchingConnection.class ) ) + ); } @Test