Class PreventSystemExit

  • All Implemented Interfaces:
    TestConfigurationIF

    public class PreventSystemExit
    extends Object
    implements TestConfigurationIF
    Configures the test environment to block calls to System.exit(), throwing a PermissionDenied instead.
    • Constructor Detail

      • PreventSystemExit

        public PreventSystemExit()
    • Method Detail

      • setUp

        public void setUp()
        Stores original SecurityManager and set a new one blocking System.exit() Calls reset().
        Specified by:
        setUp in interface TestConfigurationIF
      • reset

        public void reset()
        Resets internal state.
      • getExitCalled

        public boolean getExitCalled()
        Checks whether System.exit() has been called after reset().
        Returns:
        true if and only if System.exit() has been called after reset().
      • getExitValue

        public int getExitValue()
        Looks up the value given to the latest invocation of System.exit()
        Returns:
        The int value. Throws UnknownID if System.exit() has not been called after reset().