Class EnvironmentVariableUtils
java.lang.Object
org.junitpioneer.jupiter.EnvironmentVariableUtils
This class modifies the internals of the environment variables map with reflection.
Warning: If your
SecurityManager does not allow modifications, it fails.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear an environment variable.getFieldValue(Class<?> clazz, Object object, String name) private static voidmodifyEnvironmentVariables(Consumer<Map<String, String>> consumer) static voidSet a value of an environment variable.private static voidsetInProcessEnvironmentClass(Consumer<Map<String, String>> consumer) private static voidsetInSystemEnvClass(Consumer<Map<String, String>> consumer) private static voidtrySystemEnvClass(Consumer<Map<String, String>> consumer, ReflectiveOperationException processEnvironmentClassEx)
-
Constructor Details
-
EnvironmentVariableUtils
private EnvironmentVariableUtils()
-
-
Method Details
-
set
-
clear
Clear an environment variable.- Parameters:
name- of the environment variable
-
modifyEnvironmentVariables
-
trySystemEnvClass
private static void trySystemEnvClass(Consumer<Map<String, String>> consumer, ReflectiveOperationException processEnvironmentClassEx) -
setInProcessEnvironmentClass
private static void setInProcessEnvironmentClass(Consumer<Map<String, String>> consumer) throws ReflectiveOperationException- Throws:
ReflectiveOperationException
-
setInSystemEnvClass
private static void setInSystemEnvClass(Consumer<Map<String, String>> consumer) throws ReflectiveOperationException- Throws:
ReflectiveOperationException
-
getFieldValue
private static Map<String,String> getFieldValue(Class<?> clazz, Object object, String name) throws ReflectiveOperationException - Throws:
ReflectiveOperationException
-