Author: dbrosius Date: Tue Oct 15 02:52:47 2013 New Revision: 1532170 URL: http://svn.apache.org/r1532170 Log: update junit usage to version 4
Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java 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 commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestObjectPool.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java Tue Oct 15 02:52:47 2013 @@ -16,7 +16,7 @@ */ package org.apache.commons.pool2; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertTrue; import org.junit.Test; 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=1532170&r1=1532169&r2=1532170&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 Tue Oct 15 02:52:47 2013 @@ -16,9 +16,9 @@ */ package org.apache.commons.pool2; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.junit.Test; 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=1532170&r1=1532169&r2=1532170&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 Tue Oct 15 02:52:47 2013 @@ -16,7 +16,7 @@ */ package org.apache.commons.pool2; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertTrue; import org.junit.Test; 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=1532170&r1=1532169&r2=1532170&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 Tue Oct 15 02:52:47 2013 @@ -16,15 +16,13 @@ */ package org.apache.commons.pool2; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; -import junit.framework.TestCase; - import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.commons.pool2.impl.GenericKeyedObjectPool; import org.junit.After; Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestObjectPool.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestObjectPool.java Tue Oct 15 02:52:47 2013 @@ -16,9 +16,7 @@ */ package org.apache.commons.pool2; -import static junit.framework.Assert.*; - -import junit.framework.TestCase; +import static org.junit.Assert.*; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.PooledObjectFactory; Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java Tue Oct 15 02:52:47 2013 @@ -17,8 +17,8 @@ package org.apache.commons.pool2; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Set; import java.util.TimerTask; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.AssertionFailedError; import org.apache.commons.pool2.impl.DefaultPooledObject; Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java Tue Oct 15 02:52:47 2013 @@ -25,23 +25,24 @@ import java.util.concurrent.atomic.Atomi import javax.management.MBeanServer; import javax.management.ObjectName; -import junit.framework.TestCase; - import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.TrackedUse; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * TestCase for AbandonedObjectPool * * @version $Revision: 1158659 $ $Date: 2011-08-17 05:37:26 -0700 (Wed, 17 Aug 2011) $ */ -public class TestAbandonedObjectPool extends TestCase { +public class TestAbandonedObjectPool { private GenericObjectPool<PooledTestObject> pool = null; private AbandonedConfig abandonedConfig = null; - @Override + @Before public void setUp() throws Exception { abandonedConfig = new AbandonedConfig(); @@ -56,7 +57,7 @@ public class TestAbandonedObjectPool ext abandonedConfig); } - @Override + @After public void tearDown() throws Exception { String poolName = pool.getJmxName().toString(); pool.clear(); @@ -87,6 +88,7 @@ public class TestAbandonedObjectPool ext * in GenericObjectPool * */ + @Test public void testConcurrentInvalidation() throws Exception { final int POOL_SIZE = 30; pool.setMaxTotal(POOL_SIZE); @@ -126,7 +128,7 @@ public class TestAbandonedObjectPool ext } // Now, the number of active instances should be 0 - assertTrue("numActive should have been 0, was " + pool.getNumActive(), pool.getNumActive() == 0); + Assert.assertTrue("numActive should have been 0, was " + pool.getNumActive(), pool.getNumActive() == 0); } /** @@ -134,6 +136,7 @@ public class TestAbandonedObjectPool ext * is destroyed instead of being returned to the pool (and possibly later destroyed * inappropriately). */ + @Test public void testAbandonedReturn() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnBorrow(true); @@ -159,15 +162,16 @@ public class TestAbandonedObjectPool ext // off removeAbandoned and then returns an instance that borrowObject // will deem abandoned. Make sure it is not returned to the borrower. returner.start(); // short delay, then return instance - assertTrue(pool.borrowObject().hashCode() != deadMansHash); - assertEquals(0, pool.getNumIdle()); - assertEquals(1, pool.getNumActive()); + Assert.assertTrue(pool.borrowObject().hashCode() != deadMansHash); + Assert.assertEquals(0, pool.getNumIdle()); + Assert.assertEquals(1, pool.getNumActive()); } /** * Verify that an object that gets flagged as abandoned and is subsequently * invalidated is only destroyed (and pool counter decremented) once. */ + @Test public void testAbandonedInvalidate() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); @@ -188,14 +192,15 @@ public class TestAbandonedObjectPool ext Thread.sleep(1000); // abandon checked out instances and let evictor start pool.invalidateObject(obj); // Should not trigger another destroy / decrement Thread.sleep(2000); // give evictor time to finish destroys - assertEquals(0, pool.getNumActive()); - assertEquals(5, pool.getDestroyedCount()); + Assert.assertEquals(0, pool.getNumActive()); + Assert.assertEquals(5, pool.getDestroyedCount()); } /** * Verify that an object that the evictor identifies as abandoned while it * is in process of being returned to the pool is not destroyed. */ + @Test public void testRemoveAbandonedWhileReturning() throws Exception { abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(true); @@ -217,8 +222,8 @@ public class TestAbandonedObjectPool ext Thread.sleep(50); // abandon obj pool.returnObject(obj); // evictor will run during validation PooledTestObject obj2 = pool.borrowObject(); - assertEquals(obj, obj2); // should get original back - assertTrue(!obj2.isDestroyed()); // and not destroyed + Assert.assertEquals(obj, obj2); // should get original back + Assert.assertTrue(!obj2.isDestroyed()); // and not destroyed } class ConcurrentBorrower extends Thread { Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Tue Oct 15 02:52:47 2013 @@ -17,12 +17,12 @@ package org.apache.commons.pool2.impl; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNotSame; -import static junit.framework.Assert.assertSame; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.PrintWriter; import java.io.StringWriter; Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java Tue Oct 15 02:52:47 2013 @@ -17,11 +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.assertNull; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.management.ManagementFactory; import java.util.ArrayList; Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java Tue Oct 15 02:52:47 2013 @@ -19,16 +19,18 @@ package org.apache.commons.pool2.impl; import java.net.URL; import java.net.URLClassLoader; -import junit.framework.TestCase; - import org.apache.commons.pool2.BasePooledObjectFactory; -public class TestGenericObjectPoolClassLoaders extends TestCase { +import org.junit.Assert; +import org.junit.Test; + +public class TestGenericObjectPoolClassLoaders { private static final URL BASE_URL = TestGenericObjectPoolClassLoaders.class.getResource( "/org/apache/commons/pool2/impl/"); + @Test public void testContextClassLoader() throws Exception { ClassLoader savedClassloader = @@ -47,7 +49,7 @@ public class TestGenericObjectPoolClassL Thread.sleep(100); counter++; } - assertEquals("Wrong number of idle objects in pool1", 1, + Assert.assertEquals("Wrong number of idle objects in pool1", 1, pool1.getNumIdle()); // --------------- @@ -60,7 +62,7 @@ public class TestGenericObjectPoolClassL pool2.setMinIdle(1); pool2.addObject(); - assertEquals("Wrong number of idle objects in pool2", 1, + Assert.assertEquals("Wrong number of idle objects in pool2", 1, pool2.getNumIdle()); pool2.clear(); @@ -71,7 +73,7 @@ public class TestGenericObjectPoolClassL Thread.sleep(100); counter++; } - assertEquals("Wrong number of idle objects in pool2", 1, + Assert.assertEquals("Wrong number of idle objects in pool2", 1, pool2.getNumIdle()); pool1.close(); Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java?rev=1532170&r1=1532169&r2=1532170&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java (original) +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java Tue Oct 15 02:52:47 2013 @@ -17,9 +17,9 @@ package org.apache.commons.pool2.impl; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.LinkedList;