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:06 UTC
[commons-pool] branch master updated (0a71dc8d -> 41fc4734)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
from 0a71dc8d Use modern JUnit API
new 51e9ede9 No need for test to catch and rethrow
new 2230d75d No need for test to catch and rethrow
new 6e381f46 Use modern JUnit API
new 41fc4734 Use forEach()
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/commons/pool2/TestPoolUtils.java | 4 +--
.../pool2/impl/TestGenericKeyedObjectPool.java | 6 +---
.../commons/pool2/impl/TestGenericObjectPool.java | 6 +---
.../commons/pool2/impl/TestSoftRefOutOfMemory.java | 37 ++++------------------
4 files changed, 10 insertions(+), 43 deletions(-)
[commons-pool] 03/04: Use modern JUnit API
Posted by gg...@apache.org.
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();
}
[commons-pool] 02/04: No need for test to catch and rethrow
Posted by gg...@apache.org.
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 2230d75d0f71b9011b4c5cbca4250a45ee79da53
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 14 15:38:27 2023 -0400
No need for test to catch and rethrow
---
.../java/org/apache/commons/pool2/impl/TestGenericObjectPool.java | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
index eb6582f1..08db55d8 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -1054,11 +1054,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
final Thread t = new Thread(threads[i]);
t.start();
// Short delay to ensure threads start in correct order
- try {
- Thread.sleep(10);
- } catch (final InterruptedException e) {
- fail(e.toString());
- }
+ Thread.sleep(10);
}
// Return objects, other threads should get served in order
[commons-pool] 01/04: No need for test to catch and rethrow
Posted by gg...@apache.org.
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 51e9ede9201c4a3c69ce837bf9a2732c258567ef
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 14 15:37:39 2023 -0400
No need for test to catch and rethrow
---
.../org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
index 3e60202a..e5b37f7f 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -970,11 +970,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool {
final Thread t = new Thread(threads[i]);
t.start();
// Short delay to ensure threads start in correct order
- try {
- Thread.sleep(10);
- } catch (final InterruptedException e) {
- fail(e.toString());
- }
+ Thread.sleep(10);
}
// Return objects, other threads should get served in order
[commons-pool] 04/04: Use forEach()
Posted by gg...@apache.org.
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 41fc473462afde220088347abe02d597630e4dc7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 14 15:43:01 2023 -0400
Use forEach()
---
src/test/java/org/apache/commons/pool2/TestPoolUtils.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
index 0fe89770..502aab81 100644
--- a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
+++ b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
@@ -241,9 +241,7 @@ public class TestPoolUtils {
final Map<String, TimerTask> tasks = PoolUtils.checkMinIdle(pool, keys, 1, CHECK_PERIOD);
Thread.sleep(CHECK_SLEEP_PERIOD); // will check CHECK_COUNT more times.
- for (final TimerTask task : tasks.values()) {
- task.cancel();
- }
+ tasks.values().forEach(TimerTask::cancel);
final List<String> expectedMethods = new ArrayList<>();
for (int i = 0; i < CHECK_COUNT * keys.size(); i++) {