@Test(expected = IllegalStateException.class) public void testCheckNotFinalized2() { Runnable task = mock(Runnable.class); ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION"); finalizer.markFinalized(); finalizer.checkNotFinalized(); }
/** Test of markFinalized method, of class ObjectFinalizer. */ @Test public void testMarkFinalized() { Runnable task = mock(Runnable.class); ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION"); finalizer.markFinalized(); assertFalse(finalizer.doFinalize()); verifyZeroInteractions(task); }
@Test public void testIsFinalized2() { Runnable task = mock(Runnable.class); ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION"); assertFalse(finalizer.isFinalized()); finalizer.markFinalized(); assertTrue(finalizer.isFinalized()); }
@Test public void testFinalizeAfterMarkFinalized() { Runnable task = mock(Runnable.class); ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION"); finalizer.markFinalized(); try (LogCollector logs = LogCollectorTest.startCollecting()) { finalizeObject(finalizer); assertEquals(0, logs.getNumberOfLogs()); } verifyZeroInteractions(task); }