コード例 #1
0
  @Test(expected = IllegalStateException.class)
  public void testCheckNotFinalized2() {
    Runnable task = mock(Runnable.class);

    ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION");
    finalizer.markFinalized();
    finalizer.checkNotFinalized();
  }
コード例 #2
0
  /** 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);
  }
コード例 #3
0
  @Test
  public void testIsFinalized2() {
    Runnable task = mock(Runnable.class);

    ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION");
    assertFalse(finalizer.isFinalized());

    finalizer.markFinalized();

    assertTrue(finalizer.isFinalized());
  }
コード例 #4
0
  @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);
  }