Skip to content

Commit 1177ba5

Browse files
committed
ARTEMIS-6116 Use USERPROFILE on windows
1 parent 5968aa8 commit 1177ba5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,26 @@
3030
public class XmlUtilTest extends ArtemisTestCase {
3131

3232
@Test
33-
public void testPropertySubstituion(@TempDir Path tempDir) throws Exception {
33+
public void testPropertySubstitution(@TempDir Path tempDir) throws Exception {
3434
final String SYSTEM_PROP_NAME = getTestMethodName() + "SysPropName";
3535
final String SYSTEM_PROP_VALUE = getTestMethodName() + "SysPropValue";
3636
System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE);
3737

3838
// since System.getenv() returns an immutable Map we rely here on an environment variable that is likely to exist
39-
final String ENV_VAR_NAME = "HOME";
39+
String ENV_VAR_NAME = "HOME";
40+
41+
// override to USERPROFILE if OS is windows
42+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
43+
ENV_VAR_NAME = "USERPROFILE";
44+
}
4045

4146
BrokerDTO brokerDTO = getBrokerDTO(tempDir, SYSTEM_PROP_NAME, ENV_VAR_NAME);
4247
assertEquals(SYSTEM_PROP_VALUE, ((JaasSecurityDTO)brokerDTO.security).domain);
4348
assertEquals(System.getenv(ENV_VAR_NAME), brokerDTO.server.configuration);
4449
}
4550

4651
@Test
47-
public void testPropertySubstituionPrecedence(@TempDir Path tempDir) throws Exception {
52+
public void testPropertySubstitutionPrecedence(@TempDir Path tempDir) throws Exception {
4853
final String SYSTEM_PROP_NAME = "HOME";
4954
final String SYSTEM_PROP_VALUE = getTestMethodName() + "SysPropValue";
5055
System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE);

0 commit comments

Comments
 (0)