Class SystemPropertiesInvariantRule

java.lang.Object
com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class SystemPropertiesInvariantRule extends Object implements org.junit.rules.TestRule
A TestRule that ensures system properties remain unmodified by the nested Statement. This can be applied both at suite level and at test level. This rule requires appropriate security permission to read and write system properties (System.getProperties()) if running under a security manager.
See Also:
  • Field Details

    • ignoredProperties

      private final HashSet<String> ignoredProperties
      Ignored property keys.
  • Constructor Details

    • SystemPropertiesInvariantRule

      public SystemPropertiesInvariantRule()
      Cares about all properties.
    • SystemPropertiesInvariantRule

      public SystemPropertiesInvariantRule(String... ignoredProperties)
      Don't care about the given set of properties.
    • SystemPropertiesInvariantRule

      public SystemPropertiesInvariantRule(Set<String> ignoredProperties)
      Don't care about the given set of properties.
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement s, org.junit.runner.Description d)
      Specified by:
      apply in interface org.junit.rules.TestRule