commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1531878 - in /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2: TestBaseObjectPool.java TestBasePoolableObjectFactory.java TestKeyedObjectPool.java
Date Mon, 14 Oct 2013 12:53:53 GMT
Author: markt
Date: Mon Oct 14 12:53:52 2013
New Revision: 1531878

URL: http://svn.apache.org/r1531878
Log:
Fix some FindBugs warnings

Modified:
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java?rev=1531878&r1=1531877&r2=1531878&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java
Mon Oct 14 12:53:52 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,13 +24,13 @@ import org.junit.Test;
 
 
 /**
- * @version $Revision$ 
+ * @version $Revision$
  */
 public class TestBaseObjectPool extends TestObjectPool {
     private ObjectPool<Object> _pool = null;
 
     /**
-     * @param mincapacity  
+     * @param mincapacity
      */
     protected ObjectPool<Object> makeEmptyPool(int mincapacity) {
         if (this.getClass() != TestBaseObjectPool.class) {
@@ -48,7 +48,7 @@ public class TestBaseObjectPool extends 
     }
 
     /**
-     * @param n  
+     * @param n
      */
     protected Object getNthObject(final int n) {
         if (this.getClass() != TestBaseObjectPool.class) {
@@ -77,18 +77,7 @@ public class TestBaseObjectPool extends 
         if (!getClass().equals(TestBaseObjectPool.class)) {
             return; // skip redundant tests
         }
-        ObjectPool<Object> pool = new BaseObjectPool<Object>() { 
-            @Override
-            public Object borrowObject() {
-                return null;
-            }
-            @Override
-            public void returnObject(Object obj) {
-            }
-            @Override
-            public void invalidateObject(Object obj) {
-            }            
-        };   
+        ObjectPool<Object> pool = new TestObjectPool();
 
         assertTrue("Negative expected.", pool.getNumIdle() < 0);
         assertTrue("Negative expected.", pool.getNumActive() < 0);
@@ -110,18 +99,7 @@ public class TestBaseObjectPool extends 
 
     @Test
     public void testClose() throws Exception {
-        ObjectPool<Object> pool = new BaseObjectPool<Object>() {
-            @Override
-            public Object borrowObject() {
-                return null;
-            }
-            @Override
-            public void returnObject(Object obj) {
-            }
-            @Override
-            public void invalidateObject(Object obj) {
-            }
-        };
+        ObjectPool<Object> pool = new TestObjectPool();
 
         pool.close();
         pool.close(); // should not error as of Pool 2.0.
@@ -295,4 +273,17 @@ public class TestBaseObjectPool extends 
             // expected
         }
     }
+
+    private static class TestObjectPool extends BaseObjectPool<Object> {
+        @Override
+        public Object borrowObject() {
+            return null;
+        }
+        @Override
+        public void returnObject(Object obj) {
+        }
+        @Override
+        public void invalidateObject(Object obj) {
+        }
+    }
 }

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java?rev=1531878&r1=1531877&r2=1531878&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java
Mon Oct 14 12:53:52 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,22 +21,24 @@ import static junit.framework.Assert.ass
 import org.junit.Test;
 
 /**
- * @version $Revision$ 
+ * @version $Revision$
  */
 public class TestBasePoolableObjectFactory {
 
     @Test
     public void testDefaultMethods() throws Exception {
-        PooledObjectFactory<Object> factory = new BasePooledObjectFactory<Object>()
{ 
-            @Override
-            public Object create() throws Exception {
-                return null;
-            }
-        };   
-        
+        PooledObjectFactory<Object> factory = new TestFactory();
+
         factory.activateObject(null); // a no-op
         factory.passivateObject(null); // a no-op
         factory.destroyObject(null); // a no-op
         assertTrue(factory.validateObject(null)); // constant true
     }
+
+    private static class TestFactory extends BasePooledObjectFactory<Object> {
+        @Override
+        public Object create() throws Exception {
+            return null;
+        }
+    }
 }

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java?rev=1531878&r1=1531877&r2=1531878&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java
Mon Oct 14 12:53:52 2013
@@ -139,7 +139,7 @@ public abstract class TestKeyedObjectPoo
         }
         final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
-        // addObject should make a new object, pasivate it and put it in the pool
+        // addObject should make a new object, passivate it and put it in the pool
         pool.addObject(KEY);
         expectedMethods.add(new MethodCall("makeObject", KEY).returned(ZERO));
         expectedMethods.add(new MethodCall("passivateObject", KEY, ZERO));
@@ -767,7 +767,7 @@ public abstract class TestKeyedObjectPoo
                 throw new PrivateException("validateObject");
             }
             final boolean r = true;
-            call.returned(new Boolean(r));
+            call.returned(Boolean.valueOf(r));
             return r;
         }
 



Mime
View raw message