Examples of returnObject()


Examples of org.apache.commons.pool.ObjectPool.returnObject()

        // returnObject
        factory.setThrowOnValidate(false);
        Object obj = pool.borrowObject();
        factory.setThrowOnValidate(true);
        try {
            pool.returnObject(obj);
            fail("Expecting IntegerFactoryException");
        } catch (IntegerFactoryException ex) {
            assertEquals("validateObject", ex.getType());
        }
        assertEquals(0, pool.getNumIdle());
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        assertEquals(1, pool.getNumActive());
        List destroyed = factory.getDestroyed();
        assertEquals(2, destroyed.size());
        assertTrue(destroyed.contains(new Integer(0)));
        assertTrue(destroyed.contains(new Integer(0)));
        pool.returnObject(two);
        assertTrue(destroyed.contains(two));
        try {
            pool.addObject();
            fail("Expecting IllegalStateException");
        } catch (IllegalStateException ex) {
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

                    ObjectPool pool = getClientPool(endpoint);
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("Releasing connection for endpoint " + endpoint.getEndpointURI());
                    }
                    pool.returnObject(client);
                }
            }
        }
        else
        {
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

       
        factory.setValidateSelectively(true)// Even numbers fail validation
        factory.setPassivateSelectively(true); // Multiples of 3 fail passivation

        for(int i=0;i<10;i++) {
            pool.returnObject(obj[i]);
            assertEquals("Each time we return, get one less active.", 9-i, pool.getNumActive());
        }
        // 0,2,4,6,8 fail validation, 3, 9 fail passivation - 3 left.
        assertEquals(3,pool.getNumIdle());
    }
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        Integer i2 = (Integer)pool.borrowObject();
        Integer i3 = (Integer)pool.borrowObject();

        // tests
        // return as many as the pool will hold.
        pool.returnObject(i0);
        pool.returnObject(i1);
        pool.returnObject(i2);

        // the pool should now be full.
        assertEquals("No returned objects should have been destroyed yet.", 0,  factory.getDestroyed().size());
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        Integer i3 = (Integer)pool.borrowObject();

        // tests
        // return as many as the pool will hold.
        pool.returnObject(i0);
        pool.returnObject(i1);
        pool.returnObject(i2);

        // the pool should now be full.
        assertEquals("No returned objects should have been destroyed yet.", 0,  factory.getDestroyed().size());
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        // tests
        // return as many as the pool will hold.
        pool.returnObject(i0);
        pool.returnObject(i1);
        pool.returnObject(i2);

        // the pool should now be full.
        assertEquals("No returned objects should have been destroyed yet.", 0,  factory.getDestroyed().size());

        // cause the pool to discard a stale object.
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        // the pool should now be full.
        assertEquals("No returned objects should have been destroyed yet.", 0,  factory.getDestroyed().size());

        // cause the pool to discard a stale object.
        pool.returnObject(i3);
        assertEquals("One object should have been destroyed.", 1, factory.getDestroyed().size());

        // check to see what object was destroyed
        Integer d = (Integer)factory.getDestroyed().get(0);
        assertEquals("Destoryed object should be the stalest object.", i0, d);
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool.returnObject()

        Object[] objects = new Object[3];
        for (int i = 0; i < 3; i++) {
            objects[i] = pool.borrowObject();
        }
        for (int i = 0; i < 3; i++) {
            pool.returnObject(objects[i]); // Third triggers destroy
        }
        assertEquals(2, pool.getNumIdle());
    }
   
    /**
 
View Full Code Here

Examples of org.apache.commons.pool.impl.GenericKeyedObjectPool.returnObject()

                @Override
                public void doOperation(int id) throws Exception {
                    Integer key = id % numKeys;
                    String s = (String) pool.borrowObject(key);
                    pool.returnObject(key, s);
                }
            };
            test.run(numRequests, numThreads);
            test.printStats();
            System.out.println();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.