Repository: commons-pool
Updated Branches:
  refs/heads/master c5309f13a -> 5736b0ad1


[POOL-332] ObjectPool and KeyedObject pool should extend Closeable.
Cleaning up tests by managing pools with try-with-resource blocks.
More to do.

Project: http://git-wip-us.apache.org/repos/asf/commons-pool/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-pool/commit/5736b0ad
Tree: http://git-wip-us.apache.org/repos/asf/commons-pool/tree/5736b0ad
Diff: http://git-wip-us.apache.org/repos/asf/commons-pool/diff/5736b0ad

Branch: refs/heads/master
Commit: 5736b0ad12c2e2ad84d2fcbcfa1ce2a4f4ecbc60
Parents: c5309f1
Author: Gary Gregory <ggreg...@apache.org>
Authored: Wed Nov 1 12:19:35 2017 -0600
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Wed Nov 1 12:19:35 2017 -0600

----------------------------------------------------------------------
 .../org/apache/commons/pool2/TestPoolUtils.java | 49 +++++++++++---------
 1 file changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-pool/blob/5736b0ad/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java 
b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
index b253297..1316a32 100644
--- a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
+++ b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
@@ -557,19 +557,21 @@ public class TestPoolUtils {
 
     @Test
     public void testErodingObjectPoolDefaultFactor() {
-        @SuppressWarnings("unchecked")
-        final ObjectPool<Object> internalPool = createProxy(ObjectPool.class, 
new InvocationHandler() {
+        try (@SuppressWarnings("unchecked")
+            final ObjectPool<Object> internalPool = 
createProxy(ObjectPool.class, new InvocationHandler() {
+                
             @Override
             public Object invoke(final Object arg0, final Method arg1, final 
Object[] arg2) throws Throwable {
                 return null;
             }
-        });
-        final ObjectPool<Object> pool = PoolUtils.erodingPool(internalPool);
-        final String expectedToString = 
"ErodingObjectPool{factor=ErodingFactor{factor=1.0, idleHighWaterMark=1}, pool="
-                + internalPool + "}";
-        // The factor is not exposed, but will be printed in the toString() 
method
-        // In this case since we didn't pass one, the default 1.0f will be 
printed
-        assertEquals(expectedToString, pool.toString());
+        })) {
+            final ObjectPool<Object> pool = 
PoolUtils.erodingPool(internalPool);
+            final String expectedToString = 
"ErodingObjectPool{factor=ErodingFactor{factor=1.0, idleHighWaterMark=1}, pool="
+                    + internalPool + "}";
+            // The factor is not exposed, but will be printed in the 
toString() method
+            // In this case since we didn't pass one, the default 1.0f will be 
printed
+            assertEquals(expectedToString, pool.toString());
+        }
     }
 
     @Test
@@ -682,20 +684,21 @@ public class TestPoolUtils {
 
     @Test
     public void testErodingPoolKeyedObjectPoolDefaultFactor() {
-        @SuppressWarnings("unchecked")
-        final
-        KeyedObjectPool<Object, Object> internalPool = 
createProxy(KeyedObjectPool.class, new InvocationHandler() {
-            @Override
-            public Object invoke(final Object arg0, final Method arg1, final 
Object[] arg2)
-                    throws Throwable {
-                return null;
-            }
-        });
-        final KeyedObjectPool<Object, Object> pool = 
PoolUtils.erodingPool(internalPool);
-        final String expectedToString = 
"ErodingKeyedObjectPool{factor=ErodingFactor{factor=1.0, idleHighWaterMark=1}, 
keyedPool=" + internalPool + "}";
-        // The factor is not exposed, but will be printed in the toString() 
method
-        // In this case since we didn't pass one, the default 1.0f will be 
printed
-        assertEquals(expectedToString, pool.toString());
+        try (@SuppressWarnings("unchecked")
+        final KeyedObjectPool<Object, Object> internalPool = 
createProxy(KeyedObjectPool.class,
+                new InvocationHandler() {
+                    @Override
+                    public Object invoke(final Object arg0, final Method arg1, 
final Object[] arg2) throws Throwable {
+                        return null;
+                    }
+                })) {
+            final KeyedObjectPool<Object, Object> pool = 
PoolUtils.erodingPool(internalPool);
+            final String expectedToString = 
"ErodingKeyedObjectPool{factor=ErodingFactor{factor=1.0, idleHighWaterMark=1}, 
keyedPool="
+                    + internalPool + "}";
+            // The factor is not exposed, but will be printed in the 
toString() method
+            // In this case since we didn't pass one, the default 1.0f will be 
printed
+            assertEquals(expectedToString, pool.toString());
+        }
     }
 
     @Test

Reply via email to