From 3c614058f79cd3442f042fcae25ed02a5fa37ac8 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Fri, 14 Feb 2020 14:03:59 -0500 Subject: [PATCH] updating unit tests so they pass on my mac. Also updating test to Junit5 --- org.hl7.fhir.r5/pom.xml | 8 +++++ .../fhir/r5/model/BaseDateTimeTypeTest.java | 4 ++- .../org/hl7/fhir/r5/test/FHIRPathTests.java | 3 ++ .../org/hl7/fhir/r5/test/UtilitiesTests.java | 33 ++++++++++++++----- pom.xml | 2 -- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 667c503f7..becfa98cd 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -107,6 +107,14 @@ ${validator_test_case_version} test + + + + org.junit.jupiter + junit-jupiter-engine + 5.6.0 + test + com.atlassian.commonmark commonmark diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BaseDateTimeTypeTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BaseDateTimeTypeTest.java index ffd2d9b3d..242551809 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BaseDateTimeTypeTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BaseDateTimeTypeTest.java @@ -36,7 +36,9 @@ public class BaseDateTimeTypeTest { @Test public void equalsUsingFhirPathRulesOther() { - + // Setting timezone for this test. Grahame is in UTC+11, Travis is in GMT, and I'm here in Toronto, Canada with + // all my time based tests failing locally... + TimeZone.setDefault(TimeZone.getTimeZone("UTC+1100")); // Exact same - Same timezone assertTrue( compareDateTimes("2001-01-02T11:22:33.444Z", "2001-01-02T11:22:33.444Z")); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java index cd8096b84..63885a005 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java @@ -147,6 +147,9 @@ public class FHIRPathTests { @SuppressWarnings("deprecation") @Test public void test() throws FileNotFoundException, IOException, FHIRException, org.hl7.fhir.exceptions.FHIRException, UcumException { + // Setting timezone for this test. Grahame is in UTC+11, Travis is in GMT, and I'm here in Toronto, Canada with + // all my time based tests failing locally... + TimeZone.setDefault(TimeZone.getTimeZone("UTC+1100")); if (fp == null) fp = new FHIRPathEngine(TestingUtilities.context()); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/UtilitiesTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/UtilitiesTests.java index b245d4afc..628a0f62f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/UtilitiesTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/UtilitiesTests.java @@ -1,19 +1,34 @@ package org.hl7.fhir.r5.test; import java.io.IOException; + import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.utilities.Utilities; -import org.junit.Test; -import junit.framework.Assert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +@DisplayName("Path Tests") public class UtilitiesTests { - @Test - public void testPath() throws IOException { - Assert.assertEquals(Utilities.path("[tmp]", "test.txt"), SystemUtils.IS_OS_WINDOWS ? "c:\\temp\\test.txt" : "/temp/test.txt"); - Assert.assertEquals(Utilities.path("[user]", "test.txt"), System.getProperty("user.home")+"\\test.txt"); - Assert.assertEquals(Utilities.path("[JAVA_HOME]", "test.txt"), System.getenv("JAVA_HOME")+"\\test.txt"); - } -} + @Test + @DisplayName("Tests java temp directory is created correctly") + public void testTempDir() throws IOException { + Assertions.assertEquals(Utilities.path("[tmp]", "test.txt"), SystemUtils.IS_OS_WINDOWS ? "c:\\temp\\test.txt" : System.getProperty("java.io.tmpdir") + "test.txt"); + } + + @Test + @DisplayName("Tests user system property is correct") + public void testUserDir() throws IOException { + Assertions.assertEquals(Utilities.path("[user]", "test.txt"), SystemUtils.IS_OS_WINDOWS ? System.getProperty("user.home") + "\\test.txt" : System.getProperty("user.home") + "/test.txt"); + } + + @Test + @DisplayName("Tests JAVA_HOME is initialized correctly") + public void testJavaHome() throws IOException { + Assertions.assertEquals(Utilities.path("[JAVA_HOME]", "test.txt"), SystemUtils.IS_OS_WINDOWS ? System.getenv("JAVA_HOME") + "\\test.txt" : System.getenv("JAVA_HOME") + "/test.txt"); + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index cf55740ef..0e98ae929 100644 --- a/pom.xml +++ b/pom.xml @@ -113,8 +113,6 @@ txtmark 0.13 - -