예제 #1
0
  /** Test for clear statement caches. */
  @Test
  public void testClearStatementCaches() {

    testClass.statementCachingEnabled = true;
    mockPreparedStatementCache.clear();
    expectLastCall().once();
    mockCallableStatementCache.clear();
    expectLastCall().once();

    replay(mockPreparedStatementCache, mockCallableStatementCache);
    testClass.clearStatementCaches(true);
    verify(mockPreparedStatementCache, mockCallableStatementCache);
    reset(mockPreparedStatementCache, mockCallableStatementCache);

    mockPool.closeConnectionWatch = true;
    mockPreparedStatementCache.checkForProperClosure();
    expectLastCall().once();
    mockCallableStatementCache.checkForProperClosure();
    expectLastCall().once();

    replay(mockPreparedStatementCache, mockCallableStatementCache);
    testClass.clearStatementCaches(false);
    verify(mockPreparedStatementCache, mockCallableStatementCache);
  }