/** * Mock setup. * * @throws ClassNotFoundException */ @BeforeClass public static void setup() throws ClassNotFoundException { mockPool = createNiceMock(BoneCP.class); mockConnectionPartition = createNiceMock(ConnectionPartition.class); mockExecutor = createNiceMock(ScheduledExecutorService.class); mockConnection = createNiceMock(ConnectionHandle.class); mockLogger = createNiceMock(Logger.class); makeThreadSafe(mockLogger, true); config = new BoneCPConfig(); config.setIdleMaxAge(100); config.setIdleConnectionTestPeriod(100); }
/** * 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); }