test_class.declarator: mockCache
test_class.modifier: private
test_class.original_string: private IStatementCache mockCache;
test_class.type: IStatementCache
test_class.var_name: mockCache
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: config
test_class.modifier: private
test_class.original_string: private BoneCPConfig config;
test_class.type: BoneCPConfig
test_class.var_name: config
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/TestStatementCache.java
test_class.identifier: TestStatementCache
test_case.body: @Test
  	public void testPreparedStatement() throws SQLException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
  		BoneCP dsb = null ;
  		CommonTestUtils.logTestInfo("Tests that prepared statements are obtained from cache when set.");
  		config.setMinConnectionsPerPartition(10);
  		config.setMaxConnectionsPerPartition(20);
  		config.setAcquireIncrement(5);
  		config.setPartitionCount(1);
  		config.setStatementsCacheSize(1);
  		config.setLogStatementsEnabled(true);
  		config.setStatementReleaseHelperThreads(0);
  		dsb = new BoneCP(config);
  
  		ConnectionHandle con = (ConnectionHandle) dsb.getConnection();
  		Field preparedStatement = con.getClass().getDeclaredField("preparedStatementCache");
  		preparedStatement.setAccessible(true);
  		// switch to our mock
  		preparedStatement.set(con, mockCache);
  		expect(mockCache.get(isA(String.class))).andReturn(null);
  //		mockCache.put(isA(String.class), isA(PreparedStatement.class));
  
  		replay(mockCache);
  		Statement statement = con.prepareStatement(CommonTestUtils.TEST_QUERY);
  		statement.close();
  		verify(mockCache);
  
  		reset(mockCache);
  		expect(mockCache.get(isA(String.class))).andReturn(null);
  		replay(mockCache);
  
  		con.prepareStatement(CommonTestUtils.TEST_QUERY);
  		statement.close();
  		verify(mockCache);
  		dsb.shutdown();
  		statement.close();
  		con.close();
  		dsb.close();
  		CommonTestUtils.logPass();
  	}
test_case.class_method_signature: TestStatementCache.testPreparedStatement()
test_case.full_signature: @Test public void testPreparedStatement()
test_case.identifier: testPreparedStatement
test_case.invocations: logTestInfo setMinConnectionsPerPartition setMaxConnectionsPerPartition setAcquireIncrement setPartitionCount setStatementsCacheSize setLogStatementsEnabled setStatementReleaseHelperThreads getConnection getDeclaredField getClass setAccessible set andReturn expect get isA replay prepareStatement close verify reset andReturn expect get isA replay prepareStatement close verify shutdown close close close logPass
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPreparedStatement()
focal_class.declarator: logger = LoggerFactory.getLogger(StatementCache.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(StatementCache.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: cache
focal_class.modifier: private
focal_class.original_string: private ConcurrentMap<String, StatementHandle> cache;
focal_class.type: ConcurrentMap<String, StatementHandle>
focal_class.var_name: cache
focal_class.declarator: cacheSize
focal_class.modifier: private
focal_class.original_string: private int cacheSize;
focal_class.type: int
focal_class.var_name: cacheSize
focal_class.declarator: maintainStats
focal_class.modifier: private final
focal_class.original_string: private final boolean maintainStats;
focal_class.type: boolean
focal_class.var_name: maintainStats
focal_class.declarator: statistics
focal_class.modifier: private final
focal_class.original_string: private final Statistics statistics;
focal_class.type: Statistics
focal_class.var_name: statistics
focal_class.file: bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java
focal_class.identifier: StatementCache
focal_class.interfaces: implements IStatementCache
focal_class.class_method_signature: StatementCache.StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.full_signature: public  StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.identifier: StatementCache
focal_class.modifiers: public
focal_class.parameters: (int size, boolean maintainStats, Statistics statistics)
focal_class.signature:  StatementCache(int size, boolean maintainStats, Statistics statistics)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.full_signature: public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.full_signature: public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.full_signature: private StringBuilder calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.identifier: calculateCacheKeyInternal
focal_class.modifiers: private
focal_class.parameters: (String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.return: StringBuilder
focal_class.signature: StringBuilder calculateCacheKeyInternal(String sql,
  			int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.full_signature: public String calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int autoGeneratedKeys)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int autoGeneratedKeys)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, int[] columnIndexes)
focal_class.full_signature: public String calculateCacheKey(String sql, int[] columnIndexes)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, int[] columnIndexes)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, int[] columnIndexes)
focal_class.class_method_signature: StatementCache.calculateCacheKey(String sql, String[] columnNames)
focal_class.full_signature: public String calculateCacheKey(String sql, String[] columnNames)
focal_class.identifier: calculateCacheKey
focal_class.modifiers: public
focal_class.parameters: (String sql, String[] columnNames)
focal_class.return: String
focal_class.signature: String calculateCacheKey(String sql, String[] columnNames)
focal_class.class_method_signature: StatementCache.get(String key)
focal_class.full_signature: public StatementHandle get(String key)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String key)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String key)
focal_class.class_method_signature: StatementCache.get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.full_signature: public StatementHandle get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
focal_class.class_method_signature: StatementCache.get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.full_signature: public StatementHandle get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int resultSetType, int resultSetConcurrency)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int resultSetType, int resultSetConcurrency)
focal_class.class_method_signature: StatementCache.get(String sql, int autoGeneratedKeys)
focal_class.full_signature: public StatementHandle get(String sql, int autoGeneratedKeys)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int autoGeneratedKeys)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int autoGeneratedKeys)
focal_class.class_method_signature: StatementCache.get(String sql, int[] columnIndexes)
focal_class.full_signature: public StatementHandle get(String sql, int[] columnIndexes)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, int[] columnIndexes)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, int[] columnIndexes)
focal_class.class_method_signature: StatementCache.get(String sql, String[] columnNames)
focal_class.full_signature: public StatementHandle get(String sql, String[] columnNames)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (String sql, String[] columnNames)
focal_class.return: StatementHandle
focal_class.signature: StatementHandle get(String sql, String[] columnNames)
focal_class.class_method_signature: StatementCache.size()
focal_class.full_signature: public int size()
focal_class.identifier: size
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: StatementCache.clear()
focal_class.full_signature: public void clear()
focal_class.identifier: clear
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: StatementCache.checkForProperClosure()
focal_class.full_signature: public void checkForProperClosure()
focal_class.identifier: checkForProperClosure
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void checkForProperClosure()
focal_class.class_method_signature: StatementCache.putIfAbsent(String key, StatementHandle handle)
focal_class.full_signature: public void putIfAbsent(String key, StatementHandle handle)
focal_class.identifier: putIfAbsent
focal_class.modifiers: public
focal_class.parameters: (String key, StatementHandle handle)
focal_class.return: void
focal_class.signature: void putIfAbsent(String key, StatementHandle handle)
focal_method.body: public StatementHandle get(String key){
  		StatementHandle statement = this.cache.get(key);
  		
  		if (statement != null && !statement.logicallyClosed.compareAndSet(true, false)){
  			statement = null;
  		}
  		
  		if (this.maintainStats){
  			if (statement != null){
  				this.statistics.incrementCacheHits();
  			} else {
  				this.statistics.incrementCacheMiss();
  			}
  		}
  		return statement;
  	}
focal_method.class_method_signature: StatementCache.get(String key)
focal_method.full_signature: public StatementHandle get(String key)
focal_method.identifier: get
focal_method.invocations: get compareAndSet incrementCacheHits incrementCacheMiss
focal_method.modifiers: public
focal_method.parameters: (String key)
focal_method.return: StatementHandle
focal_method.signature: StatementHandle get(String key)