public void testMaximumElements() throws Exception
{
final AtomicInteger counter = new AtomicInteger(0);
AbstractObjectPool pool = new AbstractObjectPool("Test", 0, 0, 0, 0, 1)
{
public Object newInstance()
{
return new Integer(counter.incrementAndGet());
}
};
pool.configure(null);
Object lended = pool.lendObject();
try
{
pool.lendObject();
fail();
} catch (RuntimeException e)
{
// expected
}
try
{
pool.returnObject(new Integer(10));
fail();
} catch (RuntimeException e)
{
// expected
}
try
{
pool.lendObject();
fail();
} catch (RuntimeException e)
{
// expected
}
pool.returnObject(lended);
pool.lendObject();
}