* @throws CloneNotSupportedException
*/
@Test
public void testCreatePool() throws SQLException, ClassNotFoundException, CloneNotSupportedException {
BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnectionsPerPartition()).andReturn(1).anyTimes();
expect(mockConfig.getMinConnectionsPerPartition()).andReturn(1).anyTimes();
expect(mockConfig.getIdleConnectionTestPeriodInMinutes()).andReturn(100L).anyTimes();
expect(mockConfig.getUsername()).andReturn("somethingbad").anyTimes();
expect(mockConfig.getPassword()).andReturn("somethingbad").anyTimes();
expect(mockConfig.getJdbcUrl()).andReturn("invalid").anyTimes();
// expect(mockConfig.getReleaseHelperThreads()).andReturn(1).once().andReturn(0).anyTimes();
replay(mockConfig);
try{
testClass.createPool(mockConfig);
fail("Should throw an exception");
} catch (RuntimeException e){
// do nothing
}
verify(mockConfig);
reset(mockConfig);
Class.forName(DRIVER);
mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnectionsPerPartition()).andReturn(1).anyTimes();
expect(mockConfig.getMinConnectionsPerPartition()).andReturn(1).anyTimes();
expect(mockConfig.getIdleConnectionTestPeriodInMinutes()).andReturn(100L).anyTimes();
expect(mockConfig.getUsername()).andReturn(USERNAME).anyTimes();
expect(mockConfig.getPassword()).andReturn(PASSWORD).anyTimes();
expect(mockConfig.getJdbcUrl()).andReturn(URL).anyTimes();
expect(mockConfig.isLazyInit()).andReturn(false).anyTimes();
expect(mockConfig.clone()).andReturn(mockConfig).anyTimes();
replay(mockConfig);
try{
testClass.createPool(mockConfig);