Thought I'd do it properly and provide a test and patch... mocking static calls
on java.lang classes is a pig! If you can be bothered to make the unit test
work, you need jmockit (https://jmockit.dev.java.net/) and you must run your
test with the following VM arguments:
-javaagent:<full_path_to>/jmockit.jar
-Xbootclasspath/a:"<full_path_to_EnvVars_class>:<full_path_to_EnvVarsTest_class>:<full_path_to>/junit.jar:<full_path_to>/jmockit.jar"
Just to make it more fun, the path and classpath separators have to be system
correct. On my machine it looks like this:
-javaagent:c:\jmockit.jar -Xbootclasspath/a:"c:\Eclipse
Workspaces\hudson\hudson-core\target\classes;c:\Eclipse
Workspaces\hudson\hudson-core\target\test-classes;c:\Program
Files\eclipse\plugins\org.junit_3.8.2.v200711021030\junit.jar;c:\jmockit.jar"
Starting 1.162, EnvVars.masterEnvVars handles case insensitive look up
correctly, so this should no longer be an issue. I'm assuming that you've been
using an older version of Hudson.
That said, technically speaking it's possible that PATH/Path is not set at all,
regardless of upper/lower convention, so I added null check too. This change
will be in 1.165.