コード例 #1
0
  /**
   * Mock setup.
   *
   * @throws Exception
   */
  @BeforeClass
  public static void setUp() throws Exception {
    config = CommonTestUtils.getConfigClone();
    mockConnection = createNiceMock(ConnectionHandle.class);
    mockPreparedStatementCache = createNiceMock(IStatementCache.class);
    mockCallableStatementCache = createNiceMock(IStatementCache.class);

    mockLogger = createNiceMock(Logger.class);
    makeThreadSafe(mockLogger, true);
    mockPool = createNiceMock(BoneCP.class);
    mockPool.closeConnectionWatch = true;
    expect(mockPool.getConfig()).andReturn(config).anyTimes();
    config.setTransactionRecoveryEnabled(false);
    config.setStatementsCacheSize(1);
    replay(mockPool);
    testClass =
        new ConnectionHandle(
            mockConnection, mockPreparedStatementCache, mockCallableStatementCache, mockPool);
    testStatementCache = new StatementCache(100);
    Field field = testClass.getClass().getDeclaredField("logger");
    field.setAccessible(true);
    field.set(null, mockLogger);
    config.setReleaseHelperThreads(0);
  }