Class TestSecurityManager


  • public final class TestSecurityManager
    extends SecurityManager
    A SecurityManager that prevents tests calling System.exit(int). Only the test runner itself is allowed to exit the JVM. All other security checks are handled by the default security policy.

    Use this with -Djava.security.manager=org.apache.lucene.util.TestSecurityManager.

    • Constructor Detail

      • TestSecurityManager

        public TestSecurityManager()
        Creates a new TestSecurityManager. This ctor is called on JVM startup, when -Djava.security.manager=org.apache.lucene.util.TestSecurityManager is passed to JVM.
    • Method Detail

      • checkExit

        public void checkExit​(int status)

        This method inspects the stack trace and checks who is calling System.exit(int) and similar methods

        Overrides:
        checkExit in class SecurityManager
        Throws:
        SecurityException - if the caller of this method is not the test runner itself.