BoneCP implements Serializable, Closeable { protected void unregisterDriver(){ String jdbcURL = this.config.getJdbcUrl(); if ((jdbcURL != null) && this.config.isDeregisterDriverOnClose()){ logger.info("Unregistering JDBC driver for : "+jdbcURL); try { DriverManager.deregisterDriver(DriverManager.getDriver(jdbcURL)); } catch (SQLException e) { logger.info("Unregistering driver failed.", e); } } } BoneCP(BoneCPConfig config); synchronized void shutdown(); void close(); Connection getConnection(); ListenableFuture<Connection> getAsyncConnection(); boolean isConnectionHandleAlive(ConnectionHandle connection); int getTotalLeased(); int getTotalFree(); int getTotalCreatedConnections(); BoneCPConfig getConfig(); Statistics getStatistics(); AtomicBoolean getDbIsDown(); static final String MBEAN_CONFIG; static final String MBEAN_BONECP; }
@Test public void testUnregisterDriver() { expect(mockConfig.isDeregisterDriverOnClose()).andReturn(true).anyTimes(); expect(mockConfig.getJdbcUrl()).andReturn("jdbc:mock").anyTimes(); replay(mockConfig); try { Assert.assertNotNull(DriverManager.getDriver("jdbc:mock")); } catch (SQLException e1) { fail("SQLException thrown"); } testClass.unregisterDriver(); testClass.unregisterDriver(); }