BoneCP implements Serializable, Closeable { public ListenableFuture<Connection> getAsyncConnection(){ return this.asyncExecutor.submit(new Callable<Connection>() { public Connection call() throws Exception { return getConnection(); }}); } 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 testGetAsyncConnection() throws InterruptedException, ExecutionException{ expect(mockPartition.isUnableToCreateMoreTransactions()).andReturn(true).once(); expect(mockPartition.getFreeConnections()).andReturn(mockConnectionHandles).anyTimes(); expect(mockPartition.getAvailableConnections()).andReturn(1).anyTimes(); expect(mockConnectionHandles.poll()).andReturn(mockConnection).once(); mockConnection.renewConnection(); expectLastCall().once(); replay(mockPartition, mockConnectionHandles, mockConnection); assertEquals(mockConnection, testClass.getAsyncConnection().get()); verify(mockPartition, mockConnectionHandles, mockConnection); }