public class ProvideSecurityManager
extends org.junit.rules.ExternalResource
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()); } }
Modifier and Type | Field and Description |
---|---|
private java.lang.SecurityManager |
manager |
private java.lang.SecurityManager |
originalManager |
Constructor and Description |
---|
ProvideSecurityManager(java.lang.SecurityManager manager) |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |