ShutdownHookCallbacks { public void callback() { getCallbacks().forEach(callback -> execute(callback::callback)); } ShutdownHookCallbacks(); ShutdownHookCallbacks addCallback(ShutdownHookCallback callback); Collection<ShutdownHookCallback> getCallbacks(); void clear(); void callback(); static final ShutdownHookCallbacks INSTANCE; }
@Test public void testCallback() { callbacks.callback(); DefaultShutdownHookCallback callback = (DefaultShutdownHookCallback) callbacks.getCallbacks().iterator().next(); assertTrue(callback.isExecuted()); }