public void testCheckedPoolKeyedObjectPool() throws Exception {
        try {
            PoolUtils.checkedPool((KeyedObjectPool<Object, Object>)null, Object.class);
            fail("PoolUtils.checkedPool(KeyedObjectPool, Class) must not allow a null pool.");
        } catch(IllegalArgumentException iae) {
            // expected
        }
        try {
            PoolUtils.checkedPool((KeyedObjectPool<?, ?>)createProxy(KeyedObjectPool.class, (List<String>)null), null);
            fail("PoolUtils.checkedPool(KeyedObjectPool, Class) must not allow a null type.");
        } catch(IllegalArgumentException iae) {
            // expected
        }

        final List<String> calledMethods = new ArrayList<String>();
        @SuppressWarnings("unchecked")
        KeyedObjectPool<Object, Object> op = createProxy(KeyedObjectPool.class, calledMethods);

        KeyedObjectPool<Object, Object> cop = PoolUtils.checkedPool(op, Object.class);
        final List<String> expectedMethods = invokeEveryMethod(cop);
        assertEquals(expectedMethods, calledMethods);


        op = new BaseKeyedObjectPool<Object, Object>() {
            @Override
            public Integer borrowObject(Object key) {
                return new Integer(0);
            }

            @Override
            public void returnObject(Object key, Object obj) {}

            @Override
            public void invalidateObject(Object key, Object obj) {}
        };
        @SuppressWarnings("rawtypes")
        final KeyedObjectPool rawPool = op;
        @SuppressWarnings("unchecked")
        KeyedObjectPool<Object, Object> cop2 = PoolUtils.checkedPool(rawPool, String.class);

        try {
            cop2.borrowObject(null);
            fail("borrowObject should have failed as Integer !instanceof String.");
        } catch (ClassCastException cce) {
            // expected
        }
        try {
            cop2.returnObject(null, new Integer(1));
            fail("returnObject should have failed as Integer !instanceof String.");
        } catch (ClassCastException cce) {
            // expected
        }
        try {
            cop2.invalidateObject(null, new Integer(2));
            fail("invalidateObject should have failed as Integer !instanceof String.");
        } catch (ClassCastException cce) {
            // expected
        }
    }