commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1021858 - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool/ java/org/apache/commons/pool/impl/ test/org/apache/commons/pool/ test/org/apache/commons/pool/impl/
Date Tue, 12 Oct 2010 17:47:17 GMT
Author: simonetripodi
Date: Tue Oct 12 17:47:16 2010
New Revision: 1021858

URL: http://svn.apache.org/viewvc?rev=1021858&view=rev
Log:
removed the setFactory() from both Interfaces and Implementations

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolUtils.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestPoolUtils.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseKeyedObjectPool.java Tue
Oct 12 17:47:16 2010
@@ -126,18 +126,6 @@ public abstract class BaseKeyedObjectPoo
     }
 
     /**
-     * Not supported in this base implementation.
-     * Always throws an {@link UnsupportedOperationException},
-     * subclasses should override this behavior.
-     * @param factory the new KeyedPoolableObjectFactory
-     * @deprecated to be removed in pool 2.0
-     */
-    @Deprecated
-    public void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws IllegalStateException,
UnsupportedOperationException {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
      * Has this pool instance been closed.
      * @return <code>true</code> when this pool has been closed.
      * @since Pool 1.4

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java Tue Oct
12 17:47:16 2010
@@ -106,21 +106,6 @@ public abstract class BaseObjectPool<T> 
     }
 
     /**
-     * Not supported in this base implementation.
-     * Always throws an {@link UnsupportedOperationException},
-     * subclasses should override this behavior.
-     * 
-     * @param factory the PoolableObjectFactory
-     * @throws UnsupportedOperationException
-     * @throws IllegalStateException
-     * @deprecated to be removed in pool 2.0
-     */
-    @Deprecated
-    public void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
      * Has this pool instance been closed.
      * @return <code>true</code> when this pool has been closed.
      */

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java Tue Oct
12 17:47:16 2010
@@ -212,19 +212,4 @@ public interface KeyedObjectPool<K,V> {
      * @throws Exception
      */
     void close() throws Exception;
-
-    /**
-     * Sets the {@link KeyedPoolableObjectFactory factory} the pool uses
-     * to create new instances (optional operation).
-     * Trying to change the <code>factory</code> after a pool has been used will
frequently
-     * throw an {@link UnsupportedOperationException}. It is up to the pool
-     * implementation to determine when it is acceptable to call this method.
-     *
-     * @param factory the {@link KeyedPoolableObjectFactory} used to create new instances.
-     * @throws IllegalStateException when the factory cannot be set at this time
-     * @throws UnsupportedOperationException when this implementation doesn't support the
operation
-     * @deprecated to be removed in pool 2.0
-     */
-    @Deprecated
-    void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws IllegalStateException,
UnsupportedOperationException;
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java Tue Oct 12
17:47:16 2010
@@ -173,19 +173,4 @@ public interface ObjectPool<T> {
      * @throws Exception <strong>deprecated</strong>: implementations should
silently fail if not all resources can be freed.
      */
     void close() throws Exception;
-
-    /**
-     * Sets the {@link PoolableObjectFactory factory} this pool uses
-     * to create new instances (optional operation). Trying to change
-     * the <code>factory</code> after a pool has been used will frequently
-     * throw an {@link UnsupportedOperationException}. It is up to the pool
-     * implementation to determine when it is acceptable to call this method.
-     *
-     * @param factory the {@link PoolableObjectFactory} used to create new instances.
-     * @throws IllegalStateException when the factory cannot be set at this time
-     * @throws UnsupportedOperationException if this implementation does not support the
operation
-     * @deprecated to be removed in pool 2.0
-     */
-    @Deprecated
-    void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException;
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolUtils.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolUtils.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolUtils.java Tue Oct 12 17:47:16
2010
@@ -18,12 +18,12 @@
 package org.apache.commons.pool;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.Collections;
 
 /**
  * This class consists exclusively of static methods that operate on or return ObjectPool
@@ -842,17 +842,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the PoolableObjectFactory for the pool.
-         * 
-         * @param factory new PoolableObjectFactory 
-         * @deprecated to be removed in version 2.0
-         */
-        @Deprecated
-        public void setFactory(final PoolableObjectFactory<V> factory) throws IllegalStateException,
UnsupportedOperationException {
-            keyedPool.setFactory((KeyedPoolableObjectFactory<K, V>) adapt(factory));
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -996,17 +985,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the factory used to manage objects.
-         * 
-         * @param factory new factory to use managing object instances
-         * @deprecated to be removed in version 2.0
-         */
-        @Deprecated
-        public void setFactory(final KeyedPoolableObjectFactory<K,V> factory) throws
IllegalStateException, UnsupportedOperationException {
-            pool.setFactory(adapt((KeyedPoolableObjectFactory<Object, V>) factory));
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -1144,17 +1122,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the object factory associated with the pool
-         * 
-         * @param factory object factory
-         * @deprecated to be removed in version 2.0
-         */
-        @Deprecated
-        public void setFactory(final PoolableObjectFactory factory) throws IllegalStateException,
UnsupportedOperationException {
-            pool.setFactory(factory);
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -1316,17 +1283,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the object factory associated with the pool
-         * 
-         * @param factory object factory
-         * @deprecated to be removed in version 2.0
-         */
-        @Deprecated
-        public void setFactory(final KeyedPoolableObjectFactory factory) throws IllegalStateException,
UnsupportedOperationException {
-            keyedPool.setFactory(factory);
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -1594,19 +1550,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the factory used by the pool.
-         * 
-         * @param factory new PoolableObjectFactory
-         * @deprecated to be removed in pool 2.0
-         */
-        @Deprecated
-        public void setFactory(final PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException {
-            synchronized (lock) {
-                pool.setFactory(factory);
-            }
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -1763,19 +1706,6 @@ public final class PoolUtils {
         }
 
         /**
-         * Sets the object factory used by the pool.
-         * 
-         * @param factory KeyedPoolableObjectFactory used by the pool
-         * @deprecated to be removed in pool 2.0
-         */
-        @Deprecated
-        public void setFactory(final KeyedPoolableObjectFactory<K,V> factory) throws
IllegalStateException, UnsupportedOperationException {
-            synchronized (lock) {
-                keyedPool.setFactory(factory);
-            }
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -2153,15 +2083,6 @@ public final class PoolUtils {
 
         /**
          * {@inheritDoc}
-         * @deprecated to be removed in pool 2.0
-         */
-        @Deprecated
-        public void setFactory(final PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException {
-            pool.setFactory(factory);
-        }
-
-        /**
-         * {@inheritDoc}
          */
         @Override
         public String toString() {
@@ -2337,15 +2258,6 @@ public final class PoolUtils {
         }
 
         /**
-         * {@inheritDoc}
-         * @deprecated to be removed in pool 2.0
-         */
-        @Deprecated
-        public void setFactory(final KeyedPoolableObjectFactory<K,V> factory) throws
IllegalStateException, UnsupportedOperationException {
-            keyedPool.setFactory(factory);
-        }
-
-        /**
          * Returns the underlying pool
          * 
          * @return the keyed pool that this ErodingKeyedObjectPool wraps

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -1706,50 +1706,6 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * <p>Sets the keyed poolable object factory associated with this pool.</p>
-     * 
-     * <p>If this method is called when objects are checked out of any of the keyed
pools,
-     * an IllegalStateException is thrown.  Calling this method also has the side effect
of
-     * destroying any idle instances in existing keyed pools, using the original factory.</p>
-     * 
-     * @param factory KeyedPoolableObjectFactory to use when creating keyed object pool instances
-     * @throws IllegalStateException if there are active (checked out) instances associated
with this keyed object pool
-     * @deprecated to be removed in version 2.0
-     */
-    @Deprecated
-    @Override
-    public void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws IllegalStateException
{
-        Map<K, List<ObjectTimestampPair<V>>> toDestroy = new HashMap<K,
List<ObjectTimestampPair<V>>>();
-        final KeyedPoolableObjectFactory<K,V> oldFactory = _factory;
-        synchronized (this) {
-            assertOpen();
-            if (0 < getNumActive()) {
-                throw new IllegalStateException("Objects are already active");
-            } else {
-                for (Iterator<K> it = _poolMap.keySet().iterator(); it.hasNext();)
{
-                    K key = it.next();
-                    ObjectQueue pool = _poolMap.get(key);
-                    if (pool != null) {
-                        // Copy objects to new list so pool.queue can be cleared
-                        // inside the sync
-                        List<ObjectTimestampPair<V>> objects = new ArrayList<ObjectTimestampPair<V>>();
-                        objects.addAll(pool.queue);
-                        toDestroy.put(key, objects);
-                        it.remove();
-                        _poolList.remove(key);
-                        _totalIdle = _totalIdle - pool.queue.size();
-                        _totalInternalProcessing =
-                            _totalInternalProcessing + pool.queue.size();
-                        pool.queue.clear();
-                    }
-                }
-                _factory = factory;
-            }
-        }
-        destroy(toDestroy, oldFactory);
-    }
-
-    /**
      * <p>Perform <code>numTests</code> idle object eviction tests, evicting
      * examined objects that meet the criteria for eviction. If
      * <code>testWhileIdle</code> is true, examined objects are validated

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -1413,37 +1413,6 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Sets the {@link PoolableObjectFactory factory} this pool uses
-     * to create new instances. Trying to change
-     * the <code>factory</code> while there are borrowed objects will
-     * throw an {@link IllegalStateException}.  If there are instances idle
-     * in the pool when this method is invoked, these will be destroyed
-     * using the original factory.
-     *
-     * @param factory the {@link PoolableObjectFactory} used to create new instances.
-     * @throws IllegalStateException when the factory cannot be set at this time
-     * @deprecated to be removed in version 2.0
-     */
-    @Deprecated
-    @Override
-    public void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException
{
-        List<ObjectTimestampPair<T>> toDestroy = new ArrayList<ObjectTimestampPair<T>>();
-        final PoolableObjectFactory<T> oldFactory = _factory;
-        synchronized (this) {
-            assertOpen();
-            if(0 < getNumActive()) {
-                throw new IllegalStateException("Objects are already active");
-            } else {
-                toDestroy.addAll(_pool);
-                _numInternalProcessing = _numInternalProcessing + _pool._size;
-                _pool.clear();
-            }
-            _factory = factory;
-        }
-        destroy(toDestroy, oldFactory); 
-    }
-
-    /**
      * <p>Perform <code>numTests</code> idle object eviction tests, evicting
      * examined objects that meet the criteria for eviction. If
      * <code>testWhileIdle</code> is true, examined objects are validated

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -311,27 +311,6 @@ public class SoftReferenceObjectPool<T> 
     }
 
     /**
-     * Sets the {@link PoolableObjectFactory factory} this pool uses
-     * to create new instances. Trying to change
-     * the <code>factory</code> while there are borrowed objects will
-     * throw an {@link IllegalStateException}.
-     *
-     * @param factory the {@link PoolableObjectFactory} used to create new instances.
-     * @throws IllegalStateException when the factory cannot be set at this time
-     * @deprecated to be removed in pool 2.0
-     */
-    @Override
-    public synchronized void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException
{
-        assertOpen();
-        if(0 < getNumActive()) {
-            throw new IllegalStateException("Objects are already active");
-        } else {
-            clear();
-            _factory = factory;
-        }
-    }
-
-    /**
      * If any idle objects were garbage collected, remove their
      * {@link Reference} wrappers from the idle object pool.
      */

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -463,26 +463,6 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * Sets the {@link KeyedPoolableObjectFactory factory} the pool uses
-     * to create new instances.
-     * Trying to change the <code>factory</code> after a pool has been used will
frequently
-     * throw an {@link UnsupportedOperationException}.
-     *
-     * @param factory the {@link KeyedPoolableObjectFactory} used to manage object instances
-     * @throws IllegalStateException when the factory cannot be set at this time
-     * @deprecated to be removed in pool 2.0
-     */
-    @Override
-    public synchronized void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws
IllegalStateException {
-        if(0 < getNumActive()) {
-            throw new IllegalStateException("Objects are already active");
-        } else {
-            clear();
-            _factory = factory;
-        }
-    }
-    
-    /**
      * @return the {@link KeyedPoolableObjectFactory} used by this pool to manage object
instances.
      * @since 1.5.5
      */

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -124,13 +124,6 @@ public class TestBaseKeyedObjectPool ext
             // expected
         }
 
-        try {
-            pool.setFactory(null);
-            fail("Expected UnsupportedOperationException");
-        } catch(UnsupportedOperationException e) {
-            // expected
-        }
-
         pool.close(); // a no-op, probably should be remove
 
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java Tue
Oct 12 17:47:16 2010
@@ -99,13 +99,6 @@ public class TestBaseObjectPool extends 
         } catch(UnsupportedOperationException e) {
             // expected
         }
-
-        try {
-            pool.setFactory(null);
-            fail("Expected UnsupportedOperationException");
-        } catch(UnsupportedOperationException e) {
-            // expected
-        }
     }
 
     public void testClose() throws Exception {

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestObjectPool.java Tue Oct
12 17:47:16 2010
@@ -16,16 +16,17 @@
  */
 package org.apache.commons.pool;
 
-import junit.framework.TestCase;
-import org.apache.commons.pool.impl.GenericObjectPool;
-import org.apache.commons.pool.impl.StackObjectPool;
-import org.apache.commons.pool.impl.SoftReferenceObjectPool;
-
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.NoSuchElementException;
 
+import junit.framework.TestCase;
+
+import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool.impl.SoftReferenceObjectPool;
+import org.apache.commons.pool.impl.StackObjectPool;
+
 /**
  * Abstract {@link TestCase} for {@link ObjectPool} implementations.
  * @author Rodney Waldhoff
@@ -390,21 +391,6 @@ public abstract class TestObjectPool ext
         pool.close();
     }
 
-    public void testSetFactory() throws Exception {
-        ObjectPool<Object> pool;
-        try {
-            pool = makeEmptyPool(new MethodCallPoolableObjectFactory());
-        } catch (UnsupportedOperationException uoe) {
-            return; // test not supported
-        }
-        final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        try {
-            pool.setFactory(factory);
-        } catch (UnsupportedOperationException uoe) {
-            return;
-        }
-    }
-
     public void testToString() {
         ObjectPool<Object> pool;
         try {

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestPoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestPoolUtils.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestPoolUtils.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestPoolUtils.java Tue Oct
12 17:47:16 2010
@@ -857,13 +857,12 @@ public class TestPoolUtils extends TestC
         op.getNumIdle();
         op.invalidateObject(new Object());
         op.returnObject(new Object());
-        op.setFactory((PoolableObjectFactory<Object>)createProxy(PoolableObjectFactory.class,
(List)null));
         op.toString();
 
         final List<String> expectedMethods = Arrays.asList(new String[] {
                 "addObject", "borrowObject", "clear", "close",
                 "getNumActive", "getNumIdle", "invalidateObject",
-                "returnObject", "setFactory", "toString"
+                "returnObject", "toString"
         });
         return expectedMethods;
     }
@@ -880,13 +879,12 @@ public class TestPoolUtils extends TestC
         kop.getNumIdle(null);
         kop.invalidateObject(null, new Object());
         kop.returnObject(null, new Object());
-        kop.setFactory((KeyedPoolableObjectFactory<Object,Object>)createProxy(KeyedPoolableObjectFactory.class,
(List<String>)null));
         kop.toString();
 
         final List<String> expectedMethods = Arrays.asList(new String[] {
                 "addObject", "borrowObject", "clear", "clear", "close",
                 "getNumActive", "getNumActive", "getNumIdle", "getNumIdle", "invalidateObject",
-                "returnObject", "setFactory", "toString"
+                "returnObject", "toString"
         });
         return expectedMethods;
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -327,10 +327,7 @@ public class TestGenericKeyedObjectPool 
     }
 
     public void testSettersAndGetters() throws Exception {
-        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>();
-        {
-            pool.setFactory(new SimpleFactory<String>());
-        }
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(new
SimpleFactory<String>());
         {
             pool.setMaxActive(123);
             assertEquals(123,pool.getMaxActive());

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -459,37 +459,6 @@ public class TestGenericObjectPool exten
         assertEquals(0, pool.getNumIdle());
     }
 
-    public void testSetFactoryWithActiveObjects() 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");
-        } catch(IllegalStateException e) {
-            // expected
-        }
-    }
-
-    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());
-    }
-    
     public void testNegativeMaxActive() throws Exception {
         pool.setMaxActive(-1);
         pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
@@ -585,7 +554,7 @@ public class TestGenericObjectPool exten
         
         SimpleFactory factory = new SimpleFactory();
         factory.setMaxActive(maxActive);
-        pool.setFactory(factory);
+        pool = new GenericObjectPool<Object>(factory);
         pool.setMaxActive(maxActive);
         pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
         pool.setTimeBetweenEvictionRunsMillis(-1);
@@ -655,10 +624,7 @@ public class TestGenericObjectPool exten
     }
 
     public void testSettersAndGetters() throws Exception {
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
-        {
-            pool.setFactory(new SimpleFactory());
-        }
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
         {
             pool.setMaxActive(123);
             assertEquals(123,pool.getMaxActive());
@@ -1485,7 +1451,7 @@ public class TestGenericObjectPool exten
 
         SimpleFactory factory = new SimpleFactory();
         factory.setMaxActive(maxActive);
-        pool.setFactory(factory);
+        pool = new GenericObjectPool<Object>(factory);
         pool.setMaxActive(maxActive);
         pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
         pool.setTimeBetweenEvictionRunsMillis(-1);
@@ -1528,7 +1494,7 @@ public class TestGenericObjectPool exten
         
         SimpleFactory factory = new SimpleFactory();
         factory.setMaxActive(maxActive);
-        pool.setFactory(factory);
+        pool = new GenericObjectPool<Object>(factory);
         pool.setMaxActive(maxActive);
         pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
         pool.setTestOnBorrow(true);

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java?rev=1021858&r1=1021857&r2=1021858&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
Tue Oct 12 17:47:16 2010
@@ -206,50 +206,6 @@ public class TestStackKeyedObjectPool ex
         }
     }
 
-    public void testSetFactory() throws Exception {
-        KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
-        try {
-            pool.borrowObject("x");
-            fail("Expected NoSuchElementException");
-        } catch(NoSuchElementException e) {
-            // expected
-        }
-        pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject("x");
-        assertNotNull(obj);
-        pool.returnObject("x",obj);
-    }
-
-    public void testCantResetFactoryWithActiveObjects() throws Exception {
-        KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
-        pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject("x");
-        assertNotNull(obj);
-
-        try {
-            pool.setFactory(new SimpleFactory());
-            fail("Expected IllegalStateException");
-        } catch(IllegalStateException e) {
-            // expected
-        }
-    }
-
-    public void testCanResetFactoryWithoutActiveObjects() throws Exception {
-        KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
-        {
-            pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");
-            assertNotNull(obj);
-            pool.returnObject("x",obj);
-        }
-        {
-            pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");
-            assertNotNull(obj);
-            pool.returnObject("x",obj);
-        }
-    }
-
     public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
         KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(
             new KeyedPoolableObjectFactory<Object,Object>() {



Mime
View raw message