### Question:
VariableExpansion { private static final String resolve(String var, Resolver resolver, Stack<String> stack) { if (stack.contains(var)) { throw new IllegalArgumentException(String.format("Recursively defined variable '%s', stack=%s", var, stack)); } String result = resolver.resolve(var); if (result == null) { throw new UnresolvedVariableException("Unable to resolve variable: " + var); } stack.push(var); try { return expand0(result, resolver, stack); } finally { stack.pop(); } } private  VariableExpansion(); static final String expand(String input, Resolver resolver); static final Resolver ENV_VAR_RESOLVER; static final Resolver SYS_PROP_RESOLVER; }### Answer:
@Test public void testResolveWithSysPropResolver() { Resolver sysPropResolver = VariableExpansion.SYS_PROP_RESOLVER; assertNull("System property value unexpectedly set already", System.getProperty(testPropName)); assertNull("Expected resolve to return null as property not set", sysPropResolver.resolve(testPropName)); setTestSystemProperty(testPropName, testPropValue); assertEquals("System property value not as expected", testPropValue, System.getProperty(testPropName)); assertEquals("Resolved variable not as expected", testPropValue, sysPropResolver.resolve(testPropName)); }
@Test public void testResolveWithEnvVarResolver() { assumeTrue("Environment variable not set as required", System.getenv().containsKey(TEST_ENV_VARIABLE_NAME)); assumeFalse("Environment variable unexpectedly set", System.getenv().containsKey(TEST_ENV_VARIABLE_NAME_NOT_SET)); assertEquals("Environment variable value not as expected", TEST_ENV_VARIABLE_VALUE, System.getenv(TEST_ENV_VARIABLE_NAME)); final Resolver envVarResolver = VariableExpansion.ENV_VAR_RESOLVER; assertNull("Expected resolve to return null as property not set", envVarResolver.resolve(TEST_ENV_VARIABLE_NAME_NOT_SET)); assertEquals("Resolved variable not as expected", TEST_ENV_VARIABLE_VALUE, envVarResolver.resolve(TEST_ENV_VARIABLE_NAME)); }