org.junit.contrib.java.lang.system
Class ProvideSecurityManager

java.lang.Object
  extended by org.junit.rules.ExternalResource
      extended by org.junit.contrib.java.lang.system.ProvideSecurityManager
All Implemented Interfaces:
org.junit.rules.TestRule

public class ProvideSecurityManager
extends org.junit.rules.ExternalResource

The ProvideSecurityManager rule provides an arbitrary security manager to a test. After the test the original security manager is restored.

   public void MyTest {
     private final MySecurityManager securityManager
       = new MySecurityManager();

     @Rule
     public final ProvideSecurityManager provideSecurityManager
       = new ProvideSecurityManager(securityManager);

     @Test
     public void overrideProperty() {
       assertEquals(securityManager, System.getSecurityManager());
     }
   }
 


Constructor Summary
ProvideSecurityManager(SecurityManager manager)
           
 
Method Summary
protected  void after()
           
protected  void before()
           
 
Methods inherited from class org.junit.rules.ExternalResource
apply
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProvideSecurityManager

public ProvideSecurityManager(SecurityManager manager)
Method Detail

before

protected void before()
               throws Throwable
Overrides:
before in class org.junit.rules.ExternalResource
Throws:
Throwable

after

protected void after()
Overrides:
after in class org.junit.rules.ExternalResource


Copyright © 2011–2018. All rights reserved.