diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 7e7935800..c2f9701ce 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -80,6 +80,13 @@ ${junit_jupiter_version} test + + + org.hl7.fhir.testcases + fhir-test-cases + ${validator_test_case_version} + test + diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java index e37599dd1..9ea29ecf8 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java @@ -1,25 +1,33 @@ package org.hl7.fhir.utilities.tests; +import org.apache.commons.io.IOUtils; +import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.Utilities; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.commons.io.IOUtils; -import org.hl7.fhir.utilities.TextFile; -import org.hl7.fhir.utilities.Utilities; - public class BaseTestingUtilities { static public boolean silent; public static String loadTestResource(String... paths) throws IOException { + /** + * This 'if' condition checks to see if the fhir-test-cases project (https://github.com/FHIR/fhir-test-cases) is + * installed locally at the same directory level as the core library project is. If so, the test case data is read + * directly from that project, instead of the imported maven dependency jar. It is important, that if you want to + * test against the dependency imported from sonatype nexus, instead of your local copy, you need to either change + * the name of the project directory to something other than 'fhir-test-cases', or move it to another location, not + * at the same directory level as the core project. + */ if (new File("../../fhir-test-cases").exists() && isTryToLoadFromFileSystem()) { String n = Utilities.path(System.getProperty("user.dir"), "..", "..", "fhir-test-cases", Utilities.path(paths)); // ok, we'll resolve this locally return TextFile.fileToString(new File(n)); } else { - // resolve from the package + // resolve from the package String contents; String classpath = ("/org/hl7/fhir/testcases/" + Utilities.pathURL(paths)); try (InputStream inputStream = BaseTestingUtilities.class.getResourceAsStream(classpath)) { @@ -81,4 +89,4 @@ public class BaseTestingUtilities { } -} +} \ No newline at end of file