ShutdownHooks { public static void removeHook(Hook hook) { if (runningHooks) { return; } hooks.remove(hook); } private  ShutdownHooks(); static void addHook(Hook hook); static void removeHook(Hook hook); static void runAllHooks();  }
@Test public void testRemoveHook() { boolean[] ran = {false}; ShutdownHooks.Hook hook = () -> ran[0] = true; ShutdownHooks.addHook(hook); ShutdownHooks.removeHook(hook); ShutdownHooks.runAllHooks(); assertFalse(ran[0], "The hook should not have run"); }