commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1136160 - /commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
Date Wed, 15 Jun 2011 19:45:35 GMT
Author: psteitz
Date: Wed Jun 15 19:45:35 2011
New Revision: 1136160

URL: http://svn.apache.org/viewvc?rev=1136160&view=rev
Log:
Fixed test failures due to factory reset no longer supported.

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

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=1136160&r1=1136159&r2=1136160&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
Wed Jun 15 19:45:35 2011
@@ -479,18 +479,13 @@ public class TestGenericObjectPool exten
     }
 
     @Test
-    public void testSetFactoryWithActiveObjects() throws Exception {
+    /**
+     * Verify that once the factory is set, it cannot be reset.
+     * This is a change in behavior as of Pool 2.0
+     */
+    public void testSetFactoryAlreadySet() throws Exception {
         GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
-        pool.setMaxIdle(10);
         pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject();
-        assertNotNull(obj);
-        try {
-            pool.setFactory(null);
-            fail("Expected IllegalStateException");
-        } catch(IllegalStateException e) {
-            // expected
-        }
         try {
             pool.setFactory(new SimpleFactory());
             fail("Expected IllegalStateException");
@@ -500,18 +495,6 @@ public class TestGenericObjectPool exten
     }
 
     @Test
-    public void testSetFactoryWithNoActiveObjects() throws Exception {
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
-        pool.setMaxIdle(10);
-        pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject();
-        pool.returnObject(obj);
-        assertEquals(1,pool.getNumIdle());
-        pool.setFactory(new SimpleFactory());
-        assertEquals(0,pool.getNumIdle());
-    }
-
-    @Test
     public void testNegativeMaxTotal() throws Exception {
         pool.setMaxTotal(-1);
         pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
@@ -613,6 +596,7 @@ public class TestGenericObjectPool exten
         
         SimpleFactory factory = new SimpleFactory();
         factory.setMaxTotal(maxTotal);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
         pool.setFactory(factory);
         pool.setMaxTotal(maxTotal);
         pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
@@ -1534,6 +1518,7 @@ public class TestGenericObjectPool exten
     public void testBrokenFactoryShouldNotBlockPool() {
         int maxTotal = 1;
         
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
         SimpleFactory factory = new SimpleFactory();
         factory.setMaxTotal(maxTotal);
         pool.setFactory(factory);



Mime
View raw message