Beispiel #1
0
  @Test
  public void testFinalizeBeforeDoFinalizeInheritMessage() {
    Runnable task = mock(Runnable.class);
    stub(task.toString()).toReturn("DESCRIPTION");

    ObjectFinalizer finalizer = new ObjectFinalizer(task);
    try (LogCollector logs = LogCollectorTest.startCollecting()) {
      finalizeObject(finalizer);
      assertEquals(1, logs.getNumberOfLogs());
    }

    verify(task).run();
    verifyNoMoreInteractions(task);
  }
 @Override
 public Object answer(InvocationOnMock invocation) throws Throwable {
   Runnable runnable = (Runnable) invocation.getArguments()[0];
   runnable.run();
   return null;
 }