Examples of returnObject()


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

        ObjectPool pool = new StackObjectPool();
        {
            pool.setFactory(new SimpleFactory());
            Object obj = pool.borrowObject();       
            assertNotNull(obj);
            pool.returnObject(obj);
        }
        {
            pool.setFactory(new SimpleFactory());
            Object obj = pool.borrowObject();       
            assertNotNull(obj);
View Full Code Here

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

        }
        {
            pool.setFactory(new SimpleFactory());
            Object obj = pool.borrowObject();       
            assertNotNull(obj);
            pool.returnObject(obj);
        }
    }

    /**
     * Verifies that validation failures when borrowing newly created instances
View Full Code Here

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

            }
            assertEquals("Each time we borrow, get one more active.", i+1, pool.getNumActive());
        }
        // 1,3,5,...,19 pass validation, get checked out
        for(int i=0;i<10;i++) {
            pool.returnObject(obj[i]);
            assertEquals("Each time we return, get one less active.", 9-i, pool.getNumActive());
        }
        // 3, 9, 15 fail passivation. 
        assertEquals(7,pool.getNumIdle());
        assertEquals(new Integer(19), pool.borrowObject());
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.ObjectPool.returnObject()

        }
        assertEquals(0, pool.getNumIdle());
       
        // returnObject swallows
        Object obj = pool.borrowObject();
        pool.returnObject(obj);
        assertEquals(0, pool.getNumIdle());
    }
   
    /**
     * Verifies that validation exceptions always propagate
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.