BoneCP implements Serializable, Closeable { protected void releaseConnection(Connection connection) throws SQLException { ConnectionHandle handle = (ConnectionHandle)connection; if (handle.getConnectionHook() != null){ handle.getConnectionHook().onCheckIn(handle); } if (!this.poolShuttingDown){ internalReleaseConnection(handle); } } 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 testReleaseConnection() throws SQLException, IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException, InterruptedException { expect(mockConnection.isPossiblyBroken()).andReturn(false).once(); expect(mockConnection.getOriginatingPartition()).andReturn(mockPartition).anyTimes(); expect(mockPartition.getFreeConnections()).andReturn(mockConnectionHandles).anyTimes(); expect(mockPartition.getAvailableConnections()).andReturn(1).anyTimes(); mockConnection.setConnectionLastUsedInMs(anyLong()); expectLastCall().once(); Connection mockRealConnection = EasyMock.createNiceMock(Connection.class); expect(mockConnection.getInternalConnection()).andReturn(mockRealConnection).anyTimes(); replay(mockRealConnection, mockConnection, mockPartition, mockConnectionHandles); testClass.releaseConnection(mockConnection); verify(mockConnection, mockPartition, mockConnectionHandles); reset(mockConnection, mockPartition, mockConnectionHandles); }