Merge pull request #135 from hapifhir/update_path_tests

updating unit tests so they pass on my mac. Also updating test to Junit5
This commit is contained in:
Grahame Grieve 2020-02-17 13:34:37 +11:00 committed by GitHub
commit 1c61ea25d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 12 deletions

View File

@ -107,6 +107,14 @@
<version>${validator_test_case_version}</version>
<scope>test</scope>
</dependency>
<!-- JUNIT JUPITER (JUNIT5) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>

View File

@ -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"));

View File

@ -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());

View File

@ -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");
}
}

View File

@ -113,8 +113,6 @@
<artifactId>txtmark</artifactId>
<version>0.13</version>
</dependency>
</dependencies>
</dependencyManagement>