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 2022/05/22 20:22:16 UTC
[commons-pool] 02/03: Using a custom exception for unit tests to better test and display usage of generic exceptions
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 6d77f4a3ddb23cb5144f0e671e284aa795378293
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 16:12:18 2022 -0400
Using a custom exception for unit tests to better test and display usage
of generic exceptions
---
src/test/java/org/apache/commons/pool2/TestObjectPool.java | 8 ++++----
.../java/org/apache/commons/pool2/impl/TestGenericObjectPool.java | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/TestObjectPool.java b/src/test/java/org/apache/commons/pool2/TestObjectPool.java
index cc04b00a..4b9a5b9f 100644
--- a/src/test/java/org/apache/commons/pool2/TestObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/TestObjectPool.java
@@ -269,12 +269,12 @@ public abstract class TestObjectPool {
}
final List<MethodCall> expectedMethods = new ArrayList<>();
- /// Test correct behavior code paths
+ // Test correct behavior code paths
pool.addObjects(5);
pool.close();
- //// Test exception handling close should swallow failures
+ // Test exception handling close should swallow failures
try {
pool = makeEmptyPool(factory);
} catch (final UnsupportedOperationException uoe) {
@@ -298,7 +298,7 @@ public abstract class TestObjectPool {
final List<MethodCall> expectedMethods = new ArrayList<>();
Object obj;
- /// Test correct behavior code paths
+ // Test correct behavior code paths
obj = pool.borrowObject();
clear(factory, expectedMethods);
@@ -308,7 +308,7 @@ public abstract class TestObjectPool {
expectedMethods.add(new MethodCall("destroyObject", obj));
assertEquals(expectedMethods, factory.getMethodCalls());
- //// Test exception handling of invalidateObject
+ // Test exception handling of invalidateObject
reset(pool, factory, expectedMethods);
final Object obj2 = pool.borrowObject();
clear(factory, expectedMethods);
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 9ee83b07..f7cae2bf 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -2294,7 +2294,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
// Create enough threads so half the threads will have to wait
final WaitingTestThread<TestException>[] wtt = new WaitingTestThread[threads * 2];
for (int i = 0; i < wtt.length; i++) {
- wtt[i] = new WaitingTestThread(genericObjectPool,holdTime);
+ wtt[i] = new WaitingTestThread<>(genericObjectPool, holdTime);
}
final long originMillis = System.currentTimeMillis() - 1000;
for (final WaitingTestThread<TestException> element : wtt) {
@@ -2528,7 +2528,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
// Make validation fail - this will cause create() to return null
simpleFactory.setValid(false);
// Create a take waiter
- final WaitingTestThread wtt = new WaitingTestThread(genericObjectPool, 200);
+ final WaitingTestThread<TestException> wtt = new WaitingTestThread<>(genericObjectPool, 200);
wtt.start();
// Give wtt time to start
Thread.sleep(200);
@@ -2938,7 +2938,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
assertNotNull(obj1);
// Create a separate thread to try and borrow another object
- final WaitingTestThread wtt = new WaitingTestThread(genericObjectPool, 200);
+ final WaitingTestThread<TestException> wtt = new WaitingTestThread<TestException>(genericObjectPool, 200);
wtt.start();
// Give wtt time to start
Thread.sleep(200);
@@ -2965,7 +2965,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
assertNotNull(obj1);
// Create a separate thread to try and borrow another object
- final WaitingTestThread wtt = new WaitingTestThread(genericObjectPool, 200000);
+ final WaitingTestThread<TestException> wtt = new WaitingTestThread<>(genericObjectPool, 200000);
wtt.start();
// Give wtt time to start
Thread.sleep(200);