addSendTestExpectations(perThreadExpectations, matcherFive, 11);
PoolableSessionFactoryMock sessionFactoryMock =
sessionFactoryWrapper.getMockedObject();
final Session sessionOne = sessionFactoryWrapper.makeRealSession();
if (onPoolExhaustion == SessionPoolImpl.WHEN_EXHAUSTED_GROW) {
// If the pool should grow when exhausted then basically the max
// size is ignored.
sessionFactoryMock.expects.makeObject().returns(sessionOne).any();
} else {
// Depending on how fast the threads execute, not all of the
// sessions may be required. However at max three sessions should
// be created.
Session sessionTwo = sessionFactoryWrapper.makeRealSession();
Session sessionThree = sessionFactoryWrapper.makeRealSession();
sessionFactoryMock.expects.makeObject().returns(sessionOne);
sessionFactoryMock.expects.makeObject().returns(sessionTwo);
sessionFactoryMock.expects.makeObject().returns(sessionThree);
// Never destroy the objects - they stay in the pool