diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java index 62c4446c871..1465b334eda 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * InfinispanSessionDataStoreTest @@ -106,15 +106,7 @@ public class InfinispanSessionDataStoreTest extends AbstractSessionDataStoreTest ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class, () -> store.load("222")); } /** diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java index 5f45903196b..37f92e3b447 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * SerializedInfinispanSessionDataStoreTest @@ -107,15 +107,7 @@ public class SerializedInfinispanSessionDataStoreTest extends AbstractSessionDat ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class,() -> store.load("222")); } /** diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java index 510ffdd6a0c..718a38e06e3 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java @@ -38,7 +38,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * RemoteInfinispanSessionDataStoreTest @@ -130,15 +130,7 @@ public class RemoteInfinispanSessionDataStoreTest extends AbstractSessionDataSto ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class, () -> store.load("222")); } @Test