package jmri.util; import jmri.managers.DefaultShutDownManager; /** * Mock ShutDownManager for unit testing. *

* To clear the state of shutting down, call * {@link #resetShuttingDown()}. *

* This overrides the DefaultShutDownManager with two changes to that manager's behavior: *

* * @author Randall Wood Copyright 2019 */ public class MockShutDownManager extends DefaultShutDownManager { public MockShutDownManager() { super(); Runtime.getRuntime().removeShutdownHook(shutdownHook); } /** * {@inheritDoc} * * This implementation runs all shutdown tasks, but does not actually call * System.exit(). */ @Override public void restart() { shutdown(100, false); } /** * {@inheritDoc} * * This implementation runs all shutdown tasks, but does not actually call * System.exit(). */ @Override public void shutdown() { shutdown(0, false); } public void resetShuttingDown() { setShuttingDown(false); } }