DisposableAction implements IDisposable { @Override public void close() { dispose(true); } DisposableAction(final Delegates.IAction action); @Override void close();  }
@Test public void actionIsExecutedOnExplicitDispose() { final AtomicBoolean called = new AtomicBoolean(false); DisposableAction action = new DisposableAction(createAction(called)); assertFalse(called.get()); action.close(); assertTrue("The action was not run when the DisposableAction was closed", called.get()); }