BoneCPConnectionProvider implements ConnectionProvider,Configurable,Stoppable { protected BoneCP createPool(BoneCPConfig config) { try{ return new BoneCP(config); } catch (SQLException e) { throw new HibernateException(e); } }  void closeConnection(Connection conn); void configure(Properties props); Connection getConnection(); boolean supportsAggressiveRelease(); ClassLoader getClassLoader(); void setClassLoader(ClassLoader classLoader); @Override @SuppressWarnings("rawtypes") boolean isUnwrappableAs(Class unwrapType); @SuppressWarnings("unchecked") @Override T unwrap(Class<T> unwrapType); @SuppressWarnings({ "unchecked", "rawtypes" }) @Override void configure(Map configurationValues); @Override void stop(); void close();  }
@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(); replay(mockConfig); try{ testClass.createPool(mockConfig); fail("Should throw an exception"); } catch (RuntimeException e){ } 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); } catch (RuntimeException e){ fail("Should pass: "); } verify(mockConfig); }