Class PreserveSystemPropertyRule
- java.lang.Object
-
- com.atlassian.bamboo.testutils.junit.rule.PreserveSystemPropertyRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class PreserveSystemPropertyRule extends Object implements org.junit.rules.TestRule
Rule which ensures tests that modify system properties doesn't interfere (eg. by concurrently modifying the properties). Additionally it will save modified properties before and restore them after running a test. There are tree ways to mark which tests will modify which properties: - passing list of properties name to the constructor. Then those properties will be preserved for each test in a test class - annotating test method with {@link @com.atlassian.bamboo.testutils.junit.rule.PreserveSystemProperties} - calling PreserveSystemPropertyRule#preserveProperties(SystemProperty... properties)
-
-
Constructor Summary
Constructors Constructor Description PreserveSystemPropertyRule()
PreserveSystemPropertyRule(String... testClassProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
void
preserveProperties(AbstractSystemProperty... properties)
-
-
-
Constructor Detail
-
PreserveSystemPropertyRule
public PreserveSystemPropertyRule()
-
PreserveSystemPropertyRule
public PreserveSystemPropertyRule(String... testClassProperties)
- Parameters:
testClassProperties
- names of System properties to preserve and restore for every test in a test class
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
preserveProperties
public void preserveProperties(AbstractSystemProperty... properties)
-
-