|
32 | 32 |
|
33 | 33 | import static java.util.concurrent.TimeUnit.MINUTES;
|
34 | 34 | import static org.assertj.core.api.Assertions.assertThat;
|
35 |
| -import static org.junit.jupiter.api.Assertions.assertEquals; |
36 |
| -import static org.junit.jupiter.api.Assertions.assertFalse; |
37 |
| -import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
38 |
| -import static org.junit.jupiter.api.Assertions.assertNotEquals; |
39 |
| -import static org.junit.jupiter.api.Assertions.assertNotNull; |
40 |
| -import static org.junit.jupiter.api.Assertions.assertTrue; |
| 35 | +import static org.junit.jupiter.api.Assertions.*; |
41 | 36 |
|
42 | 37 | @Timeout(value = 10, timeUnit = MINUTES)
|
43 | 38 |
|
@@ -969,6 +964,42 @@ context, openSession()
|
969 | 964 | );
|
970 | 965 | }
|
971 | 966 |
|
| 967 | + @Test |
| 968 | + public void testCurrentSession(VertxTestContext context) { |
| 969 | + test( context, |
| 970 | + getSessionFactory().withSession(session -> |
| 971 | + getSessionFactory().withSession(s -> { |
| 972 | + assertEquals(session, s); |
| 973 | + Stage.Session currentSession = getSessionFactory().getCurrentSession(); |
| 974 | + assertNotNull(currentSession); |
| 975 | + assertTrue(currentSession.isOpen()); |
| 976 | + assertEquals(session, currentSession); |
| 977 | + return CompletionStages.voidFuture(); |
| 978 | + }) |
| 979 | + .thenAccept(v -> assertNotNull(getSessionFactory().getCurrentSession())) |
| 980 | + ) |
| 981 | + .thenAccept(v -> assertNull(getSessionFactory().getCurrentSession())) |
| 982 | + ); |
| 983 | + } |
| 984 | + |
| 985 | + @Test |
| 986 | + public void testCurrentStatelessSession(VertxTestContext context) { |
| 987 | + test( context, |
| 988 | + getSessionFactory().withStatelessSession(session -> |
| 989 | + getSessionFactory().withStatelessSession(s -> { |
| 990 | + assertEquals(session, s); |
| 991 | + Stage.StatelessSession currentSession = getSessionFactory().getCurrentStatelessSession(); |
| 992 | + assertNotNull(currentSession); |
| 993 | + assertTrue(currentSession.isOpen()); |
| 994 | + assertEquals(session, currentSession); |
| 995 | + return CompletionStages.voidFuture(); |
| 996 | + }) |
| 997 | + .thenAccept(v -> assertNotNull(getSessionFactory().getCurrentStatelessSession())) |
| 998 | + ) |
| 999 | + .thenAccept(v -> assertNull(getSessionFactory().getCurrentStatelessSession())) |
| 1000 | + ); |
| 1001 | + } |
| 1002 | + |
972 | 1003 | private void assertThatPigsAreEqual(GuineaPig expected, GuineaPig actual) {
|
973 | 1004 | assertNotNull( actual );
|
974 | 1005 | assertEquals( expected.getId(), actual.getId() );
|
|
0 commit comments