Package org.fest.swing.security
Class NoExitSecurityManager
java.lang.Object
java.lang.SecurityManager
org.fest.swing.security.NoExitSecurityManager
Understands a
SecurityManager
that does not allow an application under test to terminate the
current JVM. Adapted from Abbot's NoExitSecurityManager
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExitCallHook
private static final ExitCallHook
private final org.fest.util.StackTraces
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newNoExitSecurityManager
.Creates a newNoExitSecurityManager
.NoExitSecurityManager
(ExitCallHook hook, org.fest.util.StackTraces stackTraces) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkExit
(int status) Throws an
if an application tries to terminate the current JVM (throughExitException
orRuntime.exit(int)
.)Runtime.halt(int)
void
checkPermission
(Permission permission) Allows everything.void
checkPermission
(Permission permission, Object context) Allows everything.private boolean
Indicates whether "exit" has been invoked through a call of
orRuntime.exit(int)
.Runtime.halt(int)
private boolean
Methods inherited from class java.lang.SecurityManager
checkAccept, checkAccess, checkAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkLink, checkListen, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkWrite, checkWrite, getClassContext, getSecurityContext, getThreadGroup
-
Field Details
-
NULL_HOOK
-
hook
-
stackTraces
private final org.fest.util.StackTraces stackTraces
-
-
Constructor Details
-
NoExitSecurityManager
public NoExitSecurityManager()Creates a newNoExitSecurityManager
. -
NoExitSecurityManager
Creates a newNoExitSecurityManager
.- Parameters:
hook
- notified when an application tries to terminate the current JVM.- Throws:
NullPointerException
- if the given hook isnull
.
-
NoExitSecurityManager
NoExitSecurityManager(ExitCallHook hook, org.fest.util.StackTraces stackTraces)
-
-
Method Details
-
checkPermission
Allows everything.- Overrides:
checkPermission
in classSecurityManager
- Parameters:
permission
- the specified permission.context
- a system-dependent security context.
-
checkPermission
Allows everything.- Overrides:
checkPermission
in classSecurityManager
- Parameters:
permission
- the specified permission.
-
checkExit
public void checkExit(int status) Throws an
if an application tries to terminate the current JVM (throughExitException
orRuntime.exit(int)
.)Runtime.halt(int)
- Overrides:
checkExit
in classSecurityManager
- Parameters:
status
- the exit status.- Throws:
ExitException
- if an application tries to terminate the current JVM.
-
exitInvoked
private boolean exitInvoked()Indicates whether "exit" has been invoked through a call of
orRuntime.exit(int)
.Runtime.halt(int)
- Returns:
true
if an exit has been invoked through a call ofRuntime.exit
orRuntime.halt
;false
otherwise.
-
exitInvoked
-