From 0c9fe20522cc8ed6b8a17f3f0d3addcf1c0c7993 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 31 Jan 2019 13:41:05 -0500 Subject: [PATCH] Get this test working (#4) --- .editorconfig | 5 +++++ org.hl7.fhir.dstu3/pom.xml | 4 ++-- .../fhir/dstu3/test/SnapShotGenerationTests.java | 11 +++++++++-- .../fhir/dstu3/test/support/TestingUtilities.java | 3 +++ org.hl7.fhir.r4/pom.xml | 14 ++++++++++---- .../hl7/fhir/r4/test/utils/TestingUtilities.java | 1 + .../fhir/utilities/cache/PackageCacheManager.java | 3 ++- pom.xml | 8 +++++++- 8 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..cd68918bc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.java] +charset = utf-8 +indent_style = space +indent_size = 2 + diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index ac775b0a1..1bf6cc72b 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -17,11 +17,11 @@ ca.uhn.hapi.fhir - hapi-fhir-base + org.hl7.fhir.utilities ca.uhn.hapi.fhir - org.hl7.fhir.utilities + hapi-fhir-base diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SnapShotGenerationTests.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SnapShotGenerationTests.java index f4a16280a..61b9c696f 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SnapShotGenerationTests.java @@ -13,6 +13,8 @@ import java.util.Set; import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.codec.Charsets; +import org.apache.commons.io.IOUtils; import org.hl7.fhir.dstu3.conformance.ProfileUtilities; import org.hl7.fhir.dstu3.context.SimpleWorkerContext; import org.hl7.fhir.dstu3.formats.IParser.OutputStyle; @@ -195,9 +197,10 @@ public class SnapShotGenerationTests { private static FHIRPathEngine fp; @Parameters(name = "{index}: file {0}") - public static Iterable data() throws ParserConfigurationException, IOException, FHIRFormatError { + public static Iterable data() throws IOException, FHIRFormatError { SnapShotGenerationTestsContext context = new SnapShotGenerationTestsContext(); - context.tests = (TestScript) new XmlParser().parse(new FileInputStream(Utilities.path(TestingUtilities.home(), "tests", "resources", "snapshot-generation-tests.xml"))); + String contents = readFileFromClasspathAsString("snapshot-generation-tests.xml"); + context.tests = (TestScript) new XmlParser().parse(contents); context.checkTestsDetails(); @@ -209,6 +212,10 @@ public class SnapShotGenerationTests { return objects; } + private static String readFileFromClasspathAsString(String theClasspath) throws IOException { + return IOUtils.toString(SnapShotGenerationTests.class.getResourceAsStream(theClasspath), Charsets.UTF_8); + } + private final TestScriptTestComponent test; private final String name; diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java index 71e725c85..3d7a328b3 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java @@ -43,6 +43,9 @@ public class TestingUtilities { String s = System.getenv("FHIR_HOME"); if (!Utilities.noString(s)) return s; + s = System.getProperty("FHIR_HOME"); + if (!Utilities.noString(s)) + return s; s = "C:\\work\\org.hl7.fhir\\build"; if (new File(s).exists()) return s; diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 5a8e93b0a..0c3bbda24 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -15,14 +15,20 @@ - - ca.uhn.hapi.fhir - hapi-fhir-base - ca.uhn.hapi.fhir org.hl7.fhir.utilities + + ca.uhn.hapi.fhir + hapi-fhir-base + + + ca.uhn.hapi.fhir + hapi-fhir-utilities + + + diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java index f3dbad616..4497bd850 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java @@ -66,6 +66,7 @@ public class TestingUtilities { PackageCacheManager pcm; try { pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION); + pcm.resolvePackage("hl7.fhir.core", "4.0.0", "4.0.1"); // FIXME: JA How to get the current version? fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackageCache("hl7.fhir.core", "4.0.0")); fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml"))); fcontext.setExpansionProfile(new Parameters()); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index e4d7b5560..51b2b1042 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -393,7 +393,8 @@ public class PackageCacheManager { private void analysePackage(String dir, String v, Map profiles, Map canonicals) throws IOException { int i = 0; int c = 11; - for (File f : new File(Utilities.path(dir, "package")).listFiles()) { + File[] packages = new File(Utilities.path(dir, "package")).listFiles(); + for (File f : packages) { i++; if (progress && i % 20 == 0) { c++; diff --git a/pom.xml b/pom.xml index cb09a3427..15105a38f 100644 --- a/pom.xml +++ b/pom.xml @@ -74,11 +74,17 @@ ca.uhn.hapi.fhir hapi-fhir-base ${hapi_fhir_version} + + + ca.uhn.hapi.fhir + hapi-fhir-utilities + + ca.uhn.hapi.fhir org.hl7.fhir.utilities - ${hapi_fhir_version} + ${project.version} ca.uhn.hapi.fhir