BoneCP implements Serializable, Closeable { public int getTotalFree(){ int total=0; for (int i=0; i < this.partitionCount && this.partitions[i] != null ; i++){ total+=this.partitions[i].getAvailableConnections(); } return total; } 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 testGetTotalFree() { expect(mockPartition.getFreeConnections()).andReturn(mockConnectionHandles).anyTimes(); expect(mockPartition.getAvailableConnections()).andReturn(3).anyTimes(); replay(mockPartition, mockConnectionHandles); assertEquals(6, testClass.getTotalFree()); testClass.partitions[1] = null; assertEquals(3, testClass.getTotalFree()); verify(mockPartition, mockConnectionHandles); }