public static <T> T withProperties(Map<String, String> properties, Closure<T> closure) {

        try (RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties()) {
            properties.forEach(System::setProperty);
            WebUtils.reloadSystemProperties();
            return closure.call();
        }
    }
Wrapper that will restore System properties after test methods.
<p>
Based on: <a href="https://github.com/stefanbirkner/system-rules/blob/master/src/main/java/org/junit/contrib/java/lang/system/RestoreSystemProperties.java">...</a>
web/src/test/java/org/apache/shiro/web/RestoreSystemProperties.java