commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1096420 - in /commons/proper/pool/trunk/src/test/org/apache/commons/pool2: TestBaseObjectPool.java TestObjectPool.java impl/TestGenericObjectPool.java impl/TestSoftReferenceObjectPool.java impl/TestStackObjectPool.java
Date Mon, 25 Apr 2011 07:01:43 GMT
Author: simonetripodi
Date: Mon Apr 25 07:01:42 2011
New Revision: 1096420

URL: http://svn.apache.org/viewvc?rev=1096420&view=rev
Log:
TestObjectPool tests (and related subclasses) moved to JUnit4 annotations

Modified:
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestBaseObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestBaseObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestBaseObjectPool.java?rev=1096420&r1=1096419&r2=1096420&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestBaseObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestBaseObjectPool.java Mon
Apr 25 07:01:42 2011
@@ -16,9 +16,11 @@
  */
 package org.apache.commons.pool2;
 
-import org.apache.commons.pool2.BaseObjectPool;
-import org.apache.commons.pool2.ObjectPool;
-import org.apache.commons.pool2.PoolableObjectFactory;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import org.junit.Test;
 
 
 /**
@@ -29,10 +31,6 @@ import org.apache.commons.pool2.Poolable
 public class TestBaseObjectPool extends TestObjectPool {
     private ObjectPool<Object> _pool = null;
 
-    public TestBaseObjectPool(String testName) {
-        super(testName);
-    }
-
     protected ObjectPool<Object> makeEmptyPool(int mincapacity) {
         if (this.getClass() != TestBaseObjectPool.class) {
             fail("Subclasses of TestBaseObjectPool must reimplement this method.");
@@ -70,6 +68,7 @@ public class TestBaseObjectPool extends 
     }
 
     // tests
+    @Test
     public void testUnsupportedOperations() throws Exception {
         if (!getClass().equals(TestBaseObjectPool.class)) {
             return; // skip redundant tests
@@ -112,6 +111,7 @@ public class TestBaseObjectPool extends 
         }
     }
 
+    @Test
     public void testClose() throws Exception {
         ObjectPool<Object> pool = new BaseObjectPool<Object>() {
             @Override
@@ -130,6 +130,7 @@ public class TestBaseObjectPool extends 
         pool.close(); // should not error as of Pool 2.0.
     }
 
+    @Test
     public void testBaseBorrow() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -141,6 +142,7 @@ public class TestBaseObjectPool extends 
         assertEquals(getNthObject(2),_pool.borrowObject());
     }
 
+    @Test
     public void testBaseAddObject() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -165,6 +167,7 @@ public class TestBaseObjectPool extends 
         }
     }
 
+    @Test
     public void testBaseBorrowReturn() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -202,6 +205,7 @@ public class TestBaseObjectPool extends 
         }
     }
 
+    @Test
     public void testBaseNumActiveNumIdle() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -224,6 +228,7 @@ public class TestBaseObjectPool extends 
         assertEquals(2,_pool.getNumIdle());
     }
 
+    @Test
     public void testBaseClear() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -247,6 +252,7 @@ public class TestBaseObjectPool extends 
         assertEquals(getNthObject(2),obj2);
     }
 
+    @Test
     public void testBaseInvalidateObject() throws Exception {
         try {
             _pool = makeEmptyPool(3);
@@ -267,6 +273,7 @@ public class TestBaseObjectPool extends 
         assertEquals(0,_pool.getNumIdle());
     }
 
+    @Test
     public void testBaseClosePool() throws Exception {
         try {
             _pool = makeEmptyPool(3);

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java?rev=1096420&r1=1096419&r2=1096420&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java Mon Apr
25 07:01:42 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.pool2;
 
+import static junit.framework.Assert.*;
+
 import junit.framework.TestCase;
 
 import org.apache.commons.pool2.ObjectPool;
@@ -24,6 +26,7 @@ import org.apache.commons.pool2.impl.Gen
 import org.apache.commons.pool2.impl.SoftReferenceObjectPool;
 import org.apache.commons.pool2.impl.StackObjectPool;
 import org.apache.commons.pool2.PoolUtils;
+import org.junit.Test;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -36,10 +39,7 @@ import java.util.NoSuchElementException;
  * @author Sandy McArthur
  * @version $Revision$ $Date$
  */
-public abstract class TestObjectPool extends TestCase {
-    public TestObjectPool(String testName) {
-        super(testName);
-    }
+public abstract class TestObjectPool {
 
     /**
      * Create an <code>ObjectPool</code> with the specified factory.
@@ -50,6 +50,7 @@ public abstract class TestObjectPool ext
      */
     protected abstract ObjectPool<Object> makeEmptyPool(PoolableObjectFactory<Object>
factory) throws UnsupportedOperationException;
 
+    @Test
     public void testClosedPoolBehavior() throws Exception {
         final ObjectPool<Object> pool;
         try {
@@ -104,6 +105,7 @@ public abstract class TestObjectPool ext
     private final Integer ZERO = new Integer(0);
     private final Integer ONE = new Integer(1);
 
+    @Test
     public void testPOFAddObjectUsage() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         final ObjectPool<Object> pool;
@@ -166,6 +168,7 @@ public abstract class TestObjectPool ext
         assertEquals(expectedMethods, factory.getMethodCalls());
     }
 
+    @Test
     public void testPOFBorrowObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         final ObjectPool<Object> pool;
@@ -248,6 +251,7 @@ public abstract class TestObjectPool ext
         assertTrue(factory.getMethodCalls().containsAll(expectedMethods));
     }
 
+    @Test
     public void testPOFReturnObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         final ObjectPool<Object> pool;
@@ -309,6 +313,7 @@ public abstract class TestObjectPool ext
         pool.returnObject(obj);
     }
 
+    @Test
     public void testPOFInvalidateObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         final ObjectPool<Object> pool;
@@ -346,6 +351,7 @@ public abstract class TestObjectPool ext
         assertEquals(expectedMethods, factory.getMethodCalls());
     }
 
+    @Test
     public void testPOFClearUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         final ObjectPool<Object> pool;
@@ -367,6 +373,7 @@ public abstract class TestObjectPool ext
         pool.clear();
     }
 
+    @Test
     public void testPOFCloseUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
         ObjectPool<Object> pool;
@@ -394,6 +401,7 @@ public abstract class TestObjectPool ext
         pool.close();
     }
 
+    @Test
     public void testSetFactory() throws Exception {
         ObjectPool<Object> pool;
         try {
@@ -409,6 +417,7 @@ public abstract class TestObjectPool ext
         }
     }
 
+    @Test
     public void testToString() {
         ObjectPool<Object> pool;
         try {

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1096420&r1=1096419&r2=1096420&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
Mon Apr 25 07:01:42 2011
@@ -17,17 +17,25 @@
 
 package org.apache.commons.pool2.impl;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
 import java.util.NoSuchElementException;
 import java.util.Random;
 
 import org.apache.commons.pool2.BasePoolableObjectFactory;
 import org.apache.commons.pool2.ObjectPool;
+import org.apache.commons.pool2.PoolUtils;
 import org.apache.commons.pool2.PoolableObjectFactory;
 import org.apache.commons.pool2.TestBaseObjectPool;
 import org.apache.commons.pool2.VisitTracker;
 import org.apache.commons.pool2.VisitTrackerFactory;
-import org.apache.commons.pool2.impl.GenericObjectPool;
-import org.apache.commons.pool2.PoolUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @author Rodney Waldhoff
@@ -36,9 +44,6 @@ import org.apache.commons.pool2.PoolUtil
  * @version $Revision$ $Date$
  */
 public class TestGenericObjectPool extends TestBaseObjectPool {
-    public TestGenericObjectPool(String testName) {
-        super(testName);
-    }
 
     @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
@@ -58,18 +63,19 @@ public class TestGenericObjectPool exten
         return String.valueOf(n);
     }
 
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         pool = new GenericObjectPool<Object>(new SimpleFactory());
     }
 
+    @After
     public void tearDown() throws Exception {
-        super.tearDown();
         pool.clear();
         pool.close();
         pool = null;
     }
 
+    @Test
     public void testWhenExhaustedGrow() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
@@ -82,6 +88,7 @@ public class TestGenericObjectPool exten
         pool.close();
     }
 
+    @Test
     public void testWhenExhaustedFail() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
@@ -98,6 +105,7 @@ public class TestGenericObjectPool exten
         pool.close();
     }
 
+    @Test
     public void testWhenExhaustedBlock() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
@@ -114,6 +122,7 @@ public class TestGenericObjectPool exten
         pool.close();
     }
 
+    @Test
     public void testWhenExhaustedBlockInterupt() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
@@ -154,12 +163,14 @@ public class TestGenericObjectPool exten
         
     }
 
+    @Test
     public void testEvictWhileEmpty() throws Exception {
         pool.evict();
         pool.evict();
         pool.close();
     }
-    
+
+    @Test
     /**
      * Tests addObject contention between ensureMinIdle triggered by
      * the Evictor with minIdle > 0 and borrowObject. 
@@ -184,10 +195,12 @@ public class TestGenericObjectPool exten
         pool.close();
     }
 
+    @Test
     public void testEvictLIFO() throws Exception {
         checkEvict(true);   
     }
-    
+
+    @Test
     public void testEvictFIFO() throws Exception {
         checkEvict(false);
     }
@@ -224,6 +237,7 @@ public class TestGenericObjectPool exten
      * 
      * JIRA: POOL-86
      */ 
+    @Test
     public void testEvictionOrder() throws Exception {
         checkEvictionOrder(false);
         checkEvictionOrder(true);
@@ -389,6 +403,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();        
         GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
@@ -398,7 +413,8 @@ public class TestGenericObjectPool exten
         assertEquals(0,pool.getNumIdle());
         pool.close();
     }
-    
+
+    @Test
     public void testExceptionOnDestroyDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
@@ -415,7 +431,8 @@ public class TestGenericObjectPool exten
         assertEquals(1, pool.getNumActive());
         assertEquals(0, pool.getNumIdle());
     }
-    
+
+    @Test
     public void testExceptionOnDestroyDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
@@ -428,7 +445,8 @@ public class TestGenericObjectPool exten
         assertEquals(1, pool.getNumActive());
         assertEquals(0, pool.getNumIdle());
     }
-    
+
+    @Test
     public void testExceptionOnActivateDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
@@ -458,6 +476,7 @@ public class TestGenericObjectPool exten
         assertEquals(0, pool.getNumIdle());
     }
 
+    @Test
     public void testSetFactoryWithActiveObjects() throws Exception {
         GenericObjectPool pool = new GenericObjectPool();
         pool.setMaxIdle(10);
@@ -478,6 +497,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testSetFactoryWithNoActiveObjects() throws Exception {
         GenericObjectPool pool = new GenericObjectPool();
         pool.setMaxIdle(10);
@@ -488,7 +508,8 @@ public class TestGenericObjectPool exten
         pool.setFactory(new SimpleFactory());
         assertEquals(0,pool.getNumIdle());
     }
-    
+
+    @Test
     public void testNegativeMaxActive() throws Exception {
         pool.setMaxActive(-1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
@@ -497,6 +518,7 @@ public class TestGenericObjectPool exten
         pool.returnObject(obj);
     }
 
+    @Test
     public void testMaxIdle() throws Exception {
         pool.setMaxActive(100);
         pool.setMaxIdle(8);
@@ -513,6 +535,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testMaxIdleZero() throws Exception {
         pool.setMaxActive(100);
         pool.setMaxIdle(0);
@@ -529,6 +552,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testMaxActive() throws Exception {
         pool.setMaxActive(3);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
@@ -543,7 +567,8 @@ public class TestGenericObjectPool exten
             // expected
         }
     }
-    
+
+    @Test
     public void testTimeoutNoLeak() throws Exception {
         pool.setMaxActive(2);
         pool.setMaxWait(10);
@@ -563,6 +588,7 @@ public class TestGenericObjectPool exten
         obj2 = pool.borrowObject();
     }
 
+    @Test
     public void testMaxActiveZero() throws Exception {
         pool.setMaxActive(0);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
@@ -575,6 +601,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testMaxActiveUnderLoad() {
         // Config
         int numThreads = 199; // And main thread makes a round 200.
@@ -653,6 +680,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testInvalidWhenExhaustedAction() throws Exception {
         try {
             pool.setWhenExhaustedAction(Byte.MAX_VALUE);
@@ -682,6 +710,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testSettersAndGetters() throws Exception {
         GenericObjectPool pool = new GenericObjectPool();
         {
@@ -743,11 +772,13 @@ public class TestGenericObjectPool exten
         }
     }
     
+    @Test
     public void testDefaultConfiguration() throws Exception {
         GenericObjectPool pool = new GenericObjectPool();
         assertConfiguration(new GenericObjectPool.Config(),pool);
     }
 
+    @Test
     public void testConstructors() throws Exception {
         {
             GenericObjectPool pool = new GenericObjectPool();
@@ -849,6 +880,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testSetConfig() throws Exception {
         GenericObjectPool.Config expected = new GenericObjectPool.Config();
         GenericObjectPool pool = new GenericObjectPool();
@@ -867,6 +899,7 @@ public class TestGenericObjectPool exten
         assertConfiguration(expected,pool);
     }
 
+    @Test
     public void testDebugInfo() throws Exception {
         GenericObjectPool pool = new GenericObjectPool(new SimpleFactory());
         pool.setMaxIdle(3);
@@ -877,6 +910,7 @@ public class TestGenericObjectPool exten
         assertNotNull(pool.debugInfo());
     }
 
+    @Test
     public void testStartAndStopEvictor() throws Exception {
         // set up pool without evictor
         pool.setMaxIdle(6);
@@ -913,6 +947,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testEvictionWithNegativeNumTests() throws Exception {
         // when numTestsPerEvictionRun is negative, it represents a fraction of the idle
objects to test
         pool.setMaxIdle(6);
@@ -939,6 +974,7 @@ public class TestGenericObjectPool exten
         assertEquals("Should be zero idle, found " + pool.getNumIdle(),0,pool.getNumIdle());
     }
 
+    @Test
     public void testEviction() throws Exception {
         pool.setMaxIdle(500);
         pool.setMaxActive(500);
@@ -989,6 +1025,7 @@ public class TestGenericObjectPool exten
         assertEquals("Should be zero idle, found " + pool.getNumIdle(),0,pool.getNumIdle());
     }
  
+    @Test
     public void testEvictionSoftMinIdle() throws Exception {
         GenericObjectPool pool = null;
         
@@ -1036,6 +1073,7 @@ public class TestGenericObjectPool exten
         assertEquals("Idle count different than expected.", 0, pool.getNumIdle());
     }
 
+    @Test
     public void testMinIdle() throws Exception {
         pool.setMaxIdle(500);
         pool.setMinIdle(5);
@@ -1069,6 +1107,7 @@ public class TestGenericObjectPool exten
         assertTrue("Should be 10 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 10);
     }
 
+    @Test
     public void testMinIdleMaxActive() throws Exception {
         pool.setMaxIdle(500);
         pool.setMinIdle(5);
@@ -1140,7 +1179,8 @@ public class TestGenericObjectPool exten
             }
         }
     }
-    
+
+    @Test
     public void testThreaded1() throws Exception {
         pool.setMaxActive(15);
         pool.setMaxIdle(15);
@@ -1153,6 +1193,7 @@ public class TestGenericObjectPool exten
      * has high latency, testOnReturn is set and there is high incidence of
      * validation failures. 
      */
+    @Test
     public void testMaxActiveInvariant() throws Exception {
         int maxActive = 15;
         SimpleFactory factory = new SimpleFactory();
@@ -1168,6 +1209,7 @@ public class TestGenericObjectPool exten
         runTestThreads(5, 10, 50);
     }
 
+    @Test
     public void testConcurrentBorrowAndEvict() throws Exception {
 
         pool.setMaxActive(1);
@@ -1305,6 +1347,7 @@ public class TestGenericObjectPool exten
         }
     }
 
+    @Test
     public void testFIFO() throws Exception {
         pool.setLifo(false);
         pool.addObject(); // "0"
@@ -1318,7 +1361,8 @@ public class TestGenericObjectPool exten
         assertEquals("returned", "r", pool.borrowObject());
         assertEquals("new-4", "4", pool.borrowObject());
     }
-    
+
+    @Test
     public void testLIFO() throws Exception {
         pool.setLifo(true);
         pool.addObject(); // "0"
@@ -1333,6 +1377,7 @@ public class TestGenericObjectPool exten
         assertEquals("new-4", "4", pool.borrowObject());
     }
 
+    @Test
     public void testAddObject() throws Exception {
         assertEquals("should be zero idle", 0, pool.getNumIdle());
         pool.addObject();
@@ -1552,6 +1597,7 @@ public class TestGenericObjectPool exten
      * enough margin for this to work correctly on most (all?) systems but be
      * aware of this if you see a failure of this test.
      */
+    @Test
     public void testBorrowObjectFairness() {
         // Config
         int numThreads = 30;
@@ -1597,6 +1643,7 @@ public class TestGenericObjectPool exten
      * On first borrow, first object fails validation, second object is OK.
      * Subsequent borrows are OK. This was POOL-152.
      */
+    @Test
     public void testBrokenFactoryShouldNotBlockPool() {
         int maxActive = 1;
         
@@ -1693,6 +1740,7 @@ public class TestGenericObjectPool exten
      * TestPerUserPoolDataSource.testMultipleThreads2()
      * Let's see if the this fails on Continuum too!
      */
+    @Test
     public void testMaxWaitMultiThreaded() throws Exception {
         final long maxWait = 500; // wait for connection
         final long holdTime = 2 * maxWait; // how long to hold connection
@@ -1748,6 +1796,7 @@ public class TestGenericObjectPool exten
      *   Thread 1 returns its instance while thread 2 is validating its newly created instance
      * The test verifies that the instance created by Thread 2 is not leaked.
      */
+    @Test
     public void testMakeConcurrentWithReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();
         GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);


Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java?rev=1096420&r1=1096419&r2=1096420&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java
Mon Apr 25 07:01:42 2011
@@ -20,7 +20,6 @@ package org.apache.commons.pool2.impl;
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.PoolableObjectFactory;
 import org.apache.commons.pool2.TestBaseObjectPool;
-import org.apache.commons.pool2.impl.SoftReferenceObjectPool;
 
 /**
  * @author Rodney Waldhoff
@@ -28,9 +27,6 @@ import org.apache.commons.pool2.impl.Sof
  * @version $Revision$ $Date$
  */
 public class TestSoftReferenceObjectPool extends TestBaseObjectPool {
-    public TestSoftReferenceObjectPool(String testName) {
-        super(testName);
-    }
 
     @Override
     protected ObjectPool<Object> makeEmptyPool(int cap) {

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java?rev=1096420&r1=1096419&r2=1096420&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
Mon Apr 25 07:01:42 2011
@@ -17,6 +17,11 @@
 
 package org.apache.commons.pool2.impl;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.List;
@@ -25,7 +30,8 @@ import java.util.NoSuchElementException;
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.PoolableObjectFactory;
 import org.apache.commons.pool2.TestBaseObjectPool;
-import org.apache.commons.pool2.impl.StackObjectPool;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * @author Rodney Waldhoff
@@ -34,9 +40,6 @@ import org.apache.commons.pool2.impl.Sta
  * @version $Revision$ $Date$
  */
 public class TestStackObjectPool extends TestBaseObjectPool {
-    public TestStackObjectPool(String testName) {
-        super(testName);
-    }
 
     @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
@@ -53,6 +56,7 @@ public class TestStackObjectPool extends
         return String.valueOf(n);
     }
 
+    @Test
     public void testIdleCap() throws Exception {
         ObjectPool<Object> pool = makeEmptyPool(8);
         Object[] active = new Object[100];
@@ -71,6 +75,9 @@ public class TestStackObjectPool extends
     /**
      * @deprecated - to be removed in pool 2.0
      */
+    @Test
+    @Ignore
+    @Deprecated
     public void testPoolWithNullFactory() throws Exception {
         ObjectPool<Integer> pool = new StackObjectPool<Integer>(10);
         for(int i=0;i<10;i++) {
@@ -111,6 +118,9 @@ public class TestStackObjectPool extends
      * @deprecated - to be removed in pool 2.0
      */
     @Override
+    @Test
+    @Ignore
+    @Deprecated
     public void testSetFactory() throws Exception {
         ObjectPool<Object> pool = new StackObjectPool<Object>();
         try {
@@ -128,6 +138,9 @@ public class TestStackObjectPool extends
     /**
      * @deprecated - to be removed in pool 2.0
      */
+    @Test
+    @Ignore
+    @Deprecated
     public void testCantResetFactoryWithActiveObjects() throws Exception {
         ObjectPool<Object> pool = new StackObjectPool<Object>();
         pool.setFactory(new SimpleFactory());
@@ -145,6 +158,9 @@ public class TestStackObjectPool extends
     /**
      * @deprecated - to be removed in pool 2.0
      */
+    @Test
+    @Ignore
+    @Deprecated
     public void testCanResetFactoryWithoutActiveObjects() throws Exception {
         ObjectPool<Object> pool = new StackObjectPool<Object>();
         {
@@ -166,6 +182,7 @@ public class TestStackObjectPool extends
      * from the pool result in NoSuchElementExceptions and passivation failures
      * result in instances not being returned to the pool.
      */
+    @Test
     public void testBorrowWithSometimesInvalidObjects() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         factory.setValidateSelectively(true);  // Even numbers fail validation
@@ -210,6 +227,7 @@ public class TestStackObjectPool extends
      * Verifies that validation and passivation failures returning objects are handled
      * properly - instances destroyed and not returned to the pool, but no exceptions propagated.
      */
+    @Test
     public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 20);
@@ -231,7 +249,8 @@ public class TestStackObjectPool extends
         // 0,2,4,6,8 fail validation, 3, 9 fail passivation - 3 left.
         assertEquals(3,pool.getNumIdle());
     }
-     
+
+    @Test
     public void testVariousConstructors() throws Exception {
         {
             StackObjectPool<Object> pool = new StackObjectPool<Object>();
@@ -262,6 +281,7 @@ public class TestStackObjectPool extends
     /**
      * Verify that out of range constructor arguments are ignored.
      */
+    @Test
     public void testMaxIdleInitCapacityOutOfRange() throws Exception {
         SimpleFactory factory = new SimpleFactory();
         StackObjectPool<Object> pool = new StackObjectPool<Object>(factory, -1,
0);
@@ -274,6 +294,7 @@ public class TestStackObjectPool extends
      * Verifies that when returning objects cause maxSleeping exceeded, oldest instances
      * are destroyed to make room for returning objects.
      */
+    @Test
     public void testReturnObjectDiscardOrder() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 3);
@@ -307,6 +328,7 @@ public class TestStackObjectPool extends
      * the caller.  Objects that throw on activate are destroyed and if none succeed,
      * the caller gets NoSuchElementException.
      */
+    @Test
     public void testExceptionOnActivate() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
@@ -327,6 +349,7 @@ public class TestStackObjectPool extends
      * Verifies that exceptions thrown by factory destroy are swallowed
      * by both addObject and returnObject.
      */
+    @Test
     public void testExceptionOnDestroy() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
@@ -350,6 +373,7 @@ public class TestStackObjectPool extends
      * Verifies that addObject propagates exceptions thrown by
      * factory passivate, but returnObject swallows these.
      */
+    @Test
     public void testExceptionOnPassivate() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
@@ -374,6 +398,7 @@ public class TestStackObjectPool extends
     /**
      * Verifies that validation exceptions always propagate
      */
+    @Test
     public void testExceptionOnValidate() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
@@ -412,6 +437,7 @@ public class TestStackObjectPool extends
     /**
      * Verifies that exceptions thrown by makeObject are propagated.
      */
+    @Test
     public void testExceptionOnMake() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         factory.setThrowOnMake(true);
@@ -433,6 +459,7 @@ public class TestStackObjectPool extends
     /**
      * Verifies NoSuchElementException when the factory returns a null object in borrowObject
      */
+    @Test
     public void testMakeNull() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
@@ -448,6 +475,7 @@ public class TestStackObjectPool extends
     /**
      * Verifies that initIdleCapacity is not a hard limit, but maxIdle is.
      */
+    @Test
     public void testInitIdleCapacityExceeded() throws Exception {
         PoolableObjectFactory<Object> factory = new SimpleFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2, 1);
@@ -466,6 +494,7 @@ public class TestStackObjectPool extends
      * are destroyed, add/borrowObject throw IllegalStateException.
      */
     @Override
+    @Test
     public void testClose() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory);



Mime
View raw message