Adding back in local file read
This commit is contained in:
parent
8a7737cac0
commit
8aee1e2e6b
|
@ -14,10 +14,22 @@ public class BaseTestingUtilities {
|
||||||
static public boolean silent;
|
static public boolean silent;
|
||||||
|
|
||||||
public static String loadTestResource(String... paths) throws IOException {
|
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 contents;
|
||||||
String classpath = ("/org/hl7/fhir/testcases/" + Utilities.pathURL(paths));
|
String classpath = ("/org/hl7/fhir/testcases/" + Utilities.pathURL(paths));
|
||||||
|
|
||||||
try (InputStream inputStream = BaseTestingUtilities.class.getResourceAsStream(classpath)) {
|
try (InputStream inputStream = BaseTestingUtilities.class.getResourceAsStream(classpath)) {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
throw new IOException("Can't find file on classpath: " + classpath);
|
throw new IOException("Can't find file on classpath: " + classpath);
|
||||||
|
@ -26,6 +38,7 @@ public class BaseTestingUtilities {
|
||||||
}
|
}
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static InputStream loadTestResourceStream(String... paths) throws IOException {
|
public static InputStream loadTestResourceStream(String... paths) throws IOException {
|
||||||
if (new File("../../fhir-test-cases").exists() && isTryToLoadFromFileSystem()) {
|
if (new File("../../fhir-test-cases").exists() && isTryToLoadFromFileSystem()) {
|
||||||
|
|
Loading…
Reference in New Issue