From 72eef08cd4ba22e7a3fe299e26e31af1eb74d9dd Mon Sep 17 00:00:00 2001 From: dotasek Date: Mon, 6 Dec 2021 13:10:42 -0500 Subject: [PATCH] Fix JAVA_HOME tests with trailing slashes --- .../java/org/hl7/fhir/utilities/UtilitiesTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java index b2264c95f..f941577f6 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java @@ -22,17 +22,20 @@ class UtilitiesTest { public static final String TEST_TXT = "test.txt"; + private static final String getNormalizedJavaHomeDir() { + return System.getenv("JAVA_HOME") == null ? null : Paths.get(System.getenv("JAVA_HOME")).normalize().toString(); + } + public static final String LINUX_TEMP_DIR = "/tmp/"; public static final String LINUX_USER_DIR = System.getProperty("user.home") + "/"; - public static final String LINUX_JAVA_HOME = System.getenv("JAVA_HOME") + "/"; + public static final String LINUX_JAVA_HOME = getNormalizedJavaHomeDir() + "/"; public static final String WIN_TEMP_DIR = "c:\\temp\\"; public static final String WIN_USER_DIR = System.getProperty("user.home") + "\\"; - public static final String WIN_JAVA_HOME = System.getenv("JAVA_HOME") + "\\"; + public static final String WIN_JAVA_HOME = getNormalizedJavaHomeDir() + "\\"; public static final String OSX_USER_DIR = System.getProperty("user.home") + "/"; - public static final String OSX_JAVA_HOME = System.getenv("JAVA_HOME") == null ? null : Paths.get(System.getenv("JAVA_HOME")).normalize().toString() + "/"; - + public static final String OSX_JAVA_HOME = getNormalizedJavaHomeDir() + "/"; @Test @DisplayName("Test Utilities.path maps temp directory correctly") public void testTempDirPath() throws IOException {