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:
*
* - This does not register a shutdown hook with the Runtime to catch SIGTERM, Ctrl-C, and the like.
* - This does not call System.exit() when {@link #shutdown()} or {@link #restart()} are called.
*
*
* @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);
}
}