public class NoExitSecurityManager extends SecurityManager
SecurityManager
that does not allow an application under test to terminate the current JVM. Adapted from
Abbot's NoExitSecurityManager
.inCheck
Constructor and Description |
---|
NoExitSecurityManager()
Creates a new
NoExitSecurityManager . |
NoExitSecurityManager(ExitCallHook hook)
Creates a new
NoExitSecurityManager . |
Modifier and Type | Method and Description |
---|---|
void |
checkExit(int status)
Throws an
ExitException if an application tries to terminate the current JVM (through
Runtime.exit(int) or Runtime.halt(int) ). |
void |
checkPermission(Permission permission)
Allows everything.
|
void |
checkPermission(Permission permission,
Object context)
Allows everything.
|
checkAccept, checkAccess, checkAccess, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader
public NoExitSecurityManager()
NoExitSecurityManager
.public NoExitSecurityManager(ExitCallHook hook)
NoExitSecurityManager
.hook
- notified when an application tries to terminate the current JVM.NullPointerException
- if the given hook is null
.public void checkPermission(Permission permission, Object context)
checkPermission
in class SecurityManager
permission
- the specified permission.context
- a system-dependent security context.public void checkPermission(Permission permission)
checkPermission
in class SecurityManager
permission
- the specified permission.public void checkExit(int status)
ExitException
if an application tries to terminate the current JVM (through
Runtime.exit(int)
or Runtime.halt(int)
).checkExit
in class SecurityManager
status
- the exit status.ExitException
- if an application tries to terminate the current JVM.Copyright © 2014–2017 AssertJ. All rights reserved.