/** * Tests various getter/setters. * * @throws IllegalArgumentException * @throws IllegalAccessException * @throws SecurityException * @throws NoSuchFieldException */ @SuppressWarnings("deprecation") @Test public void testSettersGetters() throws IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException { ConnectionPartition mockPartition = createNiceMock(ConnectionPartition.class); testClass.setOriginatingPartition(mockPartition); assertEquals(mockPartition, testClass.getOriginatingPartition()); testClass.setConnectionLastReset(123); assertEquals(testClass.getConnectionLastReset(), 123); testClass.setConnectionLastUsed(456); assertEquals(testClass.getConnectionLastUsed(), 456); Field field = testClass.getClass().getDeclaredField("possiblyBroken"); field.setAccessible(true); field.setBoolean(testClass, true); assertTrue(testClass.isPossiblyBroken()); Object debugHandle = new Object(); testClass.setDebugHandle(debugHandle); assertEquals(debugHandle, testClass.getDebugHandle()); testClass.setInternalConnection(mockConnection); assertEquals(mockConnection, testClass.getInternalConnection()); assertEquals(mockConnection, testClass.getRawConnection()); field = testClass.getClass().getDeclaredField("logicallyClosed"); field.setAccessible(true); field.setBoolean(testClass, true); assertTrue(testClass.isClosed()); testClass.setLogStatementsEnabled(true); assertTrue(testClass.isLogStatementsEnabled()); assertEquals(testClass.getPool(), mockPool); ArrayList<ReplayLog> testLog = new ArrayList<ReplayLog>(); testClass.setReplayLog(testLog); assertEquals(testClass.getReplayLog(), testLog); testClass.setInReplayMode(true); assertTrue(testClass.isInReplayMode()); testClass.setInReplayMode(false); testClass.threadUsingConnection = Thread.currentThread(); assertEquals(Thread.currentThread(), testClass.getThreadUsingConnection()); }