* @throws SQLException
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testStatementCacheClear() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, SQLException {
ConcurrentMap mockCache = createNiceMock(ConcurrentMap.class);
List<StatementHandle> mockStatementCollections = createNiceMock(List.class);
StatementCache testClass = new StatementCache(1, false, null);
Field field = testClass.getClass().getDeclaredField("cache");
field.setAccessible(true);
field.set(testClass, mockCache);
Iterator<StatementHandle> mockIterator = createNiceMock(Iterator.class);
StatementHandle mockStatement = createNiceMock(StatementHandle.class);
expect(mockCache.values()).andReturn(mockStatementCollections).anyTimes();
expect(mockStatementCollections.iterator()).andReturn(mockIterator).anyTimes();
expect(mockIterator.hasNext()).andReturn(true).times(2).andReturn(false).once();
expect(mockIterator.next()).andReturn(mockStatement).anyTimes();
mockStatement.close();
expectLastCall().once().andThrow(new SQLException()).once();
mockCache.clear();
expectLastCall().once();
replay(mockCache, mockStatementCollections, mockIterator,mockStatement);
testClass.clear();
verify(mockCache, mockStatement);