DataSource mockDataSourceBean = EasyMock.createNiceMock(DataSource.class);
expect(this.mockConfig.getDatasourceBean()).andReturn(mockDataSourceBean).anyTimes();
expect(mockConfig.getJdbcUrl()).andReturn("jdbc:mock:driver").anyTimes();
mockConfig.setAcquireRetryDelayInMs(1);
CustomHook testHook = new CustomHook();
expect(mockConfig.getConnectionHook()).andReturn(testHook).anyTimes();
// make it fail the first time and succeed the second time
expect(this.mockPool.getDbIsDown()).andReturn(new AtomicBoolean()).anyTimes();
expect(mockDataSourceBean.getConnection()).andThrow(new SQLException()).once().andReturn(null).once(); // a call in obtainRaw
expect(mockConnection.getInternalConnection()).andReturn(new MockConnection()).anyTimes(); // a call in obtainRaw