This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch POOL_2_X in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/POOL_2_X by this push: new b9e81730 Use JUnit 5 convention for test method visibility b9e81730 is described below commit b9e81730903de73f67c5b104acc6af8a3fd8f53c Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 7 18:14:27 2025 -0400 Use JUnit 5 convention for test method visibility --- .../commons/pool2/AbstractTestKeyedObjectPool.java | 30 ++-- .../commons/pool2/AbstractTestObjectPool.java | 16 +- .../java/org/apache/commons/pool2/PoolTest.java | 2 +- .../pool2/TestBaseKeyedPooledObjectFactory.java | 2 +- .../apache/commons/pool2/TestBaseObjectPool.java | 18 +-- .../pool2/TestBasePoolableObjectFactory.java | 4 +- .../org/apache/commons/pool2/TestPoolUtils.java | 38 ++--- .../org/apache/commons/pool2/TestTrackedUse.java | 2 +- .../apache/commons/pool2/impl/CallStackTest.java | 4 +- .../commons/pool2/impl/NoOpCallStackTest.java | 2 +- .../pool2/impl/TestAbandonedKeyedObjectPool.java | 16 +- .../pool2/impl/TestAbandonedObjectPool.java | 16 +- .../pool2/impl/TestBaseGenericObjectPool.java | 10 +- .../commons/pool2/impl/TestCallStackUtils.java | 4 +- .../pool2/impl/TestDefaultPooledObject.java | 10 +- .../pool2/impl/TestDefaultPooledObjectInfo.java | 8 +- .../commons/pool2/impl/TestEvictionConfig.java | 6 +- .../commons/pool2/impl/TestEvictionTimer.java | 2 +- .../pool2/impl/TestGenericKeyedObjectPool.java | 136 ++++++++--------- .../commons/pool2/impl/TestGenericObjectPool.java | 168 ++++++++++----------- .../impl/TestGenericObjectPoolClassLoaders.java | 2 +- .../TestGenericObjectPoolFactoryCreateFailure.java | 2 +- .../pool2/impl/TestLinkedBlockingDeque.java | 80 +++++----- .../commons/pool2/impl/TestPoolImplUtils.java | 12 +- .../pool2/impl/TestPooledSoftReference.java | 4 +- .../commons/pool2/impl/TestSoftRefOutOfMemory.java | 8 +- .../commons/pool2/pool407/KeyedPool407Test.java | 12 +- .../apache/commons/pool2/pool407/Pool407Test.java | 12 +- .../proxy/AbstractTestProxiedKeyedObjectPool.java | 12 +- .../pool2/proxy/AbstractTestProxiedObjectPool.java | 12 +- 30 files changed, 325 insertions(+), 325 deletions(-) diff --git a/src/test/java/org/apache/commons/pool2/AbstractTestKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/AbstractTestKeyedObjectPool.java index 14736c2a..c2762dc5 100644 --- a/src/test/java/org/apache/commons/pool2/AbstractTestKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/AbstractTestKeyedObjectPool.java @@ -244,7 +244,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseAddObject() throws Exception { + void testBaseAddObject() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -280,7 +280,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseBorrow() throws Exception { + void testBaseBorrow() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -298,7 +298,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseBorrowReturn() throws Exception { + void testBaseBorrowReturn() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -337,7 +337,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseClear() throws Exception { + void testBaseClear() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -363,7 +363,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseInvalidateObject() throws Exception { + void testBaseInvalidateObject() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -386,7 +386,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseNumActiveNumIdle() throws Exception { + void testBaseNumActiveNumIdle() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException uoe) { @@ -415,7 +415,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testBaseNumActiveNumIdle2() throws Exception { + void testBaseNumActiveNumIdle2() throws Exception { try { pool = makeEmptyPool(6); } catch (final UnsupportedOperationException uoe) { @@ -474,7 +474,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testClosedPoolBehavior() throws Exception { + void testClosedPoolBehavior() throws Exception { final KeyedObjectPool<Object, Object> pool; try { pool = makeEmptyPool(new TestFactory()); @@ -510,7 +510,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFAddObjectUsage() throws Exception { + void testKPOFAddObjectUsage() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -550,7 +550,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFBorrowObjectUsages() throws Exception { + void testKPOFBorrowObjectUsages() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -616,7 +616,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFClearUsages() throws Exception { + void testKPOFClearUsages() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -639,7 +639,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFCloseUsages() throws Exception { + void testKPOFCloseUsages() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -662,7 +662,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFInvalidateObjectUsages() throws Exception { + void testKPOFInvalidateObjectUsages() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -694,7 +694,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testKPOFReturnObjectUsages() throws Exception { + void testKPOFReturnObjectUsages() throws Exception { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); final KeyedObjectPool<Object, Object> pool; try { @@ -753,7 +753,7 @@ public abstract class AbstractTestKeyedObjectPool { } @Test - public void testToString() { + void testToString() { final FailingKeyedPooledObjectFactory factory = new FailingKeyedPooledObjectFactory(); try (KeyedObjectPool<Object, Object> pool = makeEmptyPool(factory)) { pool.toString(); diff --git a/src/test/java/org/apache/commons/pool2/AbstractTestObjectPool.java b/src/test/java/org/apache/commons/pool2/AbstractTestObjectPool.java index 92e5726c..79ab8d51 100644 --- a/src/test/java/org/apache/commons/pool2/AbstractTestObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/AbstractTestObjectPool.java @@ -70,7 +70,7 @@ public abstract class AbstractTestObjectPool { protected abstract <E extends Exception> ObjectPool<Object> makeEmptyPool(PooledObjectFactory<Object> factory) throws UnsupportedOperationException; @Test - public void testClosedPoolBehavior() throws Exception { + void testClosedPoolBehavior() throws Exception { final ObjectPool<Object> pool; try { pool = makeEmptyPool(new MethodCallPoolableObjectFactory()); @@ -112,7 +112,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFAddObjectUsage() throws Exception { + void testPOFAddObjectUsage() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); final ObjectPool<Object> pool; try { @@ -163,7 +163,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFBorrowObjectUsages() throws Exception { + void testPOFBorrowObjectUsages() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); final ObjectPool<Object> pool; try { @@ -233,7 +233,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFClearUsages() throws Exception { + void testPOFClearUsages() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); final ObjectPool<Object> pool; try { @@ -256,7 +256,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFCloseUsages() throws Exception { + void testPOFCloseUsages() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); ObjectPool<Object> pool; try { @@ -283,7 +283,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFInvalidateObjectUsages() throws Exception { + void testPOFInvalidateObjectUsages() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); final ObjectPool<Object> pool; try { @@ -312,7 +312,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testPOFReturnObjectUsages() throws Exception { + void testPOFReturnObjectUsages() throws Exception { final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory(); final ObjectPool<Object> pool; try { @@ -372,7 +372,7 @@ public abstract class AbstractTestObjectPool { } @Test - public void testToString() { + void testToString() { final ObjectPool<Object> pool; try { pool = makeEmptyPool(new MethodCallPoolableObjectFactory()); diff --git a/src/test/java/org/apache/commons/pool2/PoolTest.java b/src/test/java/org/apache/commons/pool2/PoolTest.java index 6171447c..d64d01c4 100644 --- a/src/test/java/org/apache/commons/pool2/PoolTest.java +++ b/src/test/java/org/apache/commons/pool2/PoolTest.java @@ -68,7 +68,7 @@ public class PoolTest { private static final long EVICTION_PERIOD_IN_MILLIS = 100; @Test - public void testPool() throws Exception { + void testPool() throws Exception { final GenericObjectPoolConfig<Foo> poolConfig = new GenericObjectPoolConfig<>(); poolConfig.setTestWhileIdle(true /* testWhileIdle */); final PooledFooFactory pooledFooFactory = new PooledFooFactory(); diff --git a/src/test/java/org/apache/commons/pool2/TestBaseKeyedPooledObjectFactory.java b/src/test/java/org/apache/commons/pool2/TestBaseKeyedPooledObjectFactory.java index d4889d30..cc390cdd 100644 --- a/src/test/java/org/apache/commons/pool2/TestBaseKeyedPooledObjectFactory.java +++ b/src/test/java/org/apache/commons/pool2/TestBaseKeyedPooledObjectFactory.java @@ -37,7 +37,7 @@ public class TestBaseKeyedPooledObjectFactory { } @Test - public void testDefaultMethods() throws Exception { + void testDefaultMethods() throws Exception { final KeyedPooledObjectFactory<Object, Object> factory = new TestFactory(); factory.activateObject("key", null); // a no-op diff --git a/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java b/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java index a887ff32..de55fbea 100644 --- a/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java @@ -93,7 +93,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseAddObject() throws Exception { + void testBaseAddObject() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -120,7 +120,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseBorrow() throws Exception { + void testBaseBorrow() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -133,7 +133,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseBorrowReturn() throws Exception { + void testBaseBorrowReturn() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -172,7 +172,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseClear() throws Exception { + void testBaseClear() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -197,7 +197,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseClosePool() throws Exception { + void testBaseClosePool() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -210,7 +210,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseInvalidateObject() throws Exception { + void testBaseInvalidateObject() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -232,7 +232,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testBaseNumActiveNumIdle() throws Exception { + void testBaseNumActiveNumIdle() throws Exception { try { pool = makeEmptyPool(3); } catch (final UnsupportedOperationException e) { @@ -256,7 +256,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testClose() { + void testClose() { @SuppressWarnings("resource") final ObjectPool<Object> pool = new TestObjectPool(); @@ -265,7 +265,7 @@ public class TestBaseObjectPool extends AbstractTestObjectPool { } @Test - public void testUnsupportedOperations() { + void testUnsupportedOperations() { if (!getClass().equals(TestBaseObjectPool.class)) { return; // skip redundant tests } diff --git a/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java b/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java index dbd1994f..2de95cbd 100644 --- a/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java +++ b/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java @@ -48,7 +48,7 @@ public class TestBasePoolableObjectFactory { } @Test - public void testDefaultMethods() throws Exception { + void testDefaultMethods() throws Exception { final PooledObjectFactory<AtomicInteger> factory = new TestFactory(); factory.activateObject(null); // a no-op factory.passivateObject(null); // a no-op @@ -63,7 +63,7 @@ public class TestBasePoolableObjectFactory { * @throws RuntimeException May occur in some failure modes */ @Test - public void testDestroyModes() throws Exception { + void testDestroyModes() throws Exception { final PooledObjectFactory<AtomicInteger> factory = new TestFactory(); final PooledObject<AtomicInteger> pooledObj = factory.makeObject(); final AtomicInteger obj = pooledObj.getObject(); diff --git a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java index d2e2803b..5140470d 100644 --- a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java +++ b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java @@ -156,7 +156,7 @@ public class TestPoolUtils { } @Test - public void testCheckMinIdleKeyedObjectPool() throws InterruptedException { + void testCheckMinIdleKeyedObjectPool() throws InterruptedException { assertThrows(IllegalArgumentException.class, () -> PoolUtils.checkMinIdle(null, new Object(), 1, 1), "PoolUtils.checkMinIdle(KeyedObjectPool,Object,int,long) must not allow null pool."); try (@SuppressWarnings("unchecked") @@ -224,7 +224,7 @@ public class TestPoolUtils { } @Test - public void testCheckMinIdleKeyedObjectPoolKeys() throws InterruptedException { + void testCheckMinIdleKeyedObjectPoolKeys() throws InterruptedException { // Because this isn't deterministic and you can get false failures, try more than once. AssertionFailedError afe = null; int triesLeft = 3; @@ -260,7 +260,7 @@ public class TestPoolUtils { } @Test - public void testCheckMinIdleKeyedObjectPoolKeysNulls() { + void testCheckMinIdleKeyedObjectPoolKeysNulls() { try (@SuppressWarnings("unchecked") KeyedObjectPool<Object, Object> pool = createProxy(KeyedObjectPool.class, (List<String>) null)) { assertThrows(IllegalArgumentException.class, () -> PoolUtils.checkMinIdle(pool, (Collection<?>) null, 1, 1), @@ -276,7 +276,7 @@ public class TestPoolUtils { } @Test - public void testCheckMinIdleObjectPool() throws InterruptedException { + void testCheckMinIdleObjectPool() throws InterruptedException { assertThrows(IllegalArgumentException.class, () -> PoolUtils.checkMinIdle(null, 1, 1), "PoolUtils.checkMinIdle(ObjectPool,,) must not allow null pool."); try (@SuppressWarnings("unchecked") @@ -336,7 +336,7 @@ public class TestPoolUtils { } @Test - public void testCheckRethrow() { + void testCheckRethrow() { try { PoolUtils.checkRethrow(new Exception()); } catch (final Throwable t) { @@ -361,7 +361,7 @@ public class TestPoolUtils { } @Test - public void testErodingObjectPoolDefaultFactor() { + void testErodingObjectPoolDefaultFactor() { try (@SuppressWarnings("unchecked") ObjectPool<Object> internalPool = createProxy(ObjectPool.class, (arg0, arg1, arg2) -> null); ObjectPool<Object> pool = PoolUtils.erodingPool(internalPool)) { @@ -374,7 +374,7 @@ public class TestPoolUtils { } @Test - public void testErodingPerKeyKeyedObjectPool() throws Exception { + void testErodingPerKeyKeyedObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.erodingPool((KeyedObjectPool<Object, Object>) null, 1f, true), "PoolUtils.erodingPool(KeyedObjectPool) must not allow a null pool."); @@ -446,7 +446,7 @@ public class TestPoolUtils { } @Test - public void testErodingPoolKeyedObjectPool() throws Exception { + void testErodingPoolKeyedObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.erodingPool((KeyedObjectPool<Object, Object>) null), "PoolUtils.erodingPool(KeyedObjectPool) must not allow a null pool."); @@ -533,7 +533,7 @@ public class TestPoolUtils { } @Test - public void testErodingPoolKeyedObjectPoolDefaultFactor() { + void testErodingPoolKeyedObjectPoolDefaultFactor() { try (@SuppressWarnings("unchecked") KeyedObjectPool<Object, Object> internalPool = createProxy(KeyedObjectPool.class, (arg0, arg1, arg2) -> null); @@ -547,7 +547,7 @@ public class TestPoolUtils { } @Test - public void testErodingPoolObjectPool() throws Exception { + void testErodingPoolObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.erodingPool((ObjectPool<Object>) null), "PoolUtils.erodingPool(ObjectPool) must not allow a null pool."); @@ -626,13 +626,13 @@ public class TestPoolUtils { } @Test - public void testJavaBeanInstantiation() { + void testJavaBeanInstantiation() { assertNotNull(new PoolUtils()); } @SuppressWarnings("deprecation") @Test - public void testPrefillKeyedObjectPool() throws Exception { + void testPrefillKeyedObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.prefill(null, new Object(), 1), "PoolUtils.prefill(KeyedObjectPool,Object,int) must not accept null pool."); try (KeyedObjectPool<Object, String> pool = new GenericKeyedObjectPool<>(new TestGenericKeyedObjectPool.SimpleFactory<>())) { @@ -654,7 +654,7 @@ public class TestPoolUtils { @SuppressWarnings("deprecation") @Test - public void testPrefillKeyedObjectPoolCollection() throws Exception { + void testPrefillKeyedObjectPoolCollection() throws Exception { try (@SuppressWarnings("unchecked") KeyedObjectPool<String, String> pool = createProxy(KeyedObjectPool.class, (List<String>) null)) { assertThrows(IllegalArgumentException.class, () -> PoolUtils.prefill(pool, (Collection<String>) null, 1), @@ -680,7 +680,7 @@ public class TestPoolUtils { @SuppressWarnings("deprecation") @Test - public void testPrefillObjectPool() throws Exception { + void testPrefillObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.prefill(null, 1), "PoolUtils.prefill(ObjectPool,int) must not allow null pool."); final List<String> calledMethods = new ArrayList<>(); try (@SuppressWarnings("unchecked") @@ -696,7 +696,7 @@ public class TestPoolUtils { } @Test - public void testSynchronizedPoolableFactoryKeyedPooledObjectFactory() throws Exception { + void testSynchronizedPoolableFactoryKeyedPooledObjectFactory() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.synchronizedKeyedPooledFactory((KeyedPooledObjectFactory<Object, Object>) null), "PoolUtils.synchronizedPoolableFactory(KeyedPooledObjectFactory) must not allow a null factory."); @@ -713,7 +713,7 @@ public class TestPoolUtils { } @Test - public void testSynchronizedPoolableFactoryPoolableObjectFactory() throws Exception { + void testSynchronizedPoolableFactoryPoolableObjectFactory() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.synchronizedPooledFactory((PooledObjectFactory<Object>) null), "PoolUtils.synchronizedPoolableFactory(PoolableObjectFactory) must not allow a null factory."); @@ -729,7 +729,7 @@ public class TestPoolUtils { } @Test - public void testSynchronizedPoolKeyedObjectPool() throws Exception { + void testSynchronizedPoolKeyedObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.synchronizedPool((KeyedObjectPool<Object, Object>) null), "PoolUtils.synchronizedPool(KeyedObjectPool) must not allow a null pool."); @@ -745,7 +745,7 @@ public class TestPoolUtils { } @Test - public void testSynchronizedPoolObjectPool() throws Exception { + void testSynchronizedPoolObjectPool() throws Exception { assertThrows(IllegalArgumentException.class, () -> PoolUtils.synchronizedPool((ObjectPool<Object>) null), "PoolUtils.synchronizedPool(ObjectPool) must not allow a null pool."); final List<String> calledMethods = new ArrayList<>(); @@ -761,7 +761,7 @@ public class TestPoolUtils { * Tests the {@link PoolUtils} timer holder. */ @Test - public void testTimerHolder() { + void testTimerHolder() { final PoolUtils.TimerHolder h = new PoolUtils.TimerHolder(); assertNotNull(h); assertNotNull(PoolUtils.TimerHolder.MIN_IDLE_TIMER); diff --git a/src/test/java/org/apache/commons/pool2/TestTrackedUse.java b/src/test/java/org/apache/commons/pool2/TestTrackedUse.java index bc0c5a45..95f48e13 100644 --- a/src/test/java/org/apache/commons/pool2/TestTrackedUse.java +++ b/src/test/java/org/apache/commons/pool2/TestTrackedUse.java @@ -35,7 +35,7 @@ public class TestTrackedUse { } @Test - public void testDefaultGetLastUsedInstant() { + void testDefaultGetLastUsedInstant() { assertEquals(Instant.ofEpochMilli(1), new DefaultTrackedUse().getLastUsedInstant()); } } diff --git a/src/test/java/org/apache/commons/pool2/impl/CallStackTest.java b/src/test/java/org/apache/commons/pool2/impl/CallStackTest.java index c422cb77..fbfc4e99 100644 --- a/src/test/java/org/apache/commons/pool2/impl/CallStackTest.java +++ b/src/test/java/org/apache/commons/pool2/impl/CallStackTest.java @@ -44,7 +44,7 @@ public class CallStackTest { @ParameterizedTest @MethodSource("data") - public void testPrintClearedStackTraceIsNoOp(final CallStack stack) { + void testPrintClearedStackTraceIsNoOp(final CallStack stack) { stack.fillInStackTrace(); stack.clear(); stack.printStackTrace(new PrintWriter(writer)); @@ -54,7 +54,7 @@ public class CallStackTest { @ParameterizedTest @MethodSource("data") - public void testPrintFilledStackTrace(final CallStack stack) { + void testPrintFilledStackTrace(final CallStack stack) { stack.fillInStackTrace(); stack.printStackTrace(new PrintWriter(writer)); final String stackTrace = writer.toString(); diff --git a/src/test/java/org/apache/commons/pool2/impl/NoOpCallStackTest.java b/src/test/java/org/apache/commons/pool2/impl/NoOpCallStackTest.java index 585e60de..048dc9f8 100644 --- a/src/test/java/org/apache/commons/pool2/impl/NoOpCallStackTest.java +++ b/src/test/java/org/apache/commons/pool2/impl/NoOpCallStackTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; public class NoOpCallStackTest { @Test - public void testPrintStackTraceIsNoOp() { + void testPrintStackTraceIsNoOp() { final CallStack stack = NoOpCallStack.INSTANCE; stack.fillInStackTrace(); final StringWriter writer = new StringWriter(); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java index bc0d85f2..a00ab146 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedKeyedObjectPool.java @@ -194,7 +194,7 @@ public class TestAbandonedKeyedObjectPool { * @throws InterruptedException May occur in some failure modes */ @Test - public void testAbandonedInvalidate() throws Exception { + void testAbandonedInvalidate() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(Duration.ofMillis(2000)); @@ -233,7 +233,7 @@ public class TestAbandonedKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testAbandonedReturn() throws Exception { + void testAbandonedReturn() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnBorrow(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -268,7 +268,7 @@ public class TestAbandonedKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testConcurrentInvalidation() throws Exception { + void testConcurrentInvalidation() throws Exception { final int POOL_SIZE = 30; pool.setMaxTotalPerKey(POOL_SIZE); pool.setMaxIdlePerKey(POOL_SIZE); @@ -309,7 +309,7 @@ public class TestAbandonedKeyedObjectPool { assertEquals(0, pool.getNumActive(), "numActive should have been 0, was " + pool.getNumActive()); } - public void testDestroyModeAbandoned() throws Exception { + void testDestroyModeAbandoned() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -325,7 +325,7 @@ public class TestAbandonedKeyedObjectPool { assertTrue(obj.isDetached()); } - public void testDestroyModeNormal() throws Exception { + void testDestroyModeNormal() throws Exception { abandonedConfig = new AbandonedConfig(); pool.close(); // Unregister pool created by setup pool = new GenericKeyedObjectPool<>(new SimpleFactory(0, 0)); @@ -343,7 +343,7 @@ public class TestAbandonedKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testRemoveAbandonedWhileReturning() throws Exception { + void testRemoveAbandonedWhileReturning() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -372,7 +372,7 @@ public class TestAbandonedKeyedObjectPool { * JIRA: POOL-300 */ @Test - public void testStackTrace() throws Exception { + void testStackTrace() throws Exception { abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setLogAbandoned(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -399,7 +399,7 @@ public class TestAbandonedKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testWhenExhaustedBlock() throws Exception { + void testWhenExhaustedBlock() throws Exception { abandonedConfig.setRemoveAbandonedOnMaintenance(true); pool.setAbandonedConfig(abandonedConfig); pool.setTimeBetweenEvictionRuns(Duration.ofMillis(500)); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java index 85cb5e2a..1b134a93 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java @@ -277,7 +277,7 @@ public class TestAbandonedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testAbandonedInvalidate() throws Exception { + void testAbandonedInvalidate() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -309,7 +309,7 @@ public class TestAbandonedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testAbandonedReturn() throws Exception { + void testAbandonedReturn() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnBorrow(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -344,7 +344,7 @@ public class TestAbandonedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testConcurrentInvalidation() throws Exception { + void testConcurrentInvalidation() throws Exception { final int POOL_SIZE = 30; pool.setMaxTotal(POOL_SIZE); pool.setMaxIdle(POOL_SIZE); @@ -385,7 +385,7 @@ public class TestAbandonedObjectPool { assertEquals(0, pool.getNumActive(), "numActive should have been 0, was " + pool.getNumActive()); } - public void testDestroyModeAbandoned() throws Exception { + void testDestroyModeAbandoned() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -401,7 +401,7 @@ public class TestAbandonedObjectPool { assertTrue(obj.isDetached()); } - public void testDestroyModeNormal() throws Exception { + void testDestroyModeNormal() throws Exception { abandonedConfig = new AbandonedConfig(); pool.close(); // Unregister pool created by setup pool = new GenericObjectPool<>(new SimpleFactory(0, 0)); @@ -419,7 +419,7 @@ public class TestAbandonedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testRemoveAbandonedWhileReturning() throws Exception { + void testRemoveAbandonedWhileReturning() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -448,7 +448,7 @@ public class TestAbandonedObjectPool { * JIRA: POOL-300 */ @Test - public void testStackTrace() throws Exception { + void testStackTrace() throws Exception { abandonedConfig.setRemoveAbandonedOnMaintenance(true); abandonedConfig.setLogAbandoned(true); abandonedConfig.setRemoveAbandonedTimeout(TestConstants.ONE_SECOND_DURATION); @@ -475,7 +475,7 @@ public class TestAbandonedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testWhenExhaustedBlock() throws Exception { + void testWhenExhaustedBlock() throws Exception { abandonedConfig.setRemoveAbandonedOnMaintenance(true); pool.setAbandonedConfig(abandonedConfig); pool.setTimeBetweenEvictionRuns(Duration.ofMillis(500)); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java index 90d9c7bc..5fce786d 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java @@ -57,7 +57,7 @@ public class TestBaseGenericObjectPool { } @Test - public void testActiveTimeStatistics() { + void testActiveTimeStatistics() { for (int i = 0; i < 99; i++) { // must be < MEAN_TIMING_STATS_CACHE_SIZE pool.updateStatsReturn(Duration.ofMillis(i)); } @@ -65,7 +65,7 @@ public class TestBaseGenericObjectPool { } @Test - public void testBorrowWaitStatistics() { + void testBorrowWaitStatistics() { final DefaultPooledObject<String> p = (DefaultPooledObject<String>) factory.makeObject(); pool.updateStatsBorrow(p, Duration.ofMillis(10)); pool.updateStatsBorrow(p, Duration.ofMillis(20)); @@ -75,7 +75,7 @@ public class TestBaseGenericObjectPool { assertEquals(30, pool.getMaxBorrowWaitTimeMillis(), 0); } - public void testBorrowWaitStatisticsMax() { + void testBorrowWaitStatisticsMax() { final DefaultPooledObject<String> p = (DefaultPooledObject<String>) factory.makeObject(); assertEquals(0, pool.getMaxBorrowWaitTimeMillis(), Double.MIN_VALUE); pool.updateStatsBorrow(p, Duration.ZERO); @@ -89,7 +89,7 @@ public class TestBaseGenericObjectPool { } @Test - public void testEvictionTimerMultiplePools() throws InterruptedException { + void testEvictionTimerMultiplePools() throws InterruptedException { final AtomicIntegerFactory factory = new AtomicIntegerFactory(); factory.setValidateLatency(50); try (GenericObjectPool<AtomicInteger> evictingPool = new GenericObjectPool<>(factory)) { @@ -123,7 +123,7 @@ public class TestBaseGenericObjectPool { @SuppressWarnings("resource") // pools closed in finally block @Test @Timeout(value = 10_000, unit = TimeUnit.MILLISECONDS) - public void testJMXRegistrationLatency() { + void testJMXRegistrationLatency() { final int numPools = 1000; final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final ArrayList<GenericObjectPool<Waiter>> pools = new ArrayList<>(); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestCallStackUtils.java b/src/test/java/org/apache/commons/pool2/impl/TestCallStackUtils.java index 57c6a47a..b7a5e5d4 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestCallStackUtils.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestCallStackUtils.java @@ -44,13 +44,13 @@ public class TestCallStackUtils { } @Test - public void testNewCallStack2() { + void testNewCallStack2() { assertNewCallStack(CallStackUtils.newCallStack(MESSAGE_FORMAT, false)); assertNewCallStack(CallStackUtils.newCallStack(MESSAGE_FORMAT, true)); } @Test - public void testNewCallStack3() { + void testNewCallStack3() { assertNewCallStack(CallStackUtils.newCallStack(MESSAGE_FORMAT, false, false)); assertNewCallStack(CallStackUtils.newCallStack(MESSAGE_FORMAT, false, true)); } diff --git a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java index bb105e22..238dfe44 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java @@ -43,7 +43,7 @@ public class TestDefaultPooledObject { * @throws Exception May occur in some failure modes */ @Test - public void testGetIdleTimeMillis() throws Exception { + void testGetIdleTimeMillis() throws Exception { final DefaultPooledObject<Object> dpo = new DefaultPooledObject<>(new Object()); final AtomicBoolean negativeIdleTimeReturned = new AtomicBoolean(); final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 3); @@ -88,7 +88,7 @@ public class TestDefaultPooledObject { } @Test - public void testInitialStateActiveDuration() throws InterruptedException { + void testInitialStateActiveDuration() throws InterruptedException { final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object()); // Sleep MUST be "long enough" to test that we are not returning a negative time. // Need an API in Java 8 to get the clock granularity. @@ -109,7 +109,7 @@ public class TestDefaultPooledObject { } @Test - public void testInitialStateCreateInstant() { + void testInitialStateCreateInstant() { final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object()); // In the initial state, all instants are the creation instant: last borrow, last use, last return. @@ -129,7 +129,7 @@ public class TestDefaultPooledObject { } @Test - public void testInitialStateDuration() throws InterruptedException { + void testInitialStateDuration() throws InterruptedException { final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object()); final Duration duration1 = dpo.getFullDuration(); assertNotNull(duration1); @@ -142,7 +142,7 @@ public class TestDefaultPooledObject { } @Test - public void testInitialStateIdleDuration() throws InterruptedException { + void testInitialStateIdleDuration() throws InterruptedException { final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object()); // Sleep MUST be "long enough" to test that we are not returning a negative time. Thread.sleep(200); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java index 21a60276..e4eaf734 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObjectInfo.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; public class TestDefaultPooledObjectInfo { @Test - public void testGetLastBorrowTrace() throws Exception { + void testGetLastBorrowTrace() throws Exception { final AbandonedConfig abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnBorrow(true); @@ -49,7 +49,7 @@ public class TestDefaultPooledObjectInfo { } @Test - public void testGetPooledObjectToString() throws Exception { + void testGetPooledObjectToString() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new SimpleFactory())) { final String s1 = pool.borrowObject(); @@ -65,7 +65,7 @@ public class TestDefaultPooledObjectInfo { } @Test - public void testGetPooledObjectType() throws Exception { + void testGetPooledObjectType() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new SimpleFactory())) { pool.borrowObject(); @@ -81,7 +81,7 @@ public class TestDefaultPooledObjectInfo { } @Test - public void testTiming() throws Exception { + void testTiming() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new SimpleFactory())) { final long t1Millis = System.currentTimeMillis(); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestEvictionConfig.java b/src/test/java/org/apache/commons/pool2/impl/TestEvictionConfig.java index 776bd697..575b9f12 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestEvictionConfig.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestEvictionConfig.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; public class TestEvictionConfig { @Test - public void testConstructor1s() { + void testConstructor1s() { final EvictionConfig config = new EvictionConfig(Duration.ofMillis(1), Duration.ofMillis(1), 1); assertEquals(1, config.getIdleEvictDuration().toMillis()); assertEquals(1, config.getIdleEvictTime()); @@ -43,7 +43,7 @@ public class TestEvictionConfig { } @Test - public void testConstructorZerosDurations() { + void testConstructorZerosDurations() { final EvictionConfig config = new EvictionConfig(Duration.ZERO, Duration.ZERO, 0); assertEquals(Long.MAX_VALUE, config.getIdleEvictDuration().toMillis()); assertEquals(Long.MAX_VALUE, config.getIdleEvictTime()); @@ -57,7 +57,7 @@ public class TestEvictionConfig { } @Test - public void testConstructorZerosMillis() { + void testConstructorZerosMillis() { @SuppressWarnings("deprecation") final EvictionConfig config = new EvictionConfig(0, 0, 0); assertEquals(Long.MAX_VALUE, config.getIdleEvictDuration().toMillis()); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestEvictionTimer.java b/src/test/java/org/apache/commons/pool2/impl/TestEvictionTimer.java index 5af4f568..da05e58b 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestEvictionTimer.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestEvictionTimer.java @@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test; public class TestEvictionTimer { @Test - public void testStartStopEvictionTimer() throws Exception { + void testStartStopEvictionTimer() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new BasePooledObjectFactory<String>() { 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 355f512a..c0e1c46c 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java @@ -846,7 +846,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testAppendStats() { + void testAppendStats() { assertFalse(gkoPool.getMessageStatistics()); assertEquals("foo", gkoPool.appendStats("foo")); try (GenericKeyedObjectPool<?, ?> pool = new GenericKeyedObjectPool<>(new SimpleFactory<>())) { @@ -859,7 +859,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testBlockedKeyDoesNotBlockPool() throws Exception { + void testBlockedKeyDoesNotBlockPool() throws Exception { gkoPool.setBlockWhenExhausted(true); gkoPool.setMaxWaitMillis(5000); gkoPool.setMaxTotalPerKey(1); @@ -889,7 +889,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @SuppressWarnings("rawtypes") @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testBorrowObjectFairness() throws Exception { + void testBorrowObjectFairness() throws Exception { final int numThreads = 40; final int maxTotal = 40; final GenericKeyedObjectPoolConfig<String> config = new GenericKeyedObjectPoolConfig<>(); @@ -938,7 +938,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testClear() throws Exception { + void testClear() throws Exception { gkoPool.setMaxTotal(2); gkoPool.setMaxTotalPerKey(2); gkoPool.setBlockWhenExhausted(false); @@ -967,7 +967,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testClearOldest() throws Exception { + void testClearOldest() throws Exception { // Make destroy have some latency so clearOldest takes some time final WaiterFactory<String> waiterFactory = new WaiterFactory<>(0, 20, 0, 0, 0, 0, 50, 5, 0); try (GenericKeyedObjectPool<String, Waiter> waiterPool = new GenericKeyedObjectPool<>(waiterFactory)) { @@ -1002,7 +1002,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testClearReuseCapacity() throws Exception { + void testClearReuseCapacity() throws Exception { gkoPool.setMaxTotalPerKey(6); gkoPool.setMaxTotal(6); gkoPool.setMaxWait(Duration.ofSeconds(5)); @@ -1054,7 +1054,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS) - public void testClearUnblocksWaiters() throws Exception { + void testClearUnblocksWaiters() throws Exception { final GenericKeyedObjectPoolConfig<Integer> config = new GenericKeyedObjectPoolConfig<>(); config.setMaxTotalPerKey(1); config.setMaxTotal(1); @@ -1117,7 +1117,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { // POOL-259 @Test - public void testClientWaitStats() throws Exception { + void testClientWaitStats() throws Exception { final SimpleFactory<String> factory = new SimpleFactory<>(); // Give makeObject a little latency factory.setMakeLatency(200); @@ -1142,7 +1142,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws TestException a test failure. */ @Test - public void testConcurrentBorrowAndClear() throws Exception { + void testConcurrentBorrowAndClear() throws Exception { final int threadCount = 64; final int taskCount = 64; final int addCount = 1; @@ -1219,7 +1219,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception a test failure. */ @Test - public void testConcurrentBorrowAndClear_JiraComment17741156() throws Exception { + void testConcurrentBorrowAndClear_JiraComment17741156() throws Exception { final int threadCount = 2; final int taskCount = 2; final int addCount = 1; @@ -1235,7 +1235,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testConcurrentInvalidate() throws Exception { + void testConcurrentInvalidate() throws Exception { // Get allObjects and idleObjects loaded with some instances final int nObjects = 1000; final String key = "one"; @@ -1284,7 +1284,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testConstructorNullFactory() { + void testConstructorNullFactory() { // add dummy assert (won't be invoked because of IAE) to avoid "unused" warning assertThrows(IllegalArgumentException.class, () -> new GenericKeyedObjectPool<>(null)); } @@ -1292,7 +1292,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @SuppressWarnings("deprecation") @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testConstructors() { + void testConstructors() { // Make constructor arguments all different from defaults final int maxTotalPerKey = 1; final int minIdle = 2; @@ -1373,7 +1373,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * JIRA: POOL-270 - make sure constructor correctly sets run frequency of evictor timer. */ @Test - public void testContructorEvictionConfig() throws Exception { + void testContructorEvictionConfig() throws Exception { final GenericKeyedObjectPoolConfig<String> config = new GenericKeyedObjectPoolConfig<>(); config.setTimeBetweenEvictionRuns(Duration.ofMillis(500)); config.setMinEvictableIdleDuration(Duration.ofMillis(50)); @@ -1395,7 +1395,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * JIRA: POOL-283 */ @Test - public void testEqualsIndiscernible() throws Exception { + void testEqualsIndiscernible() throws Exception { final HashSetFactory factory = new HashSetFactory(); try (GenericKeyedObjectPool<String, HashSet<String>> pool = new GenericKeyedObjectPool<>(factory, new GenericKeyedObjectPoolConfig<>())) { final HashSet<String> s1 = pool.borrowObject("a"); @@ -1407,7 +1407,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testEviction() throws Exception { + void testEviction() throws Exception { gkoPool.setMaxIdlePerKey(500); gkoPool.setMaxTotalPerKey(500); gkoPool.setNumTestsPerEvictionRun(100); @@ -1454,7 +1454,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testEviction2() throws Exception { + void testEviction2() throws Exception { gkoPool.setMaxIdlePerKey(500); gkoPool.setMaxTotalPerKey(500); gkoPool.setNumTestsPerEvictionRun(100); @@ -1504,14 +1504,14 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testEvictionOrder() throws Exception { + void testEvictionOrder() throws Exception { checkEvictionOrder(false); checkEvictionOrder(true); } // POOL-326 @Test - public void testEvictorClearOldestRace() throws Exception { + void testEvictorClearOldestRace() throws Exception { gkoPool.setMinEvictableIdleTime(Duration.ofMillis(100)); gkoPool.setNumTestsPerEvictionRun(1); // Introduce latency between when evictor starts looking at an instance and when @@ -1541,14 +1541,14 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testEvictorVisiting() throws Exception { + void testEvictorVisiting() throws Exception { checkEvictorVisiting(true); checkEvictorVisiting(false); } @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testExceptionInValidationDuringEviction() throws Exception { + void testExceptionInValidationDuringEviction() throws Exception { gkoPool.setMaxIdlePerKey(1); gkoPool.setMinEvictableIdleTime(Duration.ZERO); gkoPool.setTestWhileIdle(true); @@ -1562,7 +1562,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnActivateDuringBorrow() throws Exception { + void testExceptionOnActivateDuringBorrow() throws Exception { final String obj1 = gkoPool.borrowObject("one"); final String obj2 = gkoPool.borrowObject("one"); gkoPool.returnObject("one", obj1); @@ -1589,7 +1589,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnDestroyDuringBorrow() throws Exception { + void testExceptionOnDestroyDuringBorrow() throws Exception { simpleFactory.setThrowExceptionOnDestroy(true); simpleFactory.setValidationEnabled(true); gkoPool.setTestOnBorrow(true); @@ -1604,7 +1604,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnDestroyDuringReturn() throws Exception { + void testExceptionOnDestroyDuringReturn() throws Exception { simpleFactory.setThrowExceptionOnDestroy(true); simpleFactory.setValidationEnabled(true); gkoPool.setTestOnReturn(true); @@ -1620,7 +1620,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnPassivateDuringReturn() throws Exception { + void testExceptionOnPassivateDuringReturn() throws Exception { final String obj = gkoPool.borrowObject("one"); simpleFactory.setThrowExceptionOnPassivate(true); gkoPool.returnObject("one", obj); @@ -1630,7 +1630,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testFIFO() throws Exception { + void testFIFO() throws Exception { gkoPool.setLifo(false); final String key = "key"; gkoPool.addObject(key); // "key0" @@ -1648,7 +1648,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60, unit = TimeUnit.SECONDS) - public void testGetKeys() throws Exception { + void testGetKeys() throws Exception { gkoPool.addObject("one"); assertEquals(1, gkoPool.getKeys().size()); gkoPool.addObject("two"); @@ -1660,7 +1660,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testGetStatsString() { + void testGetStatsString() { assertNotNull(gkoPool.getStatsString()); } @@ -1673,7 +1673,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testInvalidateFreesCapacity() throws Exception { + void testInvalidateFreesCapacity() throws Exception { final SimpleFactory<String> factory = new SimpleFactory<>(); try (GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(factory)) { pool.setMaxTotalPerKey(2); @@ -1697,7 +1697,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testInvalidateFreesCapacityForOtherKeys() throws Exception { + void testInvalidateFreesCapacityForOtherKeys() throws Exception { gkoPool.setMaxTotal(1); gkoPool.setMaxWait(Duration.ofMillis(500)); final Thread borrower = new Thread(new SimpleTestThread<>(gkoPool, "two")); @@ -1710,13 +1710,13 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testInvalidateMissingKey() throws Exception { + void testInvalidateMissingKey() throws Exception { assertThrows(IllegalStateException.class, () -> gkoPool.invalidateObject("UnknownKey", "Ignored")); } @ParameterizedTest @EnumSource(DestroyMode.class) - public void testInvalidateMissingKeyForDestroyMode(final DestroyMode destroyMode) throws Exception { + void testInvalidateMissingKeyForDestroyMode(final DestroyMode destroyMode) throws Exception { assertThrows(IllegalStateException.class, () -> gkoPool.invalidateObject("UnknownKey", "Ignored", destroyMode)); } @@ -1728,7 +1728,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testInvalidateWaiting() throws Exception { + void testInvalidateWaiting() throws Exception { final GenericKeyedObjectPoolConfig<Object> config = new GenericKeyedObjectPoolConfig<>(); config.setMaxTotal(2); config.setBlockWhenExhausted(true); @@ -1776,7 +1776,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testJmxRegistration() { + void testJmxRegistration() { final ObjectName oname = gkoPool.getJmxName(); final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Set<ObjectName> result = mbs.queryNames(oname, null); @@ -1785,7 +1785,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testLIFO() throws Exception { + void testLIFO() throws Exception { gkoPool.setLifo(true); final String key = "key"; gkoPool.addObject(key); // "key0" @@ -1808,7 +1808,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testLivenessPerKey() throws Exception { + void testLivenessPerKey() throws Exception { gkoPool.setMaxIdlePerKey(3); gkoPool.setMaxTotal(3); gkoPool.setMaxTotalPerKey(3); @@ -1833,7 +1833,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testMakeObjectException() throws Exception { + void testMakeObjectException() throws Exception { final SimpleFactory<String> factory = new SimpleFactory<>(); try (GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(factory)) { pool.setMaxTotalPerKey(1); @@ -1850,7 +1850,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 200000, unit = TimeUnit.MILLISECONDS) - public void testMaxActivePerKeyExceeded() { + void testMaxActivePerKeyExceeded() { final WaiterFactory<String> waiterFactory = new WaiterFactory<>(0, 20, 0, 0, 0, 0, 8, 5, 0); // TODO Fix this. Can't use local pool since runTestThreads uses the // protected pool field @@ -1866,7 +1866,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxIdle() throws Exception { + void testMaxIdle() throws Exception { gkoPool.setMaxTotalPerKey(100); gkoPool.setMaxIdlePerKey(8); final String[] active = new String[100]; @@ -1899,7 +1899,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotal() throws Exception { + void testMaxTotal() throws Exception { gkoPool.setMaxTotalPerKey(2); gkoPool.setMaxTotal(3); gkoPool.setBlockWhenExhausted(false); @@ -1933,7 +1933,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalInvariant() { + void testMaxTotalInvariant() { final int maxTotal = 15; simpleFactory.setEvenValid(false); // Every other validation fails simpleFactory.setDestroyLatency(100); // Destroy takes 100 ms @@ -1948,7 +1948,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalLRU() throws Exception { + void testMaxTotalLRU() throws Exception { gkoPool.setMaxTotalPerKey(2); gkoPool.setMaxTotal(3); final String o1 = gkoPool.borrowObject("a"); @@ -1989,7 +1989,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalPerKey() throws Exception { + void testMaxTotalPerKey() throws Exception { gkoPool.setMaxTotalPerKey(3); gkoPool.setBlockWhenExhausted(false); gkoPool.borrowObject(""); @@ -2000,7 +2000,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalPerKeyZero() { + void testMaxTotalPerKeyZero() { gkoPool.setMaxTotalPerKey(0); gkoPool.setBlockWhenExhausted(false); assertThrows(NoSuchElementException.class, () -> gkoPool.borrowObject("a")); @@ -2012,7 +2012,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * JIRA: POOL-310 */ @Test - public void testMaxTotalWithThreads() throws Exception { + void testMaxTotalWithThreads() throws Exception { gkoPool.setMaxTotalPerKey(2); gkoPool.setMaxTotal(1); final int holdTime = 2000; @@ -2040,7 +2040,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalZero() { + void testMaxTotalZero() { gkoPool.setMaxTotal(0); gkoPool.setBlockWhenExhausted(false); assertThrows(NoSuchElementException.class, () -> gkoPool.borrowObject("a")); @@ -2056,7 +2056,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * counted against the maxWait time. */ @Test - public void testMaxWaitTimeOutOnTime() throws Exception { + void testMaxWaitTimeOutOnTime() throws Exception { final Duration maxWaitDuration = Duration.ofSeconds(1); final SimpleFactory<String> factory = new SimpleFactory<>(); factory.makeLatency = 500; @@ -2095,7 +2095,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMaxWaitMultiThreaded() throws Exception { + void testMaxWaitMultiThreaded() throws Exception { final long maxWait = 500; // wait for connection final long holdTime = 4 * maxWait; // how long to hold connection final int keyCount = 4; // number of different keys @@ -2135,7 +2135,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMinIdle() throws Exception { + void testMinIdle() throws Exception { gkoPool.setMaxIdlePerKey(500); gkoPool.setMinIdlePerKey(5); gkoPool.setMaxTotalPerKey(10); @@ -2166,7 +2166,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMinIdleMaxTotalPerKey() throws Exception { + void testMinIdleMaxTotalPerKey() throws Exception { gkoPool.setMaxIdlePerKey(500); gkoPool.setMinIdlePerKey(5); gkoPool.setMaxTotalPerKey(10); @@ -2206,7 +2206,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testMinIdleNoPreparePool() throws Exception { + void testMinIdleNoPreparePool() throws Exception { gkoPool.setMaxIdlePerKey(500); gkoPool.setMinIdlePerKey(5); gkoPool.setMaxTotalPerKey(10); @@ -2230,7 +2230,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * JIRA: POOL-285 */ @Test - public void testMultipleReturn() throws Exception { + void testMultipleReturn() throws Exception { final WaiterFactory<String> factory = new WaiterFactory<>(0, 0, 0, 0, 0, 0); try (GenericKeyedObjectPool<String, Waiter> pool = new GenericKeyedObjectPool<>(factory)) { pool.setTestOnReturn(true); @@ -2255,7 +2255,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * JIRA: POOL-284 */ @Test - public void testMutable() throws Exception { + void testMutable() throws Exception { final HashSetFactory factory = new HashSetFactory(); try (GenericKeyedObjectPool<String, HashSet<String>> pool = new GenericKeyedObjectPool<>(factory, new GenericKeyedObjectPoolConfig<>())) { final HashSet<String> s1 = pool.borrowObject("a"); @@ -2269,7 +2269,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testNegativeMaxTotalPerKey() throws Exception { + void testNegativeMaxTotalPerKey() throws Exception { gkoPool.setMaxTotalPerKey(-1); gkoPool.setBlockWhenExhausted(false); final String obj = gkoPool.borrowObject(""); @@ -2282,7 +2282,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS) - public void testNPEOnFactoryNull() { + void testNPEOnFactoryNull() { // @formatter:off final DisconnectingWaiterFactory<String> factory = new DisconnectingWaiterFactory<>( () -> null, // Override default to always return null from makeObject @@ -2305,7 +2305,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testNumActiveNumIdle2() throws Exception { + void testNumActiveNumIdle2() throws Exception { assertEquals(0, gkoPool.getNumActive()); assertEquals(0, gkoPool.getNumIdle()); assertEquals(0, gkoPool.getNumActive("A")); @@ -2347,14 +2347,14 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testReturnObjectThrowsIllegalStateException() { + void testReturnObjectThrowsIllegalStateException() { try (GenericKeyedObjectPool<String, String> pool = new GenericKeyedObjectPool<>(new SimpleFactory<>())) { assertThrows(IllegalStateException.class, () -> pool.returnObject("Foo", "Bar")); } } @Test - public void testReturnObjectWithBlockWhenExhausted() throws Exception { + void testReturnObjectWithBlockWhenExhausted() throws Exception { gkoPool.setBlockWhenExhausted(true); gkoPool.setMaxTotal(1); // Test return object with no take waiters @@ -2372,7 +2372,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testReturnObjectWithoutBlockWhenExhausted() throws Exception { + void testReturnObjectWithoutBlockWhenExhausted() throws Exception { gkoPool.setBlockWhenExhausted(false); // Test return object with no take waiters final String obj = gkoPool.borrowObject("0"); @@ -2387,7 +2387,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * Test creates the scenario described in POOL-287. */ @Test - public void testReturnToHead() throws Exception { + void testReturnToHead() throws Exception { final SimpleFactory<String> factory = new SimpleFactory<>(); factory.setValidateLatency(100); factory.setValid(true); // Validation always succeeds @@ -2415,7 +2415,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testSettersAndGetters() { + void testSettersAndGetters() { { gkoPool.setMaxTotalPerKey(123); assertEquals(123, gkoPool.getMaxTotalPerKey()); @@ -2484,7 +2484,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testThreaded1() { + void testThreaded1() { gkoPool.setMaxTotalPerKey(15); gkoPool.setMaxIdlePerKey(15); gkoPool.setMaxWaitMillis(1000L); @@ -2493,7 +2493,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { // Pool-361 @Test - public void testValidateOnCreate() throws Exception { + void testValidateOnCreate() throws Exception { gkoPool.setTestOnCreate(true); simpleFactory.setValidationEnabled(true); gkoPool.addObject("one"); @@ -2501,7 +2501,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testValidateOnCreateFailure() throws Exception { + void testValidateOnCreateFailure() throws Exception { gkoPool.setTestOnCreate(true); gkoPool.setTestOnBorrow(false); gkoPool.setMaxTotal(2); @@ -2529,7 +2529,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testValidationFailureOnReturnFreesCapacity() throws Exception { + void testValidationFailureOnReturnFreesCapacity() throws Exception { final SimpleFactory<String> factory = new SimpleFactory<>(); factory.setValid(false); // Validate will always fail factory.setValidationEnabled(true); @@ -2553,7 +2553,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { // POOL-276 @Test - public void testValidationOnCreateOnly() throws Exception { + void testValidationOnCreateOnly() throws Exception { simpleFactory.enableValidation = true; gkoPool.setMaxTotal(1); gkoPool.setTestOnCreate(true); @@ -2575,7 +2575,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { } @Test - public void testWaiterCounts() throws Exception { + void testWaiterCounts() throws Exception { final String[] keys = { "one", "two", "three" }; final String[] objects = new String[keys.length]; gkoPool.setMaxTotalPerKey(1); @@ -2640,7 +2640,7 @@ public class TestGenericKeyedObjectPool extends AbstractTestKeyedObjectPool { */ @Test @Timeout(value = 60_000, unit = TimeUnit.MILLISECONDS) - public void testWhenExhaustedBlockClosePool() throws Exception { + void testWhenExhaustedBlockClosePool() throws Exception { gkoPool.setMaxTotalPerKey(1); gkoPool.setBlockWhenExhausted(true); gkoPool.setMaxWaitMillis(-1); 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 13390dad..e403d121 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java @@ -918,7 +918,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @SuppressWarnings("deprecation") @Test - public void testAbandonedPool() throws Exception { + void testAbandonedPool() throws Exception { final GenericObjectPoolConfig<String> config = new GenericObjectPoolConfig<>(); config.setJmxEnabled(false); GenericObjectPool<String> abandoned = new GenericObjectPool<>(simpleFactory, config); @@ -935,7 +935,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testAddObject() throws Exception { + void testAddObject() throws Exception { assertEquals(0, genericObjectPool.getNumIdle(), "should be zero idle"); genericObjectPool.addObject(); assertEquals(1, genericObjectPool.getNumIdle(), "should be one idle"); @@ -949,7 +949,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testAppendStats() { + void testAppendStats() { assertFalse(genericObjectPool.getMessageStatistics()); assertEquals("foo", genericObjectPool.appendStats("foo")); try (GenericObjectPool<?> pool = new GenericObjectPool<>(new SimpleFactory())) { @@ -967,7 +967,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testBorrowObjectFairness() throws Exception { + void testBorrowObjectFairness() throws Exception { final int numThreads = 40; final int maxTotal = 40; final GenericObjectPoolConfig config = new GenericObjectPoolConfig(); @@ -1011,7 +1011,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 1200, unit = TimeUnit.MILLISECONDS) - public void testBorrowObjectOverrideMaxWaitLarge() throws Exception { + void testBorrowObjectOverrideMaxWaitLarge() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(createSlowObjectFactory(Duration.ofSeconds(60)))) { pool.setMaxTotal(1); pool.setMaxWait(Duration.ofMillis(1_000)); // large @@ -1034,7 +1034,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 1200, unit = TimeUnit.MILLISECONDS) - public void testBorrowObjectOverrideMaxWaitSmall() throws Exception { + void testBorrowObjectOverrideMaxWaitSmall() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(createSlowObjectFactory(Duration.ofSeconds(60)))) { pool.setMaxTotal(1); pool.setMaxWait(Duration.ofMillis(1)); // small @@ -1057,7 +1057,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testBorrowTimings() throws Exception { + void testBorrowTimings() throws Exception { // Borrow final String object = genericObjectPool.borrowObject(); final PooledObject<String> po = genericObjectPool.getPooledObject(object); @@ -1114,7 +1114,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testBrokenFactoryShouldNotBlockPool() throws Exception { + void testBrokenFactoryShouldNotBlockPool() throws Exception { final int maxTotal = 1; simpleFactory.setMaxTotal(maxTotal); genericObjectPool.setMaxTotal(maxTotal); @@ -1144,7 +1144,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { // POOL-259 @Test - public void testClientWaitStats() throws Exception { + void testClientWaitStats() throws Exception { final SimpleFactory factory = new SimpleFactory(); // Give makeObject a little latency factory.setMakeLatency(200); @@ -1165,7 +1165,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testCloseMultiplePools1() { + void testCloseMultiplePools1() { try (GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory)) { genericObjectPool.setTimeBetweenEvictionRuns(TestConstants.ONE_MILLISECOND_DURATION); genericObjectPool2.setTimeBetweenEvictionRuns(TestConstants.ONE_MILLISECOND_DURATION); @@ -1175,7 +1175,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testCloseMultiplePools2() throws Exception { + void testCloseMultiplePools2() throws Exception { try (GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory)) { // Ensure eviction takes a long time, during which time EvictionTimer.executor's queue is empty simpleFactory.setDestroyLatency(1000L); @@ -1193,7 +1193,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testConcurrentBorrowAndEvict() throws Exception { + void testConcurrentBorrowAndEvict() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.addObject(); for (int i = 0; i < 5000; i++) { @@ -1216,7 +1216,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testConcurrentInvalidate() throws Exception { + void testConcurrentInvalidate() throws Exception { // Get allObjects and idleObjects loaded with some instances final int nObjects = 1000; genericObjectPool.setMaxTotal(nObjects); @@ -1263,14 +1263,14 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testConstructorNullFactory() { + void testConstructorNullFactory() { // add dummy assert (won't be invoked because of IAE) to avoid "unused" warning assertThrows(IllegalArgumentException.class, () -> new GenericObjectPool<>(null)); } @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testConstructors() { + void testConstructors() { // Make constructor arguments all different from defaults final int minIdle = 2; final Duration maxWaitDuration = Duration.ofMillis(3); @@ -1339,7 +1339,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testDefaultConfiguration() { + void testDefaultConfiguration() { assertConfiguration(new GenericObjectPoolConfig<>(), genericObjectPool); } @@ -1349,7 +1349,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * JIRA: POOL-283 */ @Test - public void testEqualsIndiscernible() throws Exception { + void testEqualsIndiscernible() throws Exception { final HashSetFactory factory = new HashSetFactory(); try (GenericObjectPool<HashSet<String>> pool = new GenericObjectPool<>(factory, new GenericObjectPoolConfig<>())) { final HashSet<String> s1 = pool.borrowObject(); @@ -1360,7 +1360,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testErrorFactoryDoesNotBlockThreads() throws Exception { + void testErrorFactoryDoesNotBlockThreads() throws Exception { final CreateErrorFactory factory = new CreateErrorFactory(); try (GenericObjectPool<String> createFailFactoryPool = new GenericObjectPool<>(factory)) { createFailFactoryPool.setMaxTotal(1); @@ -1406,7 +1406,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictAddObjects() throws Exception { + void testEvictAddObjects() throws Exception { simpleFactory.setMakeLatency(300); simpleFactory.setMaxTotal(2); genericObjectPool.setMaxTotal(2); @@ -1425,13 +1425,13 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictFIFO() throws Exception { + void testEvictFIFO() throws Exception { checkEvict(false); } @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEviction() throws Exception { + void testEviction() throws Exception { genericObjectPool.setMaxIdle(500); genericObjectPool.setMaxTotal(500); genericObjectPool.setNumTestsPerEvictionRun(100); @@ -1479,7 +1479,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictionInvalid() throws Exception { + void testEvictionInvalid() throws Exception { try (GenericObjectPool<Object> invalidFactoryPool = new GenericObjectPool<>(new InvalidFactory())) { invalidFactoryPool.setMaxIdle(1); invalidFactoryPool.setMaxTotal(1); @@ -1517,7 +1517,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictionOrder() throws Exception { + void testEvictionOrder() throws Exception { checkEvictionOrder(false); tearDown(); setUp(); @@ -1526,7 +1526,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictionPolicy() throws Exception { + void testEvictionPolicy() throws Exception { genericObjectPool.setMaxIdle(500); genericObjectPool.setMaxTotal(500); genericObjectPool.setNumTestsPerEvictionRun(500); @@ -1568,7 +1568,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictionSoftMinIdle() throws Exception { + void testEvictionSoftMinIdle() throws Exception { final class TimeTest extends BasePooledObjectFactory<TimeTest> { private final long createTimeMillis; @@ -1621,7 +1621,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictionWithNegativeNumTests() throws Exception { + void testEvictionWithNegativeNumTests() throws Exception { // when numTestsPerEvictionRun is negative, it represents a fraction of the idle objects to test genericObjectPool.setMaxIdle(6); genericObjectPool.setMaxTotal(6); @@ -1647,7 +1647,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictLIFO() throws Exception { + void testEvictLIFO() throws Exception { checkEvict(true); } @@ -1657,14 +1657,14 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testEvictorVisiting() throws Exception { + void testEvictorVisiting() throws Exception { checkEvictorVisiting(true); checkEvictorVisiting(false); } @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testEvictWhileEmpty() throws Exception { + void testEvictWhileEmpty() throws Exception { genericObjectPool.evict(); genericObjectPool.evict(); genericObjectPool.close(); @@ -1672,7 +1672,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testExceptionInValidationDuringEviction() throws Exception { + void testExceptionInValidationDuringEviction() throws Exception { genericObjectPool.setMaxIdle(1); genericObjectPool.setMinEvictableIdleTime(Duration.ZERO); genericObjectPool.setTestWhileIdle(true); @@ -1686,7 +1686,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnActivateDuringBorrow() throws Exception { + void testExceptionOnActivateDuringBorrow() throws Exception { final String obj1 = genericObjectPool.borrowObject(); final String obj2 = genericObjectPool.borrowObject(); genericObjectPool.returnObject(obj1); @@ -1709,7 +1709,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnDestroyDuringBorrow() throws Exception { + void testExceptionOnDestroyDuringBorrow() throws Exception { simpleFactory.setThrowExceptionOnDestroy(true); genericObjectPool.setTestOnBorrow(true); genericObjectPool.borrowObject(); @@ -1721,7 +1721,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnDestroyDuringReturn() throws Exception { + void testExceptionOnDestroyDuringReturn() throws Exception { simpleFactory.setThrowExceptionOnDestroy(true); genericObjectPool.setTestOnReturn(true); final String obj1 = genericObjectPool.borrowObject(); @@ -1734,7 +1734,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testExceptionOnPassivateDuringReturn() throws Exception { + void testExceptionOnPassivateDuringReturn() throws Exception { final String obj = genericObjectPool.borrowObject(); simpleFactory.setThrowExceptionOnPassivate(true); genericObjectPool.returnObject(obj); @@ -1742,7 +1742,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testFailingFactoryDoesNotBlockThreads() throws Exception { + void testFailingFactoryDoesNotBlockThreads() throws Exception { final CreateFailFactory factory = new CreateFailFactory(); try (GenericObjectPool<String> createFailFactoryPool = new GenericObjectPool<>(factory)) { createFailFactoryPool.setMaxTotal(1); @@ -1783,7 +1783,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testFIFO() throws Exception { + void testFIFO() throws Exception { genericObjectPool.setLifo(false); genericObjectPool.addObject(); // "0" genericObjectPool.addObject(); // "1" @@ -1799,49 +1799,49 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testGetFactoryType_DefaultPooledObjectFactory() { + void testGetFactoryType_DefaultPooledObjectFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(createDefaultPooledObjectFactory())) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetFactoryType_NullPooledObjectFactory() { + void testGetFactoryType_NullPooledObjectFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(createNullPooledObjectFactory())) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetFactoryType_PoolUtilsSynchronizedDefaultPooledFactory() { + void testGetFactoryType_PoolUtilsSynchronizedDefaultPooledFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(PoolUtils.synchronizedPooledFactory(createDefaultPooledObjectFactory()))) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetFactoryType_PoolUtilsSynchronizedNullPooledFactory() { + void testGetFactoryType_PoolUtilsSynchronizedNullPooledFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(PoolUtils.synchronizedPooledFactory(createNullPooledObjectFactory()))) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetFactoryType_SynchronizedDefaultPooledObjectFactory() { + void testGetFactoryType_SynchronizedDefaultPooledObjectFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new TestSynchronizedPooledObjectFactory<>(createDefaultPooledObjectFactory()))) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetFactoryType_SynchronizedNullPooledObjectFactory() { + void testGetFactoryType_SynchronizedNullPooledObjectFactory() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new TestSynchronizedPooledObjectFactory<>(createNullPooledObjectFactory()))) { assertNotNull(pool.getFactoryType()); } } @Test - public void testGetStatsString() { + void testGetStatsString() { try (GenericObjectPool<String> pool = new GenericObjectPool<>(new TestSynchronizedPooledObjectFactory<>(createNullPooledObjectFactory()))) { assertNotNull(pool.getStatsString()); } @@ -1855,7 +1855,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testInvalidateFreesCapacity() throws Exception { + void testInvalidateFreesCapacity() throws Exception { final SimpleFactory factory = new SimpleFactory(); try (GenericObjectPool<String> pool = new GenericObjectPool<>(factory)) { pool.setMaxTotal(2); @@ -1883,7 +1883,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testJmxRegistration() { + void testJmxRegistration() { final ObjectName oname = genericObjectPool.getJmxName(); final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Set<ObjectName> result = mbs.queryNames(oname, null); @@ -1904,7 +1904,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testLIFO() throws Exception { + void testLIFO() throws Exception { final String o; genericObjectPool.setLifo(true); genericObjectPool.addObject(); // "0" @@ -1927,7 +1927,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Disabled @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS) - public void testLivenessOnTransientFactoryFailure() throws Exception { + void testLivenessOnTransientFactoryFailure() throws Exception { final DisconnectingWaiterFactory<String> factory = new DisconnectingWaiterFactory<>(DisconnectingWaiterFactory.DEFAULT_DISCONNECTED_CREATE_ACTION, DisconnectingWaiterFactory.DEFAULT_DISCONNECTED_LIFECYCLE_ACTION, obj -> false // all instances fail validation ); @@ -1968,7 +1968,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMakeConcurrentWithReturn() throws Exception { + void testMakeConcurrentWithReturn() throws Exception { genericObjectPool.setTestOnBorrow(true); simpleFactory.setValid(true); // Borrow and return an instance, with a short wait @@ -1986,7 +1986,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxIdle() throws Exception { + void testMaxIdle() throws Exception { genericObjectPool.setMaxTotal(100); genericObjectPool.setMaxIdle(8); final String[] active = new String[100]; @@ -2004,7 +2004,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxIdleZero() throws Exception { + void testMaxIdleZero() throws Exception { genericObjectPool.setMaxTotal(100); genericObjectPool.setMaxIdle(0); final String[] active = new String[100]; @@ -2026,7 +2026,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) @SuppressWarnings("rawtypes") - public void testMaxIdleZeroUnderLoad() { + void testMaxIdleZeroUnderLoad() { // Config final int numThreads = 199; // And main thread makes a round 200. final int numIter = 20; @@ -2087,7 +2087,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotal() throws Exception { + void testMaxTotal() throws Exception { genericObjectPool.setMaxTotal(3); genericObjectPool.setBlockWhenExhausted(false); genericObjectPool.borrowObject(); @@ -2102,7 +2102,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalInvariant() { + void testMaxTotalInvariant() { final int maxTotal = 15; simpleFactory.setEvenValid(false); // Every other validation fails simpleFactory.setDestroyLatency(100); // Destroy takes 100 ms @@ -2118,7 +2118,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) @SuppressWarnings("rawtypes") - public void testMaxTotalUnderLoad() { + void testMaxTotalUnderLoad() { // Config final int numThreads = 199; // And main thread makes a round 200. final int numIter = 20; @@ -2176,7 +2176,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxTotalZero() throws Exception { + void testMaxTotalZero() throws Exception { genericObjectPool.setMaxTotal(0); genericObjectPool.setBlockWhenExhausted(false); assertThrows(NoSuchElementException.class, () -> genericObjectPool.borrowObject()); @@ -2190,7 +2190,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMaxWaitMultiThreaded() throws Exception { + void testMaxWaitMultiThreaded() throws Exception { final long maxWait = 500; // wait for connection final long holdTime = 2 * maxWait; // how long to hold connection final int threads = 10; // number of threads to grab the object initially @@ -2228,7 +2228,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMinIdle() throws Exception { + void testMinIdle() throws Exception { genericObjectPool.setMaxIdle(500); genericObjectPool.setMinIdle(5); genericObjectPool.setMaxTotal(10); @@ -2256,7 +2256,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testMinIdleMaxTotal() throws Exception { + void testMinIdleMaxTotal() throws Exception { genericObjectPool.setMaxIdle(500); genericObjectPool.setMinIdle(5); genericObjectPool.setMaxTotal(10); @@ -2297,7 +2297,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * JIRA: POOL-285 */ @Test - public void testMultipleReturn() throws Exception { + void testMultipleReturn() throws Exception { final WaiterFactory<String> factory = new WaiterFactory<>(0, 0, 0, 0, 0, 0); try (GenericObjectPool<Waiter> pool = new GenericObjectPool<>(factory)) { pool.setTestOnReturn(true); @@ -2318,7 +2318,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { // POOL-248 @Test - public void testMultipleReturnOfSameObject() throws Exception { + void testMultipleReturnOfSameObject() throws Exception { try (GenericObjectPool<String> pool = new GenericObjectPool<>(simpleFactory, new GenericObjectPoolConfig<>())) { assertEquals(0, pool.getNumActive()); assertEquals(0, pool.getNumIdle()); @@ -2340,7 +2340,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * JIRA: POOL-284 */ @Test - public void testMutable() throws Exception { + void testMutable() throws Exception { final HashSetFactory factory = new HashSetFactory(); try (GenericObjectPool<HashSet<String>> pool = new GenericObjectPool<>(factory, new GenericObjectPoolConfig<>())) { final HashSet<String> s1 = pool.borrowObject(); @@ -2354,7 +2354,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testNegativeMaxTotal() throws Exception { + void testNegativeMaxTotal() throws Exception { genericObjectPool.setMaxTotal(-1); genericObjectPool.setBlockWhenExhausted(false); final String obj = genericObjectPool.borrowObject(); @@ -2366,7 +2366,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * Verifies that concurrent threads never "share" instances */ @Test - public void testNoInstanceOverlap() { + void testNoInstanceOverlap() { final int maxTotal = 5; final int numThreads = 100; final int delay = 1; @@ -2388,7 +2388,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testNoInvalidateNPE() throws Exception { + void testNoInvalidateNPE() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setTestOnCreate(true); genericObjectPool.setMaxWaitMillis(-1); @@ -2412,7 +2412,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS) - public void testNPEOnFactoryNull() throws Exception { + void testNPEOnFactoryNull() throws Exception { final DisconnectingWaiterFactory<String> factory = new DisconnectingWaiterFactory<>(() -> null, // Override default to always return null from // makeObject DisconnectingWaiterFactory.DEFAULT_DISCONNECTED_LIFECYCLE_ACTION, DisconnectingWaiterFactory.DEFAULT_DISCONNECTED_VALIDATION_ACTION); @@ -2444,7 +2444,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testPreparePool() throws Exception { + void testPreparePool() throws Exception { genericObjectPool.setMinIdle(1); genericObjectPool.setMaxTotal(1); genericObjectPool.preparePool(); @@ -2460,7 +2460,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test /* maxWaitMillis x2 + padding */ @Timeout(value = 1200, unit = TimeUnit.MILLISECONDS) - public void testReturnBorrowObjectWithingMaxWaitDuration() throws Exception { + void testReturnBorrowObjectWithingMaxWaitDuration() throws Exception { final Duration maxWaitDuration = Duration.ofMillis(500); try (GenericObjectPool<String> createSlowObjectFactoryPool = new GenericObjectPool<>(createSlowObjectFactory(Duration.ofSeconds(60)))) { createSlowObjectFactoryPool.setMaxTotal(1); @@ -2479,7 +2479,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test /* maxWaitMillis x2 + padding */ @Timeout(value = 1200, unit = TimeUnit.MILLISECONDS) - public void testReturnBorrowObjectWithingMaxWaitMillis() throws Exception { + void testReturnBorrowObjectWithingMaxWaitMillis() throws Exception { final long maxWaitMillis = 500; try (GenericObjectPool<String> createSlowObjectFactoryPool = new GenericObjectPool<>(createSlowObjectFactory(Duration.ofSeconds(60)))) { createSlowObjectFactoryPool.setMaxTotal(1); @@ -2503,7 +2503,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ // @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testReturnObject() throws Exception { + void testReturnObject() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setMaxIdle(-1); final String active = genericObjectPool.borrowObject(); @@ -2521,7 +2521,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testSetConfig() throws Exception { + void testSetConfig() throws Exception { final GenericObjectPoolConfig<String> expected = new GenericObjectPoolConfig<>(); assertConfiguration(expected, genericObjectPool); expected.setMaxTotal(2); @@ -2541,7 +2541,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testSettersAndGetters() throws Exception { + void testSettersAndGetters() throws Exception { { // The object receives an Exception during its creation to prevent // memory leaks. See BaseGenericObjectPool constructor for more details. @@ -2642,7 +2642,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testStartAndStopEvictor() throws Exception { + void testStartAndStopEvictor() throws Exception { // set up pool without evictor genericObjectPool.setMaxIdle(6); genericObjectPool.setMaxTotal(6); @@ -2673,7 +2673,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Test - public void testSwallowedExceptionListener() { + void testSwallowedExceptionListener() { genericObjectPool.setSwallowedExceptionListener(null); // must simply return final List<Exception> swallowedExceptions = new ArrayList<>(); /* @@ -2696,7 +2696,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testThreaded1() throws Exception { + void testThreaded1() throws Exception { genericObjectPool.setMaxTotal(15); genericObjectPool.setMaxIdle(15); genericObjectPool.setMaxWaitMillis(1000L); @@ -2705,7 +2705,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testTimeoutNoLeak() throws Exception { + void testTimeoutNoLeak() throws Exception { genericObjectPool.setMaxTotal(2); genericObjectPool.setMaxWaitMillis(10); genericObjectPool.setBlockWhenExhausted(true); @@ -2722,7 +2722,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * Tests POOL-361 */ @Test - public void testValidateOnCreate() throws Exception { + void testValidateOnCreate() throws Exception { genericObjectPool.setTestOnCreate(true); genericObjectPool.addObject(); assertEquals(1, simpleFactory.validateCounter); @@ -2732,7 +2732,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * Tests POOL-361 */ @Test - public void testValidateOnCreateFailure() throws Exception { + void testValidateOnCreateFailure() throws Exception { genericObjectPool.setTestOnCreate(true); genericObjectPool.setTestOnBorrow(false); genericObjectPool.setMaxTotal(2); @@ -2759,7 +2759,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { * @throws Exception May occur in some failure modes */ @Test - public void testValidationFailureOnReturnFreesCapacity() throws Exception { + void testValidationFailureOnReturnFreesCapacity() throws Exception { final SimpleFactory factory = new SimpleFactory(); factory.setValid(false); // Validate will always fail factory.setValidationEnabled(true); @@ -2783,7 +2783,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { // POOL-276 @Test - public void testValidationOnCreateOnly() throws Exception { + void testValidationOnCreateOnly() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setTestOnCreate(true); genericObjectPool.setTestOnBorrow(false); @@ -2805,7 +2805,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testWhenExhaustedBlock() throws Exception { + void testWhenExhaustedBlock() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setBlockWhenExhausted(true); genericObjectPool.setMaxWaitMillis(10L); @@ -2823,7 +2823,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testWhenExhaustedBlockClosePool() throws Exception { + void testWhenExhaustedBlockClosePool() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setBlockWhenExhausted(true); genericObjectPool.setMaxWaitMillis(-1); @@ -2845,7 +2845,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testWhenExhaustedBlockInterrupt() throws Exception { + void testWhenExhaustedBlockInterrupt() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setBlockWhenExhausted(true); genericObjectPool.setMaxWaitMillis(-1); @@ -2880,7 +2880,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS) - public void testWhenExhaustedFail() throws Exception { + void testWhenExhaustedFail() throws Exception { genericObjectPool.setMaxTotal(1); genericObjectPool.setBlockWhenExhausted(false); final String obj1 = genericObjectPool.borrowObject(); @@ -2893,7 +2893,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @Test @Timeout(value = 400, unit = TimeUnit.MILLISECONDS) - public void testAddObjectFastReturn() throws Exception { + void testAddObjectFastReturn() throws Exception { final SimpleFactory simpleFactory = new SimpleFactory(); simpleFactory.makeLatency = 500; final GenericObjectPool<String> pool = new GenericObjectPool<>(simpleFactory); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java index eea80634..020ccb84 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java @@ -74,7 +74,7 @@ public class TestGenericObjectPoolClassLoaders { .getResource("/org/apache/commons/pool2/impl/"); @Test - public void testContextClassLoader() throws Exception { + void testContextClassLoader() throws Exception { final ClassLoader savedClassloader = Thread.currentThread().getContextClassLoader(); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java index d3b1568e..8c717941 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java @@ -98,7 +98,7 @@ public class TestGenericObjectPoolFactoryCreateFailure { @Test @Timeout(value = 10_000, unit = TimeUnit.MILLISECONDS) - public void testBorrowObjectStuck() { + void testBorrowObjectStuck() { final SingleObjectFactory factory = new SingleObjectFactory(); final GenericObjectPoolConfig<Object> config = new GenericObjectPoolConfig<>(); config.setMaxIdle(1); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestLinkedBlockingDeque.java b/src/test/java/org/apache/commons/pool2/impl/TestLinkedBlockingDeque.java index 48af9226..058e6bbb 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestLinkedBlockingDeque.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestLinkedBlockingDeque.java @@ -52,7 +52,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testAdd() { + void testAdd() { assertTrue(deque.add(ONE)); assertTrue(deque.add(TWO)); assertThrows(IllegalStateException.class, () -> deque.add(THREE)); @@ -60,7 +60,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testAddFirst() { + void testAddFirst() { deque.addFirst(ONE); deque.addFirst(TWO); assertEquals(2, deque.size()); @@ -69,7 +69,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testAddLast() { + void testAddLast() { deque.addLast(ONE); deque.addLast(TWO); assertEquals(2, deque.size()); @@ -78,7 +78,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testClear() { + void testClear() { deque.add(ONE); deque.add(TWO); deque.clear(); @@ -87,7 +87,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testConstructors() { + void testConstructors() { LinkedBlockingDeque<Integer> deque = new LinkedBlockingDeque<>(); assertEquals(Integer.MAX_VALUE, deque.remainingCapacity()); @@ -101,7 +101,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testContains() { + void testContains() { deque.add(ONE); assertTrue(deque.contains(ONE)); assertFalse(deque.contains(TWO)); @@ -112,7 +112,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testDescendingIterator() { + void testDescendingIterator() { assertThrows(NoSuchElementException.class, () -> deque.descendingIterator().next()); deque.add(ONE); deque.add(TWO); @@ -123,7 +123,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testDrainTo() { + void testDrainTo() { Collection<Integer> c = new ArrayList<>(); deque.add(ONE); deque.add(TWO); @@ -140,7 +140,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testElement() { + void testElement() { assertThrows(NoSuchElementException.class, () -> deque.element()); deque.add(ONE); deque.add(TWO); @@ -148,7 +148,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testGetFirst() { + void testGetFirst() { assertThrows(NoSuchElementException.class, () -> deque.getFirst()); deque.add(ONE); deque.add(TWO); @@ -156,7 +156,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testGetLast() { + void testGetLast() { assertThrows(NoSuchElementException.class, () -> deque.getLast()); deque.add(ONE); deque.add(TWO); @@ -164,7 +164,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testIterator() { + void testIterator() { assertThrows(NoSuchElementException.class, () -> deque.iterator().next()); deque.add(ONE); deque.add(TWO); @@ -175,7 +175,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOffer() { + void testOffer() { assertTrue(deque.offer(ONE)); assertTrue(deque.offer(TWO)); assertFalse(deque.offer(THREE)); @@ -183,7 +183,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOfferFirst() { + void testOfferFirst() { deque.offerFirst(ONE); deque.offerFirst(TWO); assertEquals(2, deque.size()); @@ -192,7 +192,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOfferFirstWithTimeout() throws InterruptedException { + void testOfferFirstWithTimeout() throws InterruptedException { assertThrows(NullPointerException.class, () -> deque.offerFirst(null, TIMEOUT_50_MILLIS)); assertTrue(deque.offerFirst(ONE, TIMEOUT_50_MILLIS)); assertTrue(deque.offerFirst(TWO, TIMEOUT_50_MILLIS)); @@ -200,7 +200,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOfferLast() { + void testOfferLast() { deque.offerLast(ONE); deque.offerLast(TWO); assertEquals(2, deque.size()); @@ -209,7 +209,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOfferLastWithTimeout() throws InterruptedException { + void testOfferLastWithTimeout() throws InterruptedException { assertThrows(NullPointerException.class, () -> deque.offerLast(null, TIMEOUT_50_MILLIS)); assertTrue(deque.offerLast(ONE, TIMEOUT_50_MILLIS)); assertTrue(deque.offerLast(TWO, TIMEOUT_50_MILLIS)); @@ -217,7 +217,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testOfferWithTimeout() throws InterruptedException { + void testOfferWithTimeout() throws InterruptedException { assertTrue(deque.offer(ONE, TIMEOUT_50_MILLIS)); assertTrue(deque.offer(TWO, TIMEOUT_50_MILLIS)); assertFalse(deque.offer(THREE, TIMEOUT_50_MILLIS)); @@ -225,7 +225,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPeek() { + void testPeek() { assertNull(deque.peek()); deque.add(ONE); deque.add(TWO); @@ -233,7 +233,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPeekFirst() { + void testPeekFirst() { assertNull(deque.peekFirst()); deque.add(ONE); deque.add(TWO); @@ -241,7 +241,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPeekLast() { + void testPeekLast() { assertNull(deque.peekLast()); deque.add(ONE); deque.add(TWO); @@ -249,7 +249,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPollFirst() { + void testPollFirst() { assertNull(deque.pollFirst()); assertTrue(deque.offerFirst(ONE)); assertTrue(deque.offerFirst(TWO)); @@ -257,13 +257,13 @@ public class TestLinkedBlockingDeque { } @Test - public void testPollFirstWithTimeout() throws InterruptedException { + void testPollFirstWithTimeout() throws InterruptedException { assertNull(deque.pollFirst()); assertNull(deque.pollFirst(TIMEOUT_50_MILLIS)); } @Test - public void testPollLast() { + void testPollLast() { assertNull(deque.pollLast()); assertTrue(deque.offerFirst(ONE)); assertTrue(deque.offerFirst(TWO)); @@ -271,19 +271,19 @@ public class TestLinkedBlockingDeque { } @Test - public void testPollLastWithTimeout() throws InterruptedException { + void testPollLastWithTimeout() throws InterruptedException { assertNull(deque.pollLast()); assertNull(deque.pollLast(TIMEOUT_50_MILLIS)); } @Test - public void testPollWithTimeout() throws InterruptedException { + void testPollWithTimeout() throws InterruptedException { assertNull(deque.poll(TIMEOUT_50_MILLIS)); assertNull(deque.poll(TIMEOUT_50_MILLIS)); } @Test - public void testPop() { + void testPop() { assertThrows(NoSuchElementException.class, () -> deque.pop()); deque.add(ONE); deque.add(TWO); @@ -301,7 +301,7 @@ public class TestLinkedBlockingDeque { */ @Test @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS) - public void testPossibleBug() { + void testPossibleBug() { deque = new LinkedBlockingDeque<>(); for (int i = 0; i < 3; i++) { @@ -322,7 +322,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPush() { + void testPush() { deque.push(ONE); deque.push(TWO); assertEquals(2, deque.size()); @@ -331,14 +331,14 @@ public class TestLinkedBlockingDeque { } @Test - public void testPut() throws InterruptedException { + void testPut() throws InterruptedException { assertThrows(NullPointerException.class, () -> deque.put(null)); deque.put(ONE); deque.put(TWO); } @Test - public void testPutFirst() throws InterruptedException { + void testPutFirst() throws InterruptedException { assertThrows(NullPointerException.class, () -> deque.putFirst(null)); deque.putFirst(ONE); deque.putFirst(TWO); @@ -347,7 +347,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testPutLast() throws InterruptedException { + void testPutLast() throws InterruptedException { assertThrows(NullPointerException.class, () -> deque.putLast(null)); deque.putLast(ONE); deque.putLast(TWO); @@ -356,7 +356,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testRemove() { + void testRemove() { assertThrows(NoSuchElementException.class, deque::remove); deque.add(ONE); deque.add(TWO); @@ -364,7 +364,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testRemoveFirst() { + void testRemoveFirst() { assertThrows(NoSuchElementException.class, deque::removeFirst); deque.add(ONE); deque.add(TWO); @@ -376,7 +376,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testRemoveLast() { + void testRemoveLast() { assertThrows(NoSuchElementException.class, deque::removeLast); deque.add(ONE); deque.add(TWO); @@ -388,7 +388,7 @@ public class TestLinkedBlockingDeque { } @Test - public void testRemoveLastOccurrence() { + void testRemoveLastOccurrence() { assertFalse(deque.removeLastOccurrence(null)); assertFalse(deque.removeLastOccurrence(ONE)); deque.add(ONE); @@ -398,28 +398,28 @@ public class TestLinkedBlockingDeque { } @Test - public void testTake() throws InterruptedException { + void testTake() throws InterruptedException { assertTrue(deque.offerFirst(ONE)); assertTrue(deque.offerFirst(TWO)); assertEquals(Integer.valueOf(2), deque.take()); } @Test - public void testTakeFirst() throws InterruptedException { + void testTakeFirst() throws InterruptedException { assertTrue(deque.offerFirst(ONE)); assertTrue(deque.offerFirst(TWO)); assertEquals(Integer.valueOf(2), deque.takeFirst()); } @Test - public void testTakeLast() throws InterruptedException { + void testTakeLast() throws InterruptedException { assertTrue(deque.offerFirst(ONE)); assertTrue(deque.offerFirst(TWO)); assertEquals(Integer.valueOf(1), deque.takeLast()); } @Test - public void testToArray() { + void testToArray() { deque.add(ONE); deque.add(TWO); Object[] arr = deque.toArray(); diff --git a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java index 5cb985a6..acecb728 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java @@ -80,19 +80,19 @@ public class TestPoolImplUtils { private static final Instant INSTANT_0 = Instant.ofEpochMilli(0); @Test - public void testFactoryTypeNotSimple() { + void testFactoryTypeNotSimple() { final Class<?> result = PoolImplUtils.getFactoryType(NotSimpleFactory.class); assertEquals(Long.class, result); } @Test - public void testFactoryTypeSimple() { + void testFactoryTypeSimple() { final Class<?> result = PoolImplUtils.getFactoryType(SimpleFactory.class); assertEquals(String.class, result); } @Test - public void testMaxInstants() { + void testMaxInstants() { assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_0, INSTANT_1)); assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_1, INSTANT_0)); assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_1, INSTANT_1)); @@ -100,7 +100,7 @@ public class TestPoolImplUtils { } @Test - public void testMinInstants() { + void testMinInstants() { assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_0, INSTANT_1)); assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_1, INSTANT_0)); assertEquals(INSTANT_1, PoolImplUtils.min(INSTANT_1, INSTANT_1)); @@ -108,7 +108,7 @@ public class TestPoolImplUtils { } @Test - public void testToChronoUnit() { + void testToChronoUnit() { assertEquals(ChronoUnit.NANOS, PoolImplUtils.toChronoUnit(TimeUnit.NANOSECONDS)); assertEquals(ChronoUnit.MICROS, PoolImplUtils.toChronoUnit(TimeUnit.MICROSECONDS)); assertEquals(ChronoUnit.MILLIS, PoolImplUtils.toChronoUnit(TimeUnit.MILLISECONDS)); @@ -119,7 +119,7 @@ public class TestPoolImplUtils { } @Test - public void testToDuration() { + void testToDuration() { assertEquals(Duration.ZERO, PoolImplUtils.toDuration(0, TimeUnit.MILLISECONDS)); assertEquals(Duration.ofMillis(1), PoolImplUtils.toDuration(1, TimeUnit.MILLISECONDS)); for (final TimeUnit tu : TimeUnit.values()) { diff --git a/src/test/java/org/apache/commons/pool2/impl/TestPooledSoftReference.java b/src/test/java/org/apache/commons/pool2/impl/TestPooledSoftReference.java index 75f22c70..d72f5ea0 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestPooledSoftReference.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestPooledSoftReference.java @@ -39,7 +39,7 @@ public class TestPooledSoftReference { } @Test - public void testPooledSoftReference() { + void testPooledSoftReference() { assertEquals(REFERENT, ref.getObject()); SoftReference<String> softRef = ref.getReference(); @@ -57,7 +57,7 @@ public class TestPooledSoftReference { } @Test - public void testToString() { + void testToString() { final String expected = "Referenced Object: test, State: IDLE"; assertEquals(expected, ref.toString()); } 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 64e58642..7531b8e4 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java @@ -133,7 +133,7 @@ public class TestSoftRefOutOfMemory { } @Test - public void testOutOfMemory() throws Exception { + void testOutOfMemory() throws Exception { pool = new SoftReferenceObjectPool<>(new SmallPoolableObjectFactory()); String obj = pool.borrowObject(); @@ -170,7 +170,7 @@ public class TestSoftRefOutOfMemory { } @Test - public void testOutOfMemory1000() throws Exception { + void testOutOfMemory1000() throws Exception { pool = new SoftReferenceObjectPool<>(new SmallPoolableObjectFactory()); for (int i = 0 ; i < 1000 ; i++) { @@ -216,7 +216,7 @@ public class TestSoftRefOutOfMemory { * @throws Exception May occur in some failure modes */ @Test - public void testOutOfMemoryError() throws Exception { + void testOutOfMemoryError() throws Exception { pool = new SoftReferenceObjectPool<>(new OomeFactory(OomeTrigger.CREATE)); try { pool.borrowObject(); @@ -244,7 +244,7 @@ public class TestSoftRefOutOfMemory { } @Test - public void testOutOfMemoryLarge() throws Exception { + void testOutOfMemoryLarge() throws Exception { pool = new SoftReferenceObjectPool<>(new LargePoolableObjectFactory(1000000)); String obj = pool.borrowObject(); diff --git a/src/test/java/org/apache/commons/pool2/pool407/KeyedPool407Test.java b/src/test/java/org/apache/commons/pool2/pool407/KeyedPool407Test.java index 4ec21017..bcc60a6b 100644 --- a/src/test/java/org/apache/commons/pool2/pool407/KeyedPool407Test.java +++ b/src/test/java/org/apache/commons/pool2/pool407/KeyedPool407Test.java @@ -83,37 +83,37 @@ public class KeyedPool407Test extends AbstractPool407Test { } @Test - public void testNormalFactoryNonNullFixtureWaitMax() throws Exception { + void testNormalFactoryNonNullFixtureWaitMax() throws Exception { test(new KeyedPool407NormalFactory(new KeyedPool407Fixture()), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Disabled @Test - public void testNormalFactoryNullFixtureWaitMax() throws Exception { + void testNormalFactoryNullFixtureWaitMax() throws Exception { test(new KeyedPool407NormalFactory(null), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Disabled @Test - public void testNullObjectFactoryWaitMax() throws Exception { + void testNullObjectFactoryWaitMax() throws Exception { test(new KeyedPool407NullObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Disabled @Test - public void testNullObjectFactoryWaitShort() throws Exception { + void testNullObjectFactoryWaitShort() throws Exception { test(new KeyedPool407NullObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_SHORT); } @Disabled @Test - public void testNullPoolableFactoryWaitMax() throws Exception { + void testNullPoolableFactoryWaitMax() throws Exception { test(new KeyedPool407NullPoolableObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Disabled @Test - public void testNullPoolableFactoryWaitShort() throws Exception { + void testNullPoolableFactoryWaitShort() throws Exception { test(new KeyedPool407NullPoolableObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_SHORT); } } diff --git a/src/test/java/org/apache/commons/pool2/pool407/Pool407Test.java b/src/test/java/org/apache/commons/pool2/pool407/Pool407Test.java index faa6bceb..b89f5a49 100644 --- a/src/test/java/org/apache/commons/pool2/pool407/Pool407Test.java +++ b/src/test/java/org/apache/commons/pool2/pool407/Pool407Test.java @@ -80,37 +80,37 @@ public class Pool407Test extends AbstractPool407Test { } @Test - public void testNormalFactoryNonNullFixtureWaitMax() throws Exception { + void testNormalFactoryNonNullFixtureWaitMax() throws Exception { test(new Pool407NormalFactory(new Pool407Fixture()), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Test @Disabled - public void testNormalFactoryNullFixtureWaitMax() throws Exception { + void testNormalFactoryNullFixtureWaitMax() throws Exception { test(new Pool407NormalFactory(null), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Disabled @Test - public void testNullObjectFactoryWaitMax() throws Exception { + void testNullObjectFactoryWaitMax() throws Exception { test(new Pool407NullObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Test @Disabled - public void testNullObjectFactoryWaitShort() throws Exception { + void testNullObjectFactoryWaitShort() throws Exception { test(new Pool407NullObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_SHORT); } @Test @Disabled - public void testNullPoolableFactoryWaitMax() throws Exception { + void testNullPoolableFactoryWaitMax() throws Exception { test(new Pool407NullPoolableObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_FOREVER); } @Test @Disabled - public void testNullPoolableFactoryWaitShort() throws Exception { + void testNullPoolableFactoryWaitShort() throws Exception { test(new Pool407NullPoolableObjectFactory(), Pool407Constants.POOL_SIZE, Pool407Constants.WAIT_SHORT); } } diff --git a/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedKeyedObjectPool.java index bd0d38f8..75092a27 100644 --- a/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedKeyedObjectPool.java @@ -107,7 +107,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool { } @Test - public void testAccessAfterInvalidate() throws Exception { + void testAccessAfterInvalidate() throws Exception { final TestObject obj = pool.borrowObject(KEY1); assertNotNull(obj); @@ -125,7 +125,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool { } @Test - public void testAccessAfterReturn() throws Exception { + void testAccessAfterReturn() throws Exception { final TestObject obj = pool.borrowObject(KEY1); assertNotNull(obj); @@ -141,7 +141,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool { } @Test - public void testBorrowObject() throws Exception { + void testBorrowObject() throws Exception { final TestObject obj = pool.borrowObject(KEY1); assertNotNull(obj); @@ -153,7 +153,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool { } @Test - public void testPassThroughMethods01() throws Exception { + void testPassThroughMethods01() throws Exception { assertEquals(0, pool.getNumActive()); assertEquals(0, pool.getNumIdle()); @@ -169,14 +169,14 @@ public abstract class AbstractTestProxiedKeyedObjectPool { } @Test - public void testPassThroughMethods02() { + void testPassThroughMethods02() { pool.close(); assertThrows(IllegalStateException.class, () -> pool.addObject(KEY1)); } @Test - public void testUsageTracking() throws Exception { + void testUsageTracking() throws Exception { final TestObject obj = pool.borrowObject(KEY1); assertNotNull(obj); diff --git a/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedObjectPool.java b/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedObjectPool.java index 464134ba..a0493158 100644 --- a/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/proxy/AbstractTestProxiedObjectPool.java @@ -103,7 +103,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testAccessAfterInvalidate() throws Exception { + void testAccessAfterInvalidate() throws Exception { final TestObject obj = pool.borrowObject(); assertNotNull(obj); @@ -121,7 +121,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testAccessAfterReturn() throws Exception { + void testAccessAfterReturn() throws Exception { final TestObject obj = pool.borrowObject(); assertNotNull(obj); @@ -138,7 +138,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testBorrowObject() throws Exception { + void testBorrowObject() throws Exception { final TestObject obj = pool.borrowObject(); assertNotNull(obj); @@ -150,7 +150,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testPassThroughMethods01() throws Exception { + void testPassThroughMethods01() throws Exception { assertEquals(0, pool.getNumActive()); assertEquals(0, pool.getNumIdle()); @@ -166,7 +166,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testPassThroughMethods02() { + void testPassThroughMethods02() { pool.close(); assertThrows(IllegalStateException.class, @@ -174,7 +174,7 @@ public abstract class AbstractTestProxiedObjectPool { } @Test - public void testUsageTracking() throws Exception { + void testUsageTracking() throws Exception { final TestObject obj = pool.borrowObject(); assertNotNull(obj);