Class PreventSystemExit
- java.lang.Object
-
- dk.netarkivet.testutils.preconfigured.PreventSystemExit
-
- All Implemented Interfaces:
TestConfigurationIF
public class PreventSystemExit extends java.lang.Object implements TestConfigurationIF
Configures the test environment to block calls to System.exit(), throwing a PermissionDenied instead.
-
-
Constructor Summary
Constructors Constructor Description PreventSystemExit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getExitCalled()
Checks whether System.exit() has been called after reset().int
getExitValue()
Looks up the value given to the latest invocation of System.exit()void
reset()
Resets internal state.void
setUp()
Stores original SecurityManager and set a new one blocking System.exit() Calls reset().void
tearDown()
Restores original SecurityManager.
-
-
-
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 interfaceTestConfigurationIF
-
reset
public void reset()
Resets internal state.
-
tearDown
public void tearDown()
Restores original SecurityManager.- Specified by:
tearDown
in interfaceTestConfigurationIF
-
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().
-
-