Class SystemPropertiesRestoreRule
- java.lang.Object
-
- com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class SystemPropertiesRestoreRule extends java.lang.Object implements org.junit.rules.TestRule
ATestRule
which restores system properties from before the nestedStatement
. This rule requires appropriate security permission to read and write system properties (System.getProperties()
) if running under a security manager.- See Also:
SystemPropertiesInvariantRule
,ClassRule
,Rule
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashSet<java.lang.String>
ignoredProperties
Ignored property keys.
-
Constructor Summary
Constructors Constructor Description SystemPropertiesRestoreRule()
Restores all properties.SystemPropertiesRestoreRule(java.lang.String... ignoredProperties)
SystemPropertiesRestoreRule(java.util.Set<java.lang.String> ignoredProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement s, org.junit.runner.Description d)
private static java.util.TreeMap<java.lang.String,java.lang.String>
cloneAsMap(java.util.Properties properties)
(package private) static void
restore(java.util.TreeMap<java.lang.String,java.lang.String> before, java.util.TreeMap<java.lang.String,java.lang.String> after, java.util.Set<java.lang.String> ignoredKeys)
(package private) static java.util.TreeMap<java.lang.String,java.lang.String>
systemPropertiesAsMap()
-
-
-
Constructor Detail
-
SystemPropertiesRestoreRule
public SystemPropertiesRestoreRule()
Restores all properties.
-
SystemPropertiesRestoreRule
public SystemPropertiesRestoreRule(java.util.Set<java.lang.String> ignoredProperties)
- Parameters:
ignoredProperties
- Properties that will be ignored (and will not be restored).
-
SystemPropertiesRestoreRule
public SystemPropertiesRestoreRule(java.lang.String... ignoredProperties)
- Parameters:
ignoredProperties
- Properties that will be ignored (and will not be restored).
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement s, org.junit.runner.Description d)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
cloneAsMap
private static java.util.TreeMap<java.lang.String,java.lang.String> cloneAsMap(java.util.Properties properties)
-
restore
static void restore(java.util.TreeMap<java.lang.String,java.lang.String> before, java.util.TreeMap<java.lang.String,java.lang.String> after, java.util.Set<java.lang.String> ignoredKeys)
-
systemPropertiesAsMap
static java.util.TreeMap<java.lang.String,java.lang.String> systemPropertiesAsMap()
-
-