Class SystemPropertiesInvariantRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class SystemPropertiesInvariantRule
    extends java.lang.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:
    SystemPropertiesRestoreRule, ClassRule, Rule
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashSet<java.lang.String> ignoredProperties
      Ignored property keys.
    • Method Summary

      All 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ignoredProperties

        private final java.util.HashSet<java.lang.String> ignoredProperties
        Ignored property keys.
    • Constructor Detail

      • SystemPropertiesInvariantRule

        public SystemPropertiesInvariantRule()
        Cares about all properties.
      • SystemPropertiesInvariantRule

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

        public SystemPropertiesInvariantRule​(java.util.Set<java.lang.String> ignoredProperties)
        Don't care about the given set of properties.
    • 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 interface org.junit.rules.TestRule