You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/07/14 19:43:09 UTC
[commons-pool] 03/04: Use modern JUnit API
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
commit 6e381f4649a8bd9f1a4f17139445488fa30dcfd1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 14 15:40:33 2023 -0400
Use modern JUnit API
---
.../commons/pool2/impl/TestSoftRefOutOfMemory.java | 37 ++++------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java b/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
index 55044f3b..784cb5ec 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
@@ -19,6 +19,7 @@ package org.apache.commons.pool2.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -218,40 +219,16 @@ public class TestSoftRefOutOfMemory {
*/
@Test
public void testOutOfMemoryError() throws Exception {
- pool = new SoftReferenceObjectPool<>(
- new OomeFactory(OomeTrigger.CREATE));
-
- try {
- pool.borrowObject();
- fail("Expected out of memory.");
- }
- catch (final OutOfMemoryError ex) {
- // expected
- }
+ pool = new SoftReferenceObjectPool<>(new OomeFactory(OomeTrigger.CREATE));
+ assertThrows(OutOfMemoryError.class, pool::borrowObject);
pool.close();
- pool = new SoftReferenceObjectPool<>(
- new OomeFactory(OomeTrigger.VALIDATE));
-
- try {
- pool.borrowObject();
- fail("Expected out of memory.");
- }
- catch (final OutOfMemoryError ex) {
- // expected
- }
+ pool = new SoftReferenceObjectPool<>(new OomeFactory(OomeTrigger.VALIDATE));
+ assertThrows(OutOfMemoryError.class, pool::borrowObject);
pool.close();
- pool = new SoftReferenceObjectPool<>(
- new OomeFactory(OomeTrigger.DESTROY));
-
- try {
- pool.borrowObject();
- fail("Expected out of memory.");
- }
- catch (final OutOfMemoryError ex) {
- // expected
- }
+ pool = new SoftReferenceObjectPool<>(new OomeFactory(OomeTrigger.DESTROY));
+ assertThrows(OutOfMemoryError.class, pool::borrowObject);
pool.close();
}