test_class.declarator: mockPartition
test_class.modifier: private
test_class.original_string: private ConnectionPartition mockPartition;
test_class.type: ConnectionPartition
test_class.var_name: mockPartition
test_class.declarator: mockPool
test_class.modifier: private
test_class.original_string: private BoneCP mockPool;
test_class.type: BoneCP
test_class.var_name: mockPool
test_class.declarator: testClass
test_class.modifier: static
test_class.original_string: static PoolWatchThread testClass;
test_class.type: PoolWatchThread
test_class.var_name: testClass
test_class.declarator: mockLogger
test_class.modifier: private
test_class.original_string: private Logger mockLogger;
test_class.type: Logger
test_class.var_name: mockLogger
test_class.declarator: first = true
test_class.modifier: static
test_class.original_string: static boolean first = true;
test_class.type: boolean
test_class.var_name: first
test_class.declarator: mockConfig
test_class.modifier: private
test_class.original_string: private BoneCPConfig mockConfig;
test_class.type: BoneCPConfig
test_class.var_name: mockConfig
test_class.declarator: driver
test_class.modifier: private
test_class.original_string: private MockJDBCDriver driver;
test_class.type: MockJDBCDriver
test_class.var_name: driver
test_class.file: bonecp/src/test/java/com/jolbox/bonecp/TestPoolWatchThread.java
test_class.identifier: TestPoolWatchThread
test_case.body: @SuppressWarnings({ "unchecked", "rawtypes" })
  	@Test
  	public void testRunFullConnections() throws InterruptedException{
  //		mockPartition.lockAlmostFullLock();
  //		expectLastCall().once();
  //		mockPartition.unlockAlmostFullLock();
  //		expectLastCall().anyTimes();
  		BlockingQueue<Object> bq = new ArrayBlockingQueue<Object>(1);
  		bq.add(new Object());
  		expect(mockPartition.getPoolWatchThreadSignalQueue()).andReturn(bq);
  		expect(mockPartition.getMaxConnections()).andReturn(5).once();
  		expect(mockPartition.getCreatedConnections()).andReturn(5).once();
  		mockPartition.setUnableToCreateMoreTransactions(true);
  		expectLastCall().once();
  
  		// just to break out of the loop
  		BlockingQueue<?> mockQueue = EasyMock.createNiceMock(BlockingQueue.class);
  		expect(mockPartition.getPoolWatchThreadSignalQueue()).andReturn((BlockingQueue) mockQueue);
  		expect(mockQueue.take()).andThrow(new InterruptedException());
  
  		replay(mockPartition, mockPool, mockLogger, mockQueue);
  		testClass.run();
  		EasyMock.verify(mockPartition);
  
  
  	}
test_case.class_method_signature: TestPoolWatchThread.testRunFullConnections()
test_case.full_signature: @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testRunFullConnections()
test_case.identifier: testRunFullConnections
test_case.invocations: add andReturn expect getPoolWatchThreadSignalQueue once andReturn expect getMaxConnections once andReturn expect getCreatedConnections setUnableToCreateMoreTransactions once expectLastCall createNiceMock andReturn expect getPoolWatchThreadSignalQueue andThrow expect take replay run verify
test_case.modifiers: @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRunFullConnections()
focal_class.declarator: partition
focal_class.modifier: private
focal_class.original_string: private ConnectionPartition partition;
focal_class.type: ConnectionPartition
focal_class.var_name: partition
focal_class.declarator: pool
focal_class.modifier: private
focal_class.original_string: private BoneCP pool;
focal_class.type: BoneCP
focal_class.var_name: pool
focal_class.declarator: signalled
focal_class.modifier: private
focal_class.original_string: private boolean signalled;
focal_class.type: boolean
focal_class.var_name: signalled
focal_class.declarator: acquireRetryDelayInMs = 1000L
focal_class.modifier: private
focal_class.original_string: private long acquireRetryDelayInMs = 1000L;
focal_class.type: long
focal_class.var_name: acquireRetryDelayInMs
focal_class.declarator: lazyInit
focal_class.modifier: protected
focal_class.original_string: protected boolean lazyInit;
focal_class.type: boolean
focal_class.var_name: lazyInit
focal_class.declarator: poolAvailabilityThreshold
focal_class.modifier: private
focal_class.original_string: private int poolAvailabilityThreshold;
focal_class.type: int
focal_class.var_name: poolAvailabilityThreshold
focal_class.declarator: logger = LoggerFactory.getLogger(PoolWatchThread.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(PoolWatchThread.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: bonecp/src/main/java/com/jolbox/bonecp/PoolWatchThread.java
focal_class.identifier: PoolWatchThread
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: PoolWatchThread.PoolWatchThread(ConnectionPartition connectionPartition, BoneCP pool)
focal_class.full_signature: public  PoolWatchThread(ConnectionPartition connectionPartition, BoneCP pool)
focal_class.identifier: PoolWatchThread
focal_class.modifiers: public
focal_class.parameters: (ConnectionPartition connectionPartition, BoneCP pool)
focal_class.signature:  PoolWatchThread(ConnectionPartition connectionPartition, BoneCP pool)
focal_class.class_method_signature: PoolWatchThread.run()
focal_class.full_signature: public void run()
focal_class.identifier: run
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: PoolWatchThread.fillConnections(int connectionsToCreate)
focal_class.full_signature: private void fillConnections(int connectionsToCreate)
focal_class.identifier: fillConnections
focal_class.modifiers: private
focal_class.parameters: (int connectionsToCreate)
focal_class.return: void
focal_class.signature: void fillConnections(int connectionsToCreate)
focal_method.body: public void run() {
  		int maxNewConnections;
  		while (!this.signalled){
  			maxNewConnections=0;
  
  			try{
  				if (this.lazyInit){ // block the first time if this is on.
  					this.partition.getPoolWatchThreadSignalQueue().take();
  				}
   
  
  				maxNewConnections = this.partition.getMaxConnections()-this.partition.getCreatedConnections();
  				// loop for spurious interrupt
  				while (maxNewConnections == 0 || (this.partition.getAvailableConnections() *100/this.partition.getMaxConnections() > this.poolAvailabilityThreshold)){
  					if (maxNewConnections == 0){
  						this.partition.setUnableToCreateMoreTransactions(true);
  					}
  					
  					this.partition.getPoolWatchThreadSignalQueue().take();
  					maxNewConnections = this.partition.getMaxConnections()-this.partition.getCreatedConnections();
  					
  				}
  
  				if (maxNewConnections > 0 
  						&& !this.pool.poolShuttingDown){
  					fillConnections(Math.min(maxNewConnections, this.partition.getAcquireIncrement()));
  					// for the case where we have killed off all our connections due to network/db error
  					if (this.partition.getCreatedConnections() < this.partition.getMinConnections()){
  						fillConnections(this.partition.getMinConnections() - this.partition.getCreatedConnections() );
  							
  					}
  				}
  				
  				if (this.pool.poolShuttingDown){
  					return;
  				}
  
  
  			} catch (InterruptedException e) {
  				logger.debug("Terminating pool watch thread");
  				return; // we've been asked to terminate.
  			}
  		}
  	}
focal_method.class_method_signature: PoolWatchThread.run()
focal_method.full_signature: public void run()
focal_method.identifier: run
focal_method.invocations: take getPoolWatchThreadSignalQueue getMaxConnections getCreatedConnections getAvailableConnections getMaxConnections setUnableToCreateMoreTransactions take getPoolWatchThreadSignalQueue getMaxConnections getCreatedConnections fillConnections min getAcquireIncrement getCreatedConnections getMinConnections fillConnections getMinConnections getCreatedConnections debug
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()