From 3ea42ca1b0967f4737898980f76e07000644fe59 Mon Sep 17 00:00:00 2001 From: dotasek Date: Tue, 24 Oct 2023 14:29:05 -0400 Subject: [PATCH] Fix test ignore/exclude issues, bump test cases --- .../hl7/fhir/dstu2/test/TestingUtilities.java | 4 +++ .../dstu2016may/test/TestingUtilities.java | 5 +++ .../dstu3/test/support/TestingUtilities.java | 5 ++- .../fhir/r4/test/utils/TestingUtilities.java | 4 +++ .../fhir/r4b/test/utils/TestingUtilities.java | 9 +++--- .../fhir/r5/test/utils/TestingUtilities.java | 5 ++- .../tests/LocalTerminologyServiceTests.java | 31 +++++++++++-------- .../tests/utilities/TestUtilities.java | 5 +++ pom.xml | 7 ++++- 9 files changed, 55 insertions(+), 20 deletions(-) diff --git a/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/test/TestingUtilities.java b/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/test/TestingUtilities.java index 5a0e65f5f..1caa5cc2f 100644 --- a/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/test/TestingUtilities.java +++ b/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/test/TestingUtilities.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.xml.parsers.DocumentBuilder; @@ -245,4 +246,7 @@ public class TestingUtilities { return null; } + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file diff --git a/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/test/TestingUtilities.java b/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/test/TestingUtilities.java index a6c297ee3..645df0f83 100644 --- a/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/test/TestingUtilities.java +++ b/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/test/TestingUtilities.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.xml.parsers.DocumentBuilder; @@ -245,4 +246,8 @@ public class TestingUtilities { return null; } + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } + } \ No newline at end of file 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 860617993..ea23d05cb 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 @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.xml.parsers.DocumentBuilder; @@ -276,5 +277,7 @@ public class TestingUtilities extends BaseTestingUtilities { return null; } - + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file 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 c11cf89ec..b71cd6662 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 @@ -38,6 +38,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.xml.parsers.DocumentBuilder; @@ -528,4 +529,7 @@ public class TestingUtilities { } } + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/test/utils/TestingUtilities.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/test/utils/TestingUtilities.java index ac718895e..1940a103a 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/test/utils/TestingUtilities.java @@ -5,10 +5,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -499,4 +496,8 @@ public class TestingUtilities extends BaseTestingUtilities { return path; } } + + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index 1039d3b73..42a61d208 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.fhir.ucum.UcumEssenceService; @@ -175,5 +176,7 @@ public class TestingUtilities extends BaseTestingUtilities { FilesystemPackageCacheManager.setPackageProvider(new TestingUtilities.PackageProvider()); } - + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/LocalTerminologyServiceTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/LocalTerminologyServiceTests.java index 91db02a4c..23e6c263c 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/LocalTerminologyServiceTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/LocalTerminologyServiceTests.java @@ -4,11 +4,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import org.apache.commons.io.IOUtils; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; @@ -27,11 +23,9 @@ import org.hl7.fhir.utilities.json.model.JsonObject; import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.validation.special.TxTester; import org.hl7.fhir.validation.special.TxTester.ITxTesterLoader; +import org.hl7.fhir.validation.tests.utilities.TestUtilities; import org.junit.Test; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.condition.EnabledIf; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -39,8 +33,7 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.base.Charsets; @RunWith(Parameterized.class) -@EnabledIf("localTxRunning") -@Disabled + public class LocalTerminologyServiceTests implements ITxTesterLoader { public static class JsonObjectPair { @@ -60,6 +53,8 @@ public class LocalTerminologyServiceTests implements ITxTesterLoader { return new File("/Users/grahamegrieve/work/server/serverx").exists(); } + + @Parameters(name = "{index}: id {0}") public static Iterable data() throws IOException { @@ -99,10 +94,16 @@ public class LocalTerminologyServiceTests implements ITxTesterLoader { } @SuppressWarnings("deprecation") - @Test - @Tag("excludedInSurefire") - @Disabled + @Test public void test() throws Exception { + if (TestUtilities.runningAsSurefire()) { + logTestSkip("Running in surefire."); + return; + } + if (!localTxRunning()) { + logTestSkip("No local terminology server available."); + return; + } if (SERVER != null) { if (tester == null) { tester = new TxTester(this, SERVER, true, externals); @@ -114,6 +115,10 @@ public class LocalTerminologyServiceTests implements ITxTesterLoader { } } + private void logTestSkip(String reason) { + System.out.println("Skipping test: " + setup.suite.asString("name") + " " + setup.test.asString("name") + " reason: " + reason); + } + public Resource loadResource(String filename) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException { String contents = TestingUtilities.loadTestResource("tx", filename); try (InputStream inputStream = IOUtils.toInputStream(contents, Charsets.UTF_8)) { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/utilities/TestUtilities.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/utilities/TestUtilities.java index 235a6f8ab..3187695a0 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/utilities/TestUtilities.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/utilities/TestUtilities.java @@ -1,6 +1,7 @@ package org.hl7.fhir.validation.tests.utilities; import java.nio.file.Paths; +import java.util.Locale; import org.hl7.fhir.r5.context.TerminologyCache; import org.hl7.fhir.r5.test.utils.TestingUtilities; @@ -65,4 +66,8 @@ public class TestUtilities { return validationEngine; } + + public static boolean runningAsSurefire() { + return "true".equals(System.getProperty("runningAsSurefire") != null ? System.getProperty("runningAsSurefire").toLowerCase(Locale.ENGLISH) : ""); + } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index c939ec634..8c92381c4 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 32.0.1-jre 6.4.1 - 1.4.12-SNAPSHOT + 1.4.13-SNAPSHOT 2.15.2 5.9.2 1.8.2 @@ -341,8 +341,13 @@ @{argLine} -Xmx5632m COMPAT + + true false + + excludedInSurefire