Ejemplo n.º 1
0
  @Test(expected = IllegalStateException.class)
  public void testCheckNotFinalized2() {
    Runnable task = mock(Runnable.class);

    ObjectFinalizer finalizer = new ObjectFinalizer(task, "DESCRIPTION");
    finalizer.markFinalized();
    finalizer.checkNotFinalized();
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 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());
  }
Ejemplo n.º 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);
  }