Example usage for org.apache.commons.pool PoolUtils prefill

List of usage examples for org.apache.commons.pool PoolUtils prefill

Introduction

In this page you can find the example usage for org.apache.commons.pool PoolUtils prefill.

Prototype

public static void prefill(final KeyedObjectPool keyedPool, final Collection keys, final int count)
        throws Exception, IllegalArgumentException 

Source Link

Document

Call addObject(Object) on keyedPool with each key in keys for count number of times.

Usage

From source file:edu.illinois.enforcemop.examples.apache.pool.TestKeyedObjectPool.java

public void testKPOFClearUsages() throws Exception {
    final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
    final KeyedObjectPool pool;
    try {/*from ww  w  .ja  v  a 2 s  . c om*/
        pool = makeEmptyPool(factory);
    } catch (UnsupportedOperationException uoe) {
        return; // test not supported
    }
    final List expectedMethods = new ArrayList();

    /// Test correct behavior code paths
    PoolUtils.prefill(pool, KEY, 5);
    pool.clear();

    //// Test exception handling clear should swallow destory object failures
    reset(pool, factory, expectedMethods);
    factory.setDestroyObjectFail(true);
    PoolUtils.prefill(pool, KEY, 5);
    pool.clear();
}

From source file:edu.illinois.enforcemop.examples.apache.pool.TestKeyedObjectPool.java

public void testKPOFCloseUsages() throws Exception {
    final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
    KeyedObjectPool pool;//from   www .  j a  va  2  s.  c o m
    try {
        pool = makeEmptyPool(factory);
    } catch (UnsupportedOperationException uoe) {
        return; // test not supported
    }
    final List expectedMethods = new ArrayList();

    /// Test correct behavior code paths
    PoolUtils.prefill(pool, KEY, 5);
    pool.close();

    //// Test exception handling close should swallow failures
    pool = makeEmptyPool(factory);
    reset(pool, factory, expectedMethods);
    factory.setDestroyObjectFail(true);
    PoolUtils.prefill(pool, KEY, 5);
    pool.close();
}