use ClasspathUtil (#5263)

This commit is contained in:
Ken Stevens 2023-08-31 13:23:00 -04:00 committed by GitHub
parent f38df4b91a
commit 590e6ba88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 49 additions and 38 deletions

View File

@ -42,6 +42,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.ClasspathUtil;
import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
@ -447,7 +448,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
String name = "profiles-resources";
ourLog.info("Uploading " + name);
String vsContents;
vsContents = IOUtils.toString(FhirResourceDaoDstu3Test.class.getResourceAsStream("/org/hl7/fhir/dstu3/model/profile/" + name + ".xml"), StandardCharsets.UTF_8);
vsContents = ClasspathUtil.loadResource("/org/hl7/fhir/dstu3/model/profile/" + name + ".xml");
bundle = myFhirContext.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
for (BundleEntryComponent i : bundle.getEntry()) {

View File

@ -242,7 +242,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
}
private Bundle loadBundle(String theFileName) throws IOException {
String req = IOUtils.toString(FhirSystemDaoDstu3Test.class.getResourceAsStream(theFileName), StandardCharsets.UTF_8);
String req = ClasspathUtil.loadResource(theFileName);
return myFhirContext.newXmlParser().parseResource(Bundle.class, req);
}

View File

@ -50,6 +50,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.ClasspathUtil;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
@ -814,7 +815,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
String name = "profiles-resources";
ourLog.info("Uploading " + name);
String vsContents;
vsContents = IOUtils.toString(FhirResourceDaoR4Test.class.getResourceAsStream("/org/hl7/fhir/r4/model/profile/" + name + ".xml"), StandardCharsets.UTF_8);
vsContents = ClasspathUtil.loadResource("/org/hl7/fhir/r4/model/profile/" + name + ".xml");
bundle = myFhirContext.newXmlParser().parseResource(org.hl7.fhir.r4.model.Bundle.class, vsContents);
for (BundleEntryComponent i : bundle.getEntry()) {

View File

@ -2333,7 +2333,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
@Test
public void testTransactionCreateWithPutUsingUrl2() throws Exception {
String req = IOUtils.toString(FhirSystemDaoR4Test.class.getResourceAsStream("/r4/bundle.xml"), StandardCharsets.UTF_8);
String req = ClasspathUtil.loadResource("/r4/bundle.xml");
Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, req);
mySystemDao.transaction(mySrd, request);
}

View File

@ -110,7 +110,7 @@ public class Batch2JobHelper {
} catch (ConditionTimeoutException e) {
String statuses = myJobPersistence.fetchInstances(100, 0)
.stream()
.map(t -> t.getJobDefinitionId() + "/" + t.getStatus().name())
.map(t -> t.getInstanceId() + " " + t.getJobDefinitionId() + "/" + t.getStatus().name())
.collect(Collectors.joining("\n"));
String currentStatus = myJobCoordinator.getInstance(theBatchJobId).getStatus().name();
fail("Job " + theBatchJobId + " still has status " + currentStatus + " - All statuses:\n" + statuses);

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
import ca.uhn.fhir.parser.PatientWithExtendedContactDstu3.CustomContactComponent;
import ca.uhn.fhir.parser.XmlParserDstu2_1Test.TestPatientFor327;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets;
import net.sf.json.JSON;
@ -1222,7 +1223,7 @@ public class JsonParserDstu2_1Test {
@Test
@Disabled
public void testParseAndEncodeBundle() throws Exception {
String content = IOUtils.toString(JsonParserDstu2_1Test.class.getResourceAsStream("/bundle-example.json"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.json");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getIdElement().getValue());
@ -1271,7 +1272,7 @@ public class JsonParserDstu2_1Test {
@Test
@Disabled
public void testParseAndEncodeBundleFromXmlToJson() throws Exception {
String content = IOUtils.toString(JsonParserDstu2_1Test.class.getResourceAsStream("/bundle-example2.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example2.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
@ -1296,7 +1297,7 @@ public class JsonParserDstu2_1Test {
@Test
@Disabled
public void testParseAndEncodeBundleNewStyle() throws Exception {
String content = IOUtils.toString(JsonParserDstu2_1Test.class.getResourceAsStream("/bundle-example.json"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.json");
Bundle parsed = ourCtx.newJsonParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getIdElement().getValue());

View File

@ -9,6 +9,7 @@ import ca.uhn.fhir.parser.FooMessageHeaderWithExplicitField.FooMessageSourceComp
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
import ca.uhn.fhir.parser.PatientWithCustomCompositeExtension.FooParentExtension;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets;
import org.apache.commons.io.IOUtils;
@ -1707,7 +1708,7 @@ public class XmlParserDstu2_1Test {
@Test
@Disabled
public void testParseAndEncodeBundle() throws Exception {
String content = IOUtils.toString(XmlParserDstu2_1Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getIdElement().getValue());
@ -1742,7 +1743,7 @@ public class XmlParserDstu2_1Test {
@Test
@Disabled
public void testParseAndEncodeBundleNewStyle() throws Exception {
String content = IOUtils.toString(XmlParserDstu2_1Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
IParser newXmlParser = ourCtx.newXmlParser();
Bundle parsed = newXmlParser.parseResource(Bundle.class, content);

View File

@ -62,6 +62,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets;
import org.apache.commons.io.IOUtils;
@ -1057,7 +1058,7 @@ public class XmlParserDstu2Test {
public void testEncodeAndParseProfiledDatatypeChoice() throws Exception {
IParser xmlParser = ourCtx.newXmlParser();
String input = IOUtils.toString(XmlParser.class.getResourceAsStream("/medicationstatement_invalidelement.xml"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/medicationstatement_invalidelement.xml");
MedicationStatement ms = xmlParser.parseResource(MedicationStatement.class, input);
SimpleQuantityDt q = (SimpleQuantityDt) ms.getDosage().get(0).getQuantity();
assertEquals("1", q.getValueElement().getValueAsString());
@ -2005,7 +2006,7 @@ public class XmlParserDstu2Test {
@Test
public void testParseAndEncodeBundle() throws Exception {
String content = IOUtils.toString(XmlParserDstu2Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getId().getValue());
@ -2039,7 +2040,7 @@ public class XmlParserDstu2Test {
@Test
public void testParseAndEncodeBundleNewStyle() throws Exception {
String content = IOUtils.toString(XmlParserDstu2Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
IParser newXmlParser = ourCtx.newXmlParser();
ca.uhn.fhir.model.dstu2.resource.Bundle parsed = newXmlParser.parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, content);
@ -2512,7 +2513,7 @@ public class XmlParserDstu2Test {
*/
@Test
public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
String input = IOUtils.toString(XmlParserDstu2Test.class.getResourceAsStream("/bundle_orion.xml"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bundle_orion.xml");
ca.uhn.fhir.model.dstu2.resource.Bundle parsed = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, input);
Link link = parsed.getLink().get(0);

View File

@ -24,6 +24,7 @@ import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.parser.StrictErrorHandler;
import ca.uhn.fhir.parser.XmlParserDstu2Test.TestPatientFor327;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
import org.apache.commons.io.IOUtils;
@ -125,7 +126,7 @@ public class ResourceValidatorDstu2Test {
@Test
public void testSchemaBundleValidatorFails() throws IOException {
String res = IOUtils.toString(ResourceValidatorDstu2Test.class.getResourceAsStream("/bundle-example.json"), StandardCharsets.UTF_8);
String res = ClasspathUtil.loadResource("/bundle-example.json");
Bundle b = ourCtx.newJsonParser().parseResource(Bundle.class, res);
@ -154,7 +155,7 @@ public class ResourceValidatorDstu2Test {
@Test
public void testSchemaBundleValidatorIsSuccessful() throws IOException {
String res = IOUtils.toString(ResourceValidatorDstu2Test.class.getResourceAsStream("/bundle-example.json"), StandardCharsets.UTF_8);
String res = ClasspathUtil.loadResource("/bundle-example.json");
Bundle b = ourCtx.newJsonParser().parseResource(Bundle.class, res);
ourLog.debug(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b));
@ -220,7 +221,7 @@ public class ResourceValidatorDstu2Test {
@Test
public void testSchematronResourceValidator() throws IOException {
String res = IOUtils.toString(ResourceValidatorDstu2Test.class.getResourceAsStream("/patient-example-dicom.json"), StandardCharsets.UTF_8);
String res = ClasspathUtil.loadResource("/patient-example-dicom.json");
Patient p = ourCtx.newJsonParser().parseResource(Patient.class, res);
FhirValidator val = ourCtx.newValidator();

View File

@ -8,6 +8,7 @@ import ca.uhn.fhir.parser.PatientWithExtendedContactDstu3.CustomContactComponent
import ca.uhn.fhir.parser.XmlParserDstu3Test.TestPatientFor327;
import ca.uhn.fhir.parser.json.BaseJsonLikeValue.ScalarType;
import ca.uhn.fhir.parser.json.BaseJsonLikeValue.ValueType;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.validation.FhirValidator;
import ca.uhn.fhir.validation.ValidationResult;
@ -147,7 +148,7 @@ public class JsonParserDstu3Test {
*/
@Test
public void testBadMessageForUnknownElement() throws IOException {
String input = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/bad_parse_bundle_1.json"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bad_parse_bundle_1.json");
IParser p = ourCtx.newJsonParser();
p.setParserErrorHandler(new StrictErrorHandler());
@ -165,7 +166,7 @@ public class JsonParserDstu3Test {
*/
@Test
public void testBadMessageForUnknownElement2() throws IOException {
String input = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/bad_parse_bundle_2.json"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bad_parse_bundle_2.json");
IParser p = ourCtx.newJsonParser();
p.setParserErrorHandler(new StrictErrorHandler());
@ -1730,7 +1731,7 @@ public class JsonParserDstu3Test {
@Test
@Disabled
public void testParseAndEncodeBundle() throws Exception {
String content = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/bundle-example.json"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.json");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getIdElement().getValue());
@ -1779,7 +1780,7 @@ public class JsonParserDstu3Test {
@Test
@Disabled
public void testParseAndEncodeBundleFromXmlToJson() throws Exception {
String content = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/bundle-example2.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example2.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
@ -1954,7 +1955,7 @@ public class JsonParserDstu3Test {
*/
@Test
public void testParseCommunicationWithThreeTypes() throws IOException {
String content = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/tara-test.json"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/tara-test.json");
Communication comm = ourCtx.newJsonParser().parseResource(Communication.class, content);
assertEquals(3, comm.getPayload().size());
@ -2199,7 +2200,7 @@ public class JsonParserDstu3Test {
// We're lenient so we accept it. Maybe this could change, or be a warning in future though
String input = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/missing_array.json"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/missing_array.json");
RelatedPerson rp = ourCtx.newJsonParser().parseResource(RelatedPerson.class, input);
assertEquals(1, rp.getName().size());
assertEquals("Doe", rp.getName().get(0).getFamily());
@ -2424,7 +2425,7 @@ public class JsonParserDstu3Test {
*/
@Test
public void testUnexpectedElementsWithUnderscoreAtStartOfName() throws Exception {
String input = IOUtils.toString(JsonParserDstu3Test.class.getResourceAsStream("/bug477.json"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bug477.json");
IParserErrorHandler errorHandler = mock(IParserErrorHandler.class);

View File

@ -8,6 +8,7 @@ import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.parser.FooMessageHeaderWithExplicitField.FooMessageSourceComponent;
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
import ca.uhn.fhir.parser.PatientWithCustomCompositeExtension.FooParentExtension;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets;
import org.apache.commons.io.FileUtils;
@ -2387,7 +2388,7 @@ public class XmlParserDstu3Test {
@Test
@Disabled
public void testParseAndEncodeBundle() throws Exception {
String content = IOUtils.toString(XmlParserDstu3Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, content);
assertEquals("Bundle/example/_history/1", parsed.getIdElement().getValue());
@ -2422,7 +2423,7 @@ public class XmlParserDstu3Test {
@Test
@Disabled
public void testParseAndEncodeBundleNewStyle() throws Exception {
String content = IOUtils.toString(XmlParserDstu3Test.class.getResourceAsStream("/bundle-example.xml"), StandardCharsets.UTF_8);
String content = ClasspathUtil.loadResource("/bundle-example.xml");
IParser newXmlParser = ourCtx.newXmlParser();
Bundle parsed = newXmlParser.parseResource(Bundle.class, content);
@ -3004,7 +3005,7 @@ public class XmlParserDstu3Test {
*/
@Test
public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
String input = IOUtils.toString(XmlParserDstu3Test.class.getResourceAsStream("/bundle_orion.xml"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bundle_orion.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, input);
BundleLinkComponent link = parsed.getLink().get(0);

View File

@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
@ -1162,7 +1163,7 @@ public class JsonParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncode() throws IOException {
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), StandardCharsets.UTF_8);
String xmlString = ClasspathUtil.loadResource("/example-patient-general-hl7orgdstu2.xml");
Patient obs = ourCtx.newXmlParser().parseResource(Patient.class, xmlString);
List<Extension> undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getExtension();
@ -1175,7 +1176,7 @@ public class JsonParserHl7OrgDstu2Test {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), StandardCharsets.UTF_8);
String jsonString = ClasspathUtil.loadResource("/example-patient-general-hl7orgdstu2.json");
JSON expected = JSONSerializer.toJSON(jsonString);
JSON actual = JSONSerializer.toJSON(encoded.trim());
@ -1232,7 +1233,7 @@ public class JsonParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException, SAXException {
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), StandardCharsets.UTF_8);
String jsonString = ClasspathUtil.loadResource("/example-patient-general-hl7orgdstu2.json");
MyObservationWithExtensions obs = ourCtx.newJsonParser().parseResource(MyObservationWithExtensions.class, jsonString);
{
@ -1255,7 +1256,7 @@ public class JsonParserHl7OrgDstu2Test {
String encoded = xmlParser.encodeResourceToString(obs);
encoded = encoded.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), StandardCharsets.UTF_8);
String xmlString = ClasspathUtil.loadResource("/example-patient-general-hl7orgdstu2.xml");
xmlString = xmlString.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
ourLog.info("Expected: " + xmlString);

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.r4.elementmodel;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.util.ClasspathUtil;
import org.apache.commons.io.IOUtils;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext;
@ -60,7 +61,7 @@ public class PropertyTest {
@BeforeEach
public void setUp() throws IOException {
final String sdString = IOUtils.toString(PropertyTest.class.getResourceAsStream("/customPatientSd.xml"), StandardCharsets.UTF_8);
final String sdString = ClasspathUtil.loadResource("/customPatientSd.xml");
final IParser parser = ourCtx.newXmlParser();
sd = parser.parseResource(StructureDefinition.class, sdString);
workerContext = new HapiWorkerContext(ourCtx, ourCtx.getValidationSupport());

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.context.support.ValueSetExpansionOptions;
import ca.uhn.fhir.test.utilities.LoggingExtension;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.validation.FhirValidator;
import ca.uhn.fhir.validation.ResultSeverityEnum;
@ -630,7 +631,7 @@ public class FhirInstanceValidatorDstu3Test {
String name = "profiles-resources";
ourLog.info("Uploading " + name);
String vsContents;
vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/org/hl7/fhir/dstu3/model/profile/" + name + ".xml"), StandardCharsets.UTF_8);
vsContents = ClasspathUtil.loadResource("/org/hl7/fhir/dstu3/model/profile/" + name + ".xml");
TreeSet<String> ids = new TreeSet<String>();
@ -700,7 +701,7 @@ public class FhirInstanceValidatorDstu3Test {
@Test
public void testValidateBundleWithNoType() throws Exception {
String vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/dstu3/bundle-with-no-type.json"), StandardCharsets.UTF_8);
String vsContents = ClasspathUtil.loadResource("/dstu3/bundle-with-no-type.json");
ValidationResult output = myVal.validateWithResult(vsContents);
logResultsAndReturnNonInformationalOnes(output);
@ -713,7 +714,7 @@ public class FhirInstanceValidatorDstu3Test {
String name = "profiles-resources";
ourLog.info("Uploading " + name);
String inputString;
inputString = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/brian_reinhold_bundle.json"), StandardCharsets.UTF_8);
inputString = ClasspathUtil.loadResource("/brian_reinhold_bundle.json");
Bundle bundle = ourCtx.newJsonParser().parseResource(Bundle.class, inputString);
FHIRPathEngine fp = new FHIRPathEngine(new HapiWorkerContext(ourCtx, myDefaultValidationSupport));
@ -766,7 +767,7 @@ public class FhirInstanceValidatorDstu3Test {
String name = "profiles-resources";
ourLog.info("Uploading " + name);
String vsContents;
vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/crucible-condition.xml"), StandardCharsets.UTF_8);
vsContents = ClasspathUtil.loadResource("/crucible-condition.xml");
ValidationResult output = myVal.validateWithResult(vsContents);
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
@ -774,7 +775,7 @@ public class FhirInstanceValidatorDstu3Test {
@Test
public void testValidateDocument() throws Exception {
String vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/sample-document.xml"), StandardCharsets.UTF_8);
String vsContents = ClasspathUtil.loadResource("/sample-document.xml");
ValidationResult output = myVal.validateWithResult(vsContents);
logResultsAndReturnNonInformationalOnes(output);

View File

@ -2726,7 +2726,7 @@ public class Dstu3XmlParserTest {
*/
@Test
public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
String input = IOUtils.toString(Dstu3XmlParserTest.class.getResourceAsStream("/bundle_orion.xml"), StandardCharsets.UTF_8);
String input = ClasspathUtil.loadResource("/bundle_orion.xml");
Bundle parsed = ourCtx.newXmlParser().parseResource(Bundle.class, input);
Bundle.BundleLinkComponent link = parsed.getLink().get(0);