From d8d8c5fa44705e458f0e3e80cc81a614e8bbf9fd Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Mon, 14 Nov 2022 13:51:03 -0500 Subject: [PATCH] Consolidate all System Properties into a single class (#4252) * started converting System.setProperty to HapiSystem * added a couple more. renamed class * all the setProperty calls done * finished System.getProperty() * Split HapiSystemProperties into HapiSystemProperties and HapiTestSystemProperties * Javadoc * Javadoc * review feedback Co-authored-by: Ken Stevens --- .../ca/uhn/fhir/android/BuiltJarDstu2IT.java | 39 ++--- .../android/client/GenericClientDstu3IT.java | 6 +- .../java/ca/uhn/fhir/context/FhirContext.java | 3 +- .../java/ca/uhn/fhir/rest/api/Constants.java | 4 - .../uhn/fhir/system/HapiSystemProperties.java | 140 ++++++++++++++++++ .../java/ca/uhn/fhir/util/DatatypeUtil.java | 1 - .../java/ca/uhn/fhir/util/TimeoutManager.java | 3 +- .../java/ca/uhn/fhir/util/VersionUtil.java | 3 +- .../main/java/ca/uhn/fhir/util/XmlUtil.java | 6 +- .../ca/uhn/fhir/util/TimeoutManagerTest.java | 3 +- .../main/java/ca/uhn/fhir/cli/BaseApp.java | 12 +- .../ca/uhn/fhir/cli/RunServerCommand.java | 14 +- .../fhir/cli/UploadTerminologyCommand.java | 3 +- .../ca/uhn/fhir/cli/BulkImportCommandIT.java | 3 +- .../fhir/cli/CreatePackageCommandTest.java | 3 +- ...ExportConceptMapToCsvCommandDstu3Test.java | 5 +- .../ExportConceptMapToCsvCommandR4Test.java | 5 +- .../HapiFlywayMigrateDatabaseCommandTest.java | 3 +- ...ImportCsvToConceptMapCommandDstu3Test.java | 3 +- .../ImportCsvToConceptMapCommandR4Test.java | 3 +- .../cli/ReindexTerminologyCommandTest.java | 3 +- .../cli/UploadTerminologyCommandTest.java | 5 +- .../ca/uhn/fhir/cli/ValidateCommandTest.java | 15 +- .../ca/uhn/fhir/jpa/demo/CommonConfig.java | 9 +- .../uhn/fhir/rest/client/impl/BaseClient.java | 12 +- .../VersionedApiConverterInterceptor.java | 6 +- .../canonical/VersionCanonicalizerTest.java | 3 +- .../client/GenericJaxRsClientDstu3Test.java | 3 +- .../uhn/fhir/jpa/batch2/JpaBatch2Config.java | 3 +- .../jpa/batch2/JpaJobPersistenceImpl.java | 1 - .../ca/uhn/fhir/jpa/config/JpaConfig.java | 1 - ...JpaPersistedResourceValidationSupport.java | 2 +- .../fhir/jpa/dao/JpaResourceDaoValueSet.java | 1 - .../java/ca/uhn/fhir/jpa/entity/Search.java | 4 +- .../jpa/partition/PartitionLookupSvcImpl.java | 10 +- .../BaseJpaResourceProviderCodeSystem.java | 1 - .../fhir/jpa/provider/JpaSystemProvider.java | 2 - .../provider/ValueSetOperationProvider.java | 1 - .../jpa/search/builder/tasks/SearchTask.java | 6 +- .../cache/DatabaseSearchCacheSvcImpl.java | 6 +- .../fhir/jpa/util/QueryParameterUtils.java | 1 - ...esourceDaoR4SearchWithElasticSearchIT.java | 1 - ...sourceDaoR4TerminologyElasticsearchIT.java | 2 - .../extractor/BaseSearchParamExtractor.java | 1 - .../extractor/SearchParamExtractorR4.java | 2 +- .../extractor/SearchParamExtractorR4B.java | 2 +- .../fhir/jpa/searchparam/retry/Retrier.java | 3 +- .../module/BaseSubscriptionTest.java | 7 +- .../fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java | 2 - ...ceDaoDstu2SearchCustomSearchParamTest.java | 2 - .../FhirResourceDaoValueSetDstu2Test.java | 5 - .../provider/ResourceProviderDstu2Test.java | 2 +- .../ResourceProviderDstu2ValueSetTest.java | 2 - .../search/SearchCoordinatorSvcImplTest.java | 6 +- .../dstu3/BaseResourceProviderDstu3Test.java | 2 +- .../fhir/jpa/batch2/Batch2CoordinatorIT.java | 4 - .../fhir/jpa/bulk/BulkExportUseCaseTest.java | 1 - .../bulk/BulkExportUseCaseTestAnyMode.java | 5 - .../jpa/dao/BaseHapiFhirResourceDaoTest.java | 5 - .../jpa/dao/r4/FhirResourceDaoR4MetaTest.java | 5 +- .../r4/FhirResourceDaoR4SearchNoFtTest.java | 2 +- ...rceDaoR4SearchWithHSearchDisabledTest.java | 12 -- .../jpa/dao/r4/FhirResourceDaoR4Test.java | 1 - .../dao/r4/FhirResourceDaoR4UpdateTest.java | 2 - .../fhir/jpa/dao/r4/FhirSystemDaoR4Test.java | 1 - .../uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java | 9 +- .../r4/PatientMemberMatchOperationR4Test.java | 2 +- .../r4/ResourceProviderConcurrencyR4Test.java | 1 - ...ProviderR4ValueSetHSearchDisabledTest.java | 3 - ...rCapabilityStatementProviderJpaR4Test.java | 1 - .../jpa/provider/r4/SubscriptionsR4Test.java | 1 - .../RestHookWithInterceptorR4Test.java | 1 - .../jpa/term/TerminologySvcImplR4Test.java | 2 - .../uhn/fhir/jpa/dao/r4b/BaseJpaR4BTest.java | 2 - .../ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java | 4 +- .../r5/BaseResourceProviderR5Test.java | 2 +- .../provider/BaseResourceProviderR4Test.java | 1 - .../r4/BaseResourceProviderR4Test.java | 1 - ...SystemDeleteJobSvcWithUniTestFailures.java | 1 - .../ca/uhn/fhir/jpa/test/BaseJpaR4Test.java | 4 - .../ca/uhn/fhir/jpa/test/BaseJpaTest.java | 8 +- .../BaseValueSetHSearchExpansionR4Test.java | 2 - .../fhir/jpa/test/config/TestDstu2Config.java | 3 +- .../fhir/jpa/test/config/TestDstu3Config.java | 5 +- .../fhir/jpa/test/config/TestJPAConfig.java | 4 +- .../fhir/jpa/test/config/TestR4BConfig.java | 6 +- .../fhir/jpa/test/config/TestR4Config.java | 5 +- .../fhir/jpa/test/config/TestR5Config.java | 3 +- .../ca/uhn/fhir/jpa/dao/DaoConfigTest.java | 5 +- .../jpa/term/LoincFullLoadR4SandboxIT.java | 3 +- .../ca/uhn/fhirtest/TestRestfulServer.java | 9 +- .../uhn/fhir/rest/server/RestfulServer.java | 1 - .../BaseResourceReturningMethodBinding.java | 2 +- .../method/ConformanceMethodBinding.java | 3 +- .../ca/uhn/fhir/jpa/migrate/HapiMigrator.java | 3 +- .../fhir/jpa/migrate/taskdef/BaseTask.java | 3 +- .../jobs/export/FetchResourceIdsStep.java | 3 +- .../BulkExportJobParametersValidatorTest.java | 4 - .../coordinator/JobDefinitionRegistry.java | 1 - .../coordinator/JobCoordinatorImplTest.java | 2 - .../JobDefinitionRegistryTest.java | 1 - .../ca/uhn/fhir/jpa/api/config/DaoConfig.java | 7 +- .../api/dao/IFhirResourceDaoCodeSystem.java | 2 +- .../dao/index/DaoResourceLinkResolver.java | 6 +- .../uhn/fhir/jpa/util/MemoryCacheService.java | 6 +- .../rest/client/GenericClientDstu2_1Test.java | 4 +- .../client/NonGenericClientDstu2_1Test.java | 4 +- .../rest/client/GenericClientDstu2Test.java | 4 +- .../rest/client/MessageClientDstu2Test.java | 4 +- .../dstu3/hapi/ctx/HapiWorkerContext.java | 14 +- .../rest/client/GenericClientDstu3Test.java | 4 +- .../client/NonGenericClientDstu3Test.java | 4 +- .../MetadataCapabilityStatementDstu3Test.java | 3 +- ...erationDuplicateServerHl7OrgDstu2Test.java | 3 +- ...verConformanceProviderHl7OrgDstu2Test.java | 18 ++- .../fhir/r4/hapi/ctx/HapiWorkerContext.java | 16 +- .../rest/client/BaseGenericClientR4Test.java | 4 +- .../rest/client/NonGenericClientR4Test.java | 4 +- ...ThreadLocalCapturingInterceptorR4Test.java | 4 +- .../rest/server/BlockingContentR4Test.java | 4 - .../org/hl7/fhir/r4b/hapi/ctx/FhirR4B.java | 2 +- .../fhir/r4b/hapi/ctx/HapiWorkerContext.java | 7 +- .../fhir/r4b/hapi/fhirpath/FhirPathR4B.java | 2 +- .../rest/client/GenericClientR4BTest.java | 4 +- .../fhir/r5/hapi/ctx/HapiWorkerContext.java | 14 +- .../fhir/system/HapiTestSystemProperties.java | 54 +++++++ .../support/CachingValidationSupport.java | 4 +- .../VersionSpecificWorkerContextWrapper.java | 14 +- 128 files changed, 425 insertions(+), 336 deletions(-) create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/system/HapiSystemProperties.java create mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/system/HapiTestSystemProperties.java diff --git a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarDstu2IT.java b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarDstu2IT.java index 979ab6bd980..27fa1d13580 100644 --- a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarDstu2IT.java +++ b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarDstu2IT.java @@ -1,37 +1,42 @@ package ca.uhn.fhir.android; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.File; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.model.dstu2.composite.QuantityDt; +import ca.uhn.fhir.model.dstu2.resource.Conformance; +import ca.uhn.fhir.model.dstu2.resource.Observation; +import ca.uhn.fhir.model.dstu2.resource.Patient; +import ca.uhn.fhir.rest.client.api.IGenericClient; +import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.WildcardFileFilter; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.model.dstu2.composite.QuantityDt; -import ca.uhn.fhir.model.dstu2.resource.*; -import ca.uhn.fhir.rest.client.api.IGenericClient; -import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class BuiltJarDstu2IT { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BuiltJarDstu2IT.class); @BeforeAll public static void beforeClass() { - System.setProperty("javax.xml.stream.XMLInputFactory", "FOO"); - System.setProperty("javax.xml.stream.XMLOutputFactory", "FOO"); + System.setProperty(javax.xml.stream.XMLInputFactory.class.getName(), "FOO"); + System.setProperty(javax.xml.stream.XMLOutputFactory.class.getName(), "FOO"); } @Test - public void testParserXml() throws Exception { + public void testParserXml() { FhirContext ctx = FhirContext.forDstu2(); diff --git a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java index 5f459f23adb..bb0568b3f9e 100644 --- a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java +++ b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java @@ -303,9 +303,9 @@ public class GenericClientDstu3IT { public static void beforeClass() { // // Force StAX to fail like it will on android -// System.setProperty("javax.xml.stream.XMLInputFactory", "FOO"); -// System.setProperty("javax.xml.stream.XMLOutputFactory", "FOO"); - +// System.setProperty(javax.xml.stream.XMLInputFactory.class.getName(), "FOO"); +// System.setProperty(javax.xml.stream.XMLOutputFactory.class.getName(), "FOO"); + ourCtx = FhirContext.forDstu3(); } } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java index 39561e08125..6d4ddad52c2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.rest.client.api.IBasicClient; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.IRestfulClient; import ca.uhn.fhir.rest.client.api.IRestfulClientFactory; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.ReflectionUtil; import ca.uhn.fhir.util.VersionUtil; @@ -203,7 +204,7 @@ public class FhirContext { ourLog.info("Creating new FhirContext with auto-detected version [{}]. It is recommended to explicitly select a version for future compatibility by invoking FhirContext.forDstuX()", myVersion.getVersion().name()); } else { - if ("true".equals(System.getProperty("unit_test_mode"))) { + if (HapiSystemProperties.isUnitTestModeEnabled()) { String calledAt = ExceptionUtils.getStackFrames(new Throwable())[4]; ourLog.info("Creating new FHIR context for FHIR version [{}]{}", myVersion.getVersion().name(), calledAt); } else { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java index 2d49950d01a..b66f1b4438d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java @@ -256,10 +256,6 @@ public class Constants { public static final Charset CHARSET_US_ASCII; public static final String PARAM_PAGEID = "_pageId"; public static final String JAVA_VALIDATOR_DETAILS_SYSTEM = "http://hl7.org/fhir/java-core-messageId"; - /** - * This is provided for testing only! Use with caution as this property may change. - */ - public static final String TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS = "TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS"; public static final String PARAM_SEARCH_TOTAL_MODE = "_total"; public static final String CAPABILITYSTATEMENT_WEBSOCKET_URL = "http://hl7.org/fhir/StructureDefinition/capabilitystatement-websocket"; public static final String PARAMETER_CASCADE_DELETE = "_cascade"; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/system/HapiSystemProperties.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/system/HapiSystemProperties.java new file mode 100644 index 00000000000..6f50600d54d --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/system/HapiSystemProperties.java @@ -0,0 +1,140 @@ +package ca.uhn.fhir.system; + +import org.apache.commons.lang3.time.DateUtils; + +public final class HapiSystemProperties { + private static final String SUPPRESS_HAPI_FHIR_VERSION_LOG = "suppress_hapi_fhir_version_log"; + private static final String DISABLE_STATUS_BASED_REINDEX = "disable_status_based_reindex"; + /** + * This is provided for testing only! Use with caution as this property may change. + */ + private static final String TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS = "TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS"; + private static final String UNIT_TEST_CAPTURE_STACK = "unit_test_capture_stack"; + private static final String STACKFILTER_PATTERN_PROP = "log.stackfilter.pattern"; + private static final String HAPI_CLIENT_KEEPRESPONSES = "hapi.client.keepresponses"; + private static final String TEST_MODE = "test"; + private static final String UNIT_TEST_MODE = "unit_test_mode"; + private static final long DEFAULT_TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS = 10 * DateUtils.MILLIS_PER_SECOND; + + private HapiSystemProperties() { + } + + /** + * This property is used by unit tests - do not rely on it in production code + * as it may change at any time. If you want to capture responses in a reliable + * way in your own code, just use client interceptors + */ + public static void enableHapiClientKeepResponses() { + System.setProperty(HAPI_CLIENT_KEEPRESPONSES, "true"); + } + + public static void disableHapiClientKeepResponses() { + System.clearProperty(HAPI_CLIENT_KEEPRESPONSES); + } + + /** + * This property is used by unit tests - do not rely on it in production code + * as it may change at any time. If you want to capture responses in a reliable + * way in your own code, just use client interceptors + */ + public static boolean isHapiClientKeepResponsesEnabled() { + return ("true".equals(System.getProperty(HAPI_CLIENT_KEEPRESPONSES))); + } + + /** + * This property gets used in the logback.xml file. + * It causes logged stack traces to skip a number of packages that are + * just noise. + */ + + public static void setStackFilterPattern(String thePattern) { + System.setProperty(STACKFILTER_PATTERN_PROP, thePattern); + } + + /** + * Set the validation resource cache expireAfterWrite timeout in milliseconds + * + * @param theMillis + */ + public static void setTestValidationResourceCachesMs(long theMillis) { + System.setProperty(TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS, "" + theMillis); + } + + /** + * Get the validation resource cache expireAfterWrite timeout in milliseconds. If it has not been set, the default + * value is 10 seconds. + */ + + public static long getTestValidationResourceCachesMs() { + String property = System.getProperty(TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS); + if (property == null) { + return DEFAULT_TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS; + } + return Long.parseLong(property); + } + + /** + * When this property is primarily used to control application shutdown behavior + */ + public static void enableTestMode() { + System.setProperty(TEST_MODE, "true"); + } + + public static boolean isTestModeEnabled() { + return "true".equals(System.getProperty(TEST_MODE)); + } + + /** + * This property is used to ensure unit test behaviour is deterministic. It is also used to add extra logging for unit tests. + */ + public static void enableUnitTestMode() { + System.setProperty(UNIT_TEST_MODE, "true"); + } + + public static boolean isUnitTestModeEnabled() { + return "true".equals(System.getProperty(UNIT_TEST_MODE)); + } + + /** + * This property prevents stack traces from getting truncated and includes the full stack trace in failed search responses. + */ + public static void enableUnitTestCaptureStack() { + System.setProperty(UNIT_TEST_CAPTURE_STACK, "true"); + } + + public static void disableUnitTestCaptureStack() { + System.clearProperty(HapiSystemProperties.UNIT_TEST_CAPTURE_STACK); + } + + public static boolean isUnitTestCaptureStackEnabled() { + return "true".equals(System.getProperty(HapiSystemProperties.UNIT_TEST_CAPTURE_STACK)); + } + + public static boolean isDisableStatusBasedReindex() { + return "true".equals(System.getProperty(DISABLE_STATUS_BASED_REINDEX)); + } + + public static void disableStatusBasedReindex() { + System.setProperty(DISABLE_STATUS_BASED_REINDEX, "true"); + } + + /** + * This property sets {@link DaoConfig#setStatusBasedReindexingDisabled(Boolean)} to true when the system starts up. + */ + public static void enableStatusBasedReindex() { + System.clearProperty(DISABLE_STATUS_BASED_REINDEX); + } + + /** + * This property is used to suppress the logging of the HAPI FHIR version on startup. + */ + // TODO KHS use this in cdr + public static void enableSuppressHapiFhirVersionLog() { + System.setProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG, "true"); + } + + public static boolean isSuppressHapiFhirVersionLogEnabled() { + return "true".equals(System.getProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG)); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DatatypeUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DatatypeUtil.java index 5efe10aad8c..ae0d0a88a15 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DatatypeUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/DatatypeUtil.java @@ -22,7 +22,6 @@ package ca.uhn.fhir.util; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java index 625053e855e..187eebc6145 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java @@ -21,6 +21,7 @@ package ca.uhn.fhir.util; */ import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.system.HapiSystemProperties; import com.google.common.annotations.VisibleForTesting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +57,7 @@ public class TimeoutManager { retval = true; } if (myStopWatch.getMillis() > myErrorTimeout.toMillis() && !errored) { - if ("true".equalsIgnoreCase(System.getProperty("unit_test_mode"))) { + if (HapiSystemProperties.isUnitTestModeEnabled()) { throw new TimeoutException(Msg.code(2133) + myServiceName + " timed out after running for " + myStopWatch); } else { ourLog.error(myServiceName + " has run for {}", myStopWatch); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionUtil.java index 113c1ae0df0..62ee9e59278 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionUtil.java @@ -20,6 +20,7 @@ package ca.uhn.fhir.util; * #L% */ +import ca.uhn.fhir.system.HapiSystemProperties; import org.apache.commons.lang3.StringUtils; import java.io.InputStream; @@ -75,7 +76,7 @@ public class VersionUtil { ourBuildNumber = StringUtils.left(p.getProperty("hapifhir.buildnumber"), 10); ourBuildTime = p.getProperty("hapifhir.timestamp"); - if (System.getProperty("suppress_hapi_fhir_version_log") == null) { + if (!HapiSystemProperties.isSuppressHapiFhirVersionLogEnabled()) { String buildNumber = ourBuildNumber; if (isSnapshot()) { buildNumber = buildNumber + "/" + getBuildDate(); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java index fcef675e08c..95c43707c20 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.util; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.ConfigurationException; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.util.jar.DependencyLogFactory; @@ -1614,7 +1614,7 @@ public class XmlUtil { try { // Detect if we're running with the Android lib, and force repackaged Woodstox to be used Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLOutputFactory"); - System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); + System.setProperty(javax.xml.stream.XMLOutputFactory.class.getName(), com.ctc.wstx.stax.WstxOutputFactory.class.getName()); } catch (ClassNotFoundException e) { // ok } @@ -1708,7 +1708,7 @@ public class XmlUtil { try { // Detect if we're running with the Android lib, and force repackaged Woodstox to be used Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLInputFactory"); - System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory"); + System.setProperty(javax.xml.stream.XMLInputFactory.class.getName(), com.ctc.wstx.stax.WstxInputFactory.class.getName()); } catch (ClassNotFoundException e) { // ok } diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/TimeoutManagerTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/TimeoutManagerTest.java index 7d510432c86..0745cf914ad 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/TimeoutManagerTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/TimeoutManagerTest.java @@ -1,5 +1,6 @@ package ca.uhn.fhir.util; +import ca.uhn.fhir.system.HapiSystemProperties; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; @@ -101,7 +102,7 @@ class TimeoutManagerTest { @Test public void checkTimeout_errorThreadholdHitInUnitTest_throwsException() { // setup - System.setProperty("unit_test_mode", "true"); + HapiSystemProperties.enableUnitTestMode(); mySvc.addTimeForUnitTest(Duration.ofDays(20)); // execute try { diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java index 81e35cc9b4d..2798c377660 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java @@ -21,6 +21,7 @@ package ca.uhn.fhir.cli; */ import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.VersionUtil; import com.helger.commons.io.file.FileHelper; import org.apache.commons.cli.CommandLine; @@ -51,12 +52,11 @@ public abstract class BaseApp { protected static final org.slf4j.Logger ourLog; static final String LINESEP = System.getProperty("line.separator"); private static final String STACKFILTER_PATTERN = "%xEx{full, sun.reflect, org.junit, org.eclipse, java.lang.reflect.Method, org.springframework, org.hibernate, com.sun.proxy, org.attoparser, org.thymeleaf}"; - private static final String STACKFILTER_PATTERN_PROP = "log.stackfilter.pattern"; private static List ourCommands; private static boolean ourDebugMode; static { - System.setProperty(STACKFILTER_PATTERN_PROP, STACKFILTER_PATTERN); + HapiSystemProperties.setStackFilterPattern(STACKFILTER_PATTERN); LogbackUtil.loggingConfigOff(); // We don't use qualified names for loggers in CLI @@ -262,12 +262,12 @@ public abstract class BaseApp { myShutdownHookHasNotRun = true; runCleanupHookAndUnregister(); - if (!"true".equals(System.getProperty("test"))) { + if (!HapiSystemProperties.isTestModeEnabled()) { System.exit(0); } } catch (ParseException e) { - if (!"true".equals(System.getProperty("test"))) { + if (!HapiSystemProperties.isTestModeEnabled()) { LogbackUtil.loggingConfigOff(); } System.err.println("Invalid command options for command: " + command.getCommandName()); @@ -322,7 +322,7 @@ public abstract class BaseApp { private void exitDueToProblem(String theDescription) { - if ("true".equals(System.getProperty("test"))) { + if (HapiSystemProperties.isTestModeEnabled()) { throw new Error(Msg.code(1556) + theDescription); } else { System.exit(1); @@ -330,7 +330,7 @@ public abstract class BaseApp { } private void exitDueToException(Throwable e) { - if ("true".equals(System.getProperty("test"))) { + if (HapiSystemProperties.isTestModeEnabled()) { if (e instanceof CommandFailureException) { throw (CommandFailureException) e; } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java index 7e54c492b8f..b9195052b04 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java @@ -39,13 +39,17 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.SocketException; public class RunServerCommand extends BaseCommand { private static final String OPTION_DISABLE_REFERENTIAL_INTEGRITY = "disable-referential-integrity"; - private static final String OPTION_LOWMEM = "lowmem"; private static final String OPTION_ALLOW_EXTERNAL_REFS = "allow-external-refs"; private static final String OPTION_REUSE_SEARCH_RESULTS_MILLIS = "reuse-search-results-milliseconds"; private static final int DEFAULT_PORT = 8080; @@ -68,7 +72,6 @@ public class RunServerCommand extends BaseCommand { Options options = new Options(); addFhirVersionOption(options); options.addOption(OPTION_P, "port", true, "The port to listen on (default is " + DEFAULT_PORT + ")"); - options.addOption(null, OPTION_LOWMEM, false, "If this flag is set, the server will operate in low memory mode (some features disabled)"); options.addOption(null, OPTION_ALLOW_EXTERNAL_REFS, false, "If this flag is set, the server will allow resources to be persisted contaning external resource references"); options.addOption(null, OPTION_DISABLE_REFERENTIAL_INTEGRITY, false, "If this flag is set, the server will not enforce referential integrity"); @@ -94,11 +97,6 @@ public class RunServerCommand extends BaseCommand { myPort = parseOptionInteger(theCommandLine, OPTION_P, DEFAULT_PORT); - if (theCommandLine.hasOption(OPTION_LOWMEM)) { - ourLog.info("Running in low memory mode, some features disabled"); - System.setProperty(OPTION_LOWMEM, OPTION_LOWMEM); - } - if (theCommandLine.hasOption(OPTION_ALLOW_EXTERNAL_REFS)) { ourLog.info("Server is configured to allow external references"); ContextHolder.setAllowExternalRefs(true); diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java index de2b5966e31..6d721806910 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java @@ -28,6 +28,7 @@ import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.AttachmentUtil; import ca.uhn.fhir.util.FileUtil; import ca.uhn.fhir.util.ParametersUtil; @@ -215,7 +216,7 @@ public class UploadTerminologyCommand extends BaseRequestGeneratingCommand { ourLog.info("Beginning upload - This may take a while..."); - if (ourLog.isDebugEnabled() || "true".equals(System.getProperty("test"))) { + if (ourLog.isDebugEnabled() || HapiSystemProperties.isTestModeEnabled()) { ourLog.info("Submitting parameters: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inputParameters)); } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/BulkImportCommandIT.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/BulkImportCommandIT.java index 1f0b95bef93..c64103ed887 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/BulkImportCommandIT.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/BulkImportCommandIT.java @@ -10,6 +10,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.HttpClientExtension; import ca.uhn.fhir.test.utilities.server.RestfulServerExtension; import org.apache.commons.io.FileUtils; @@ -56,7 +57,7 @@ public class BulkImportCommandIT { private static final Logger ourLog = LoggerFactory.getLogger(BulkImportCommandIT.class); static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @RegisterExtension diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/CreatePackageCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/CreatePackageCommandTest.java index b58d0bb5f22..78bfabac245 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/CreatePackageCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/CreatePackageCommandTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.BaseTest; import com.google.common.base.Charsets; import com.google.common.io.Files; @@ -34,7 +35,7 @@ public class CreatePackageCommandTest extends BaseTest { private static final Logger ourLog = LoggerFactory.getLogger(CreatePackageCommandTest.class); static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } private File myWorkDirectory; diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandDstu3Test.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandDstu3Test.java index 19bce50564a..fa05927ebf3 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandDstu3Test.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandDstu3Test.java @@ -1,8 +1,9 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerDstu3Helper; +import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.FileUtils; @@ -38,7 +39,7 @@ public class ExportConceptMapToCsvCommandDstu3Test { private final String myVersion = "dstu3"; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @RegisterExtension diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandR4Test.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandR4Test.java index ee3edb77bf3..2f4bd84ddc1 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandR4Test.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommandR4Test.java @@ -1,8 +1,9 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerR4Helper; +import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.FileUtils; @@ -35,7 +36,7 @@ public class ExportConceptMapToCsvCommandR4Test { private static final String FILE = new File("./target/output_r4.csv").getAbsolutePath(); static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @RegisterExtension diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommandTest.java index a5722edaa56..35acb3dd998 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommandTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.jpa.migrate.DriverTypeEnum; import ca.uhn.fhir.jpa.migrate.JdbcUtils; +import ca.uhn.fhir.system.HapiSystemProperties; import com.google.common.base.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -37,7 +38,7 @@ public class HapiFlywayMigrateDatabaseCommandTest { public static final String DB_DIRECTORY = "target/h2_test"; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @Test diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandDstu3Test.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandDstu3Test.java index ef788640a94..ff0e5a38949 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandDstu3Test.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandDstu3Test.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.api.MethodOutcome; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerDstu3Helper; import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.TestUtil; @@ -40,7 +41,7 @@ public class ImportCsvToConceptMapCommandDstu3Test { private String myFile; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @RegisterExtension diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandR4Test.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandR4Test.java index d5806063b8f..82ca2e8302c 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandR4Test.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommandR4Test.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.api.MethodOutcome; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerR4Helper; import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.TestUtil; @@ -39,7 +40,7 @@ public class ImportCsvToConceptMapCommandR4Test { private static final String STATUS = "Active"; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } private final FhirContext myFhirContext = FhirContext.forR4(); diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java index 15d58b59617..366a23a7ffd 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.cli; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.provider.BaseJpaSystemProvider; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerR4Helper; import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.ParametersUtil; @@ -42,7 +43,7 @@ class ReindexTerminologyCommandTest { private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @BeforeEach diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java index 71e96eeebf7..0502e8c6858 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java @@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.term.UploadStatistics; import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.BaseRestServerHelper; import ca.uhn.fhir.test.utilities.RestServerDstu3Helper; import ca.uhn.fhir.test.utilities.RestServerR4Helper; @@ -50,8 +51,8 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; @@ -89,7 +90,7 @@ public class UploadTerminologyCommandTest { protected ArgumentCaptor> myDescriptorListCaptor; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } static Stream paramsProvider(){ diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java index b20037d4682..3accc9874e3 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java @@ -1,26 +1,15 @@ package ca.uhn.fhir.cli; +import ca.uhn.fhir.system.HapiSystemProperties; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.read.ListAppender; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.ParseException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - public class ValidateCommandTest { private final Logger ourLog = (Logger) LoggerFactory.getLogger(ValidateCommand.class); @@ -44,7 +33,7 @@ public class ValidateCommandTest { @BeforeEach public void before() { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @Test diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java index 970d045d0ca..af340b480ea 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java @@ -89,14 +89,7 @@ public class CommonConfig { extraProperties.put("hibernate.cache.use_structured_entries", "false"); extraProperties.put("hibernate.cache.use_minimal_puts", "false"); extraProperties.put("hibernate.search.backend.type", "lucene"); - -// extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName()); -// extraProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-filesystem"); -// extraProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_ROOT), "target/lucenefiles"); -// extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT"); -// if (System.getProperty("lowmem") != null) { - extraProperties.put(HibernateOrmMapperSettings.ENABLED, "false"); -// } + extraProperties.put(HibernateOrmMapperSettings.ENABLED, "false"); return extraProperties; } diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java index a25bcee752e..31ed9b6e20a 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java @@ -20,12 +20,12 @@ package ca.uhn.fhir.rest.client.impl; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.api.Pointcut; @@ -53,6 +53,7 @@ import ca.uhn.fhir.rest.client.method.IClientResponseHandlerHandlesBinary; import ca.uhn.fhir.rest.client.method.MethodUtil; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.BinaryUtil; import ca.uhn.fhir.util.OperationOutcomeUtil; import ca.uhn.fhir.util.XmlDetectionUtil; @@ -85,13 +86,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; public abstract class BaseClient implements IRestfulClient { - /** - * This property is used by unit tests - do not rely on it in production code - * as it may change at any time. If you want to capture responses in a reliable - * way in your own code, just use client interceptors - */ - public static final String HAPI_CLIENT_KEEPRESPONSES = "hapi.client.keepresponses"; - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseClient.class); private final IHttpClient myClient; @@ -118,7 +112,7 @@ public abstract class BaseClient implements IRestfulClient { * as it may change at any time. If you want to capture responses in a reliable * way in your own code, just use client interceptors */ - if ("true".equals(System.getProperty(HAPI_CLIENT_KEEPRESPONSES))) { + if (HapiSystemProperties.isHapiClientKeepResponsesEnabled()) { setKeepResponses(true); } diff --git a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java index a8cf61d1d26..a788d669735 100644 --- a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java +++ b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java @@ -20,9 +20,9 @@ package ca.uhn.hapi.converters.server; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.Interceptor; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.rest.api.Constants; @@ -45,7 +45,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.StringTokenizer; -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.defaultString; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; /** * This is an experimental interceptor! Use with caution as diff --git a/hapi-fhir-converter/src/test/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizerTest.java b/hapi-fhir-converter/src/test/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizerTest.java index bf40ae26df6..ed28c56cb25 100644 --- a/hapi-fhir-converter/src/test/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizerTest.java +++ b/hapi-fhir-converter/src/test/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizerTest.java @@ -4,10 +4,9 @@ import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.dstu2.composite.CodingDt; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.r4.model.Coding; -import org.hl7.fhir.r4.model.ValueSet; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; class VersionCanonicalizerTest { diff --git a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java index 8633b5682bd..40d7a62d37b 100644 --- a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java +++ b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java @@ -17,6 +17,7 @@ import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.JettyUtil; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; @@ -101,7 +102,7 @@ public class GenericJaxRsClientDstu3Test { ourCtx.setRestfulClientFactory(clientFactory); ourResponseCount = 0; - System.setProperty("hapi.client.keepresponses", "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String getPatientFeedWithOneResult() { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaBatch2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaBatch2Config.java index 8b6a40abe39..6f4b3565165 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaBatch2Config.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaBatch2Config.java @@ -26,6 +26,7 @@ import ca.uhn.fhir.batch2.coordinator.SynchronizedJobPersistenceWrapper; import ca.uhn.fhir.jpa.bulk.export.job.BulkExportJobConfig; import ca.uhn.fhir.jpa.dao.data.IBatch2JobInstanceRepository; import ca.uhn.fhir.jpa.dao.data.IBatch2WorkChunkRepository; +import ca.uhn.fhir.system.HapiSystemProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -49,7 +50,7 @@ public class JpaBatch2Config extends BaseBatch2Config { IJobPersistence retVal = batch2JobInstancePersister(theJobInstanceRepository, theWorkChunkRepository, theTransactionManager); // Avoid H2 synchronization issues caused by // https://github.com/h2database/h2database/issues/1808 - if ("true".equals(System.getProperty("unit_test_mode"))) { + if (HapiSystemProperties.isUnitTestModeEnabled()) { retVal = new SynchronizedJobPersistenceWrapper(retVal); } return retVal; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java index 25c2e33c59f..4b856422e97 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java @@ -35,7 +35,6 @@ import ca.uhn.fhir.jpa.entity.Batch2JobInstanceEntity; import ca.uhn.fhir.jpa.entity.Batch2WorkChunkEntity; import ca.uhn.fhir.jpa.util.JobInstanceUtil; import ca.uhn.fhir.model.api.PagingIterator; -import ca.uhn.fhir.narrative.BaseThymeleafNarrativeGenerator; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java index bf3a51b4bac..e192a468c55 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java @@ -62,7 +62,6 @@ import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl; import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; import ca.uhn.fhir.jpa.partition.RequestPartitionHelperSvc; import ca.uhn.fhir.jpa.provider.DiffProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.ProcessMessageProvider; import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaPersistedResourceValidationSupport.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaPersistedResourceValidationSupport.java index 8e5a9088583..a0043840426 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaPersistedResourceValidationSupport.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaPersistedResourceValidationSupport.java @@ -35,9 +35,9 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.UriParam; -import org.apache.commons.lang3.Validate; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.CodeSystem; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoValueSet.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoValueSet.java index f476fe54dc4..02ffffc103f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoValueSet.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoValueSet.java @@ -36,7 +36,6 @@ import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; -import ca.uhn.fhir.util.ParametersUtil; import ca.uhn.hapi.converters.canonical.VersionCanonicalizer; import org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService; import org.hl7.fhir.instance.model.api.IBaseCoding; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Search.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Search.java index 157ec2ce8f5..998b11195cf 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Search.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Search.java @@ -3,11 +3,11 @@ package ca.uhn.fhir.jpa.entity; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.jpa.util.QueryParameterUtils; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.HistorySearchStyleEnum; import ca.uhn.fhir.rest.server.util.ICachedSearchDetails; +import ca.uhn.fhir.system.HapiSystemProperties; import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.hibernate.annotations.OptimisticLock; @@ -237,7 +237,7 @@ public class Search implements ICachedSearchDetails, Serializable { public void setFailureMessage(String theFailureMessage) { myFailureMessage = left(theFailureMessage, FAILURE_MESSAGE_LENGTH); - if (System.getProperty(QueryParameterUtils.UNIT_TEST_CAPTURE_STACK) != null) { + if (HapiSystemProperties.isUnitTestCaptureStackEnabled()) { myFailureMessage = theFailureMessage; } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java index e7c3932fad7..2cb573767e6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.partition; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.dao.data.IPartitionDao; import ca.uhn.fhir.jpa.entity.PartitionEntity; import ca.uhn.fhir.jpa.model.config.PartitionSettings; @@ -29,20 +29,20 @@ import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.apache.commons.lang3.Validate; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; import ca.uhn.fhir.sl.cache.CacheFactory; import ca.uhn.fhir.sl.cache.CacheLoader; import ca.uhn.fhir.sl.cache.LoadingCache; +import org.apache.commons.lang3.Validate; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.PostConstruct; -import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderCodeSystem.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderCodeSystem.java index 1fef5bc1d46..d7171869b33 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderCodeSystem.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderCodeSystem.java @@ -44,7 +44,6 @@ import javax.servlet.http.HttpServletRequest; import java.util.List; import static ca.uhn.fhir.jpa.provider.ValueSetOperationProvider.toValidateCodeResult; -import static ca.uhn.fhir.util.DatatypeUtil.toStringValue; import static org.apache.commons.lang3.StringUtils.isNotBlank; public abstract class BaseJpaResourceProviderCodeSystem extends BaseJpaResourceProvider { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaSystemProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaSystemProvider.java index 0f0287dbce8..67f8340d241 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaSystemProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaSystemProvider.java @@ -36,9 +36,7 @@ import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.hl7.fhir.r4.model.Meta; -import javax.servlet.http.HttpServletRequest; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java index 68f784bb3df..57b0f1984b9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java @@ -53,7 +53,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import javax.servlet.http.HttpServletRequest; -import static ca.uhn.fhir.util.DatatypeUtil.toStringValue; import static org.apache.commons.lang3.StringUtils.isNotBlank; public class ValueSetOperationProvider extends BaseJpaProvider { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java index c59fa77ec29..e2770343ae7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IDao; -import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; import ca.uhn.fhir.jpa.dao.IResultIterator; import ca.uhn.fhir.jpa.dao.ISearchBuilder; import ca.uhn.fhir.jpa.dao.SearchBuilderFactory; @@ -36,7 +35,6 @@ import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.interceptor.JpaPreResourceAccessDetails; import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; -import ca.uhn.fhir.jpa.search.ExceptionService; import ca.uhn.fhir.jpa.search.SearchStrategyFactory; import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc; import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc; @@ -51,6 +49,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.AsyncUtil; import ca.uhn.fhir.util.StopWatch; import co.elastic.apm.api.ElasticApm; @@ -78,7 +77,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import static ca.uhn.fhir.jpa.util.QueryParameterUtils.UNIT_TEST_CAPTURE_STACK; import static ca.uhn.fhir.jpa.util.SearchParameterMapCalculator.isWantCount; import static ca.uhn.fhir.jpa.util.SearchParameterMapCalculator.isWantOnlyCount; import static java.util.Objects.nonNull; @@ -483,7 +481,7 @@ public class SearchTask implements Callable { failureCode = ((BaseServerResponseException) t).getStatusCode(); } - if (System.getProperty(UNIT_TEST_CAPTURE_STACK) != null) { + if (HapiSystemProperties.isUnitTestCaptureStackEnabled()) { failureMessage += "\nStack\n" + ExceptionUtils.getStackTrace(rootCause); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchCacheSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchCacheSvcImpl.java index 69ec025fed6..22061109e02 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchCacheSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchCacheSvcImpl.java @@ -27,8 +27,8 @@ import ca.uhn.fhir.jpa.dao.data.ISearchDao; import ca.uhn.fhir.jpa.dao.data.ISearchIncludeDao; import ca.uhn.fhir.jpa.dao.data.ISearchResultDao; import ca.uhn.fhir.jpa.entity.Search; -import ca.uhn.fhir.jpa.entity.SearchInclude; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; +import ca.uhn.fhir.system.HapiSystemProperties; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import org.apache.commons.lang3.Validate; @@ -42,9 +42,9 @@ import org.springframework.data.domain.Slice; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; -import org.springframework.transaction.annotation.Transactional; import java.time.Instant; import java.util.Collection; import java.util.Date; @@ -202,7 +202,7 @@ public class DatabaseSearchCacheSvcImpl implements ISearchCacheSvc { int count = toDelete.getContent().size(); if (count > 0) { - if (ourLog.isDebugEnabled() || "true".equalsIgnoreCase(System.getProperty("test"))) { + if (ourLog.isDebugEnabled() || HapiSystemProperties.isTestModeEnabled()) { Long total = tt.execute(t -> mySearchDao.count()); ourLog.debug("Deleted {} searches, {} remaining", count, total); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java index 8180af756f9..ee3b2bd3419 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java @@ -69,7 +69,6 @@ import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; public class QueryParameterUtils { private static final Logger ourLog = LoggerFactory.getLogger(QueryParameterUtils.class); public static final int DEFAULT_SYNC_SIZE = 250; - public static final String UNIT_TEST_CAPTURE_STACK = "unit_test_capture_stack"; private static final BidiMap ourCompareOperationToParamPrefix; diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java index 763439ae28c..8504bc880b8 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java @@ -57,7 +57,6 @@ import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.DateTimeType; import org.hl7.fhir.r4.model.DecimalType; import org.hl7.fhir.r4.model.DiagnosticReport; diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java index 24249c79652..111204b4c12 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java @@ -23,8 +23,6 @@ import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.ValueSet; import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent; import org.junit.jupiter.api.AfterAll; diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index 1e26e22eefd..9853a848410 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -32,7 +32,6 @@ import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParamQuantity; import ca.uhn.fhir.jpa.model.entity.ModelConfig; -import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamCoords; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber; diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java index d70674b3895..6db51c06cd4 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java @@ -24,9 +24,9 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; -import com.google.common.annotations.VisibleForTesting; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import com.google.common.annotations.VisibleForTesting; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java index c365ca6860f..b124b9970a9 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java @@ -24,9 +24,9 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; -import com.google.common.annotations.VisibleForTesting; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import com.google.common.annotations.VisibleForTesting; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/retry/Retrier.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/retry/Retrier.java index 2fb9a5e3e81..ee6e17138d6 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/retry/Retrier.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/retry/Retrier.java @@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.searchparam.retry; * #L% */ +import ca.uhn.fhir.system.HapiSystemProperties; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; @@ -73,7 +74,7 @@ public class Retrier { @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { super.onError(context, callback, throwable); - if (throwable instanceof NullPointerException || throwable instanceof UnsupportedOperationException || "true".equals(System.getProperty("unit_test_mode"))) { + if (throwable instanceof NullPointerException || throwable instanceof UnsupportedOperationException || HapiSystemProperties.isUnitTestModeEnabled()) { ourLog.error("Retry failure {}/{}: {}", context.getRetryCount(), theMaxRetries, throwable.getMessage(), throwable); } else { ourLog.error("Retry failure {}/{}: {}", context.getRetryCount(), theMaxRetries, throwable.toString()); diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java index 0e4f8e079ac..7a75d48a9d0 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java @@ -5,17 +5,14 @@ import ca.uhn.fhir.interceptor.executor.InterceptorService; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.searchparam.config.SearchParamConfig; import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl; -import ca.uhn.fhir.jpa.subscription.channel.api.ChannelConsumerSettings; -import ca.uhn.fhir.jpa.subscription.channel.api.ChannelProducerSettings; import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory; -import ca.uhn.fhir.jpa.subscription.channel.api.IChannelProducer; -import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver; import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannelFactory; import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer; import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory; import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig; import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSearchParamProvider; import ca.uhn.fhir.model.primitive.IdDt; +import ca.uhn.fhir.system.HapiSystemProperties; import org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -37,7 +34,7 @@ import java.util.Collections; public abstract class BaseSubscriptionTest { static { - System.setProperty("unit_test_mode", "true"); + HapiSystemProperties.enableUnitTestMode(); } @Autowired diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java index 52c263ea039..9e110f92610 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java @@ -55,7 +55,6 @@ import ca.uhn.fhir.model.dstu2.resource.Substance; import ca.uhn.fhir.model.dstu2.resource.ValueSet; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; -import ca.uhn.fhir.test.utilities.server.SpringContextGrabbingTestExecutionListener; import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.AfterEach; @@ -65,7 +64,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchCustomSearchParamTest.java index d23a07ae335..d2f176c97e3 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchCustomSearchParamTest.java @@ -37,13 +37,11 @@ import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.simplejavamail.internal.util.ListUtil; import java.util.List; import java.util.stream.Collectors; diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java index 013f8bf72f4..1700d1adc54 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.dao.dstu2; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; -import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem; import ca.uhn.fhir.jpa.provider.ResourceProviderDstu2ValueSetTest; import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt; @@ -21,14 +20,10 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.stringContainsInOrder; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index 8fd7ab5b060..79fc1f6b49d 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -112,7 +112,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.*; +import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.assertDoesNotContainAnyOf; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java index de8ed5ae807..26b16537848 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java @@ -23,8 +23,6 @@ import java.util.stream.Collectors; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.stringContainsInOrder; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java index 2d103fc3f8f..77fb47f1d45 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java @@ -19,7 +19,6 @@ import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc; import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.util.BaseIterator; -import ca.uhn.fhir.jpa.util.QueryParameterUtils; import ca.uhn.fhir.rest.api.CacheControlDirective; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.RequestDetails; @@ -28,6 +27,7 @@ import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.IPagingProvider; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; +import ca.uhn.fhir.system.HapiSystemProperties; import org.hamcrest.Matchers; import org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.AfterEach; @@ -110,13 +110,13 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ @AfterEach public void after() { - System.clearProperty(QueryParameterUtils.UNIT_TEST_CAPTURE_STACK); + HapiSystemProperties.disableUnitTestCaptureStack(); super.after(); } @BeforeEach public void before() { - System.setProperty(QueryParameterUtils.UNIT_TEST_CAPTURE_STACK, "true"); + HapiSystemProperties.enableUnitTestCaptureStack(); myCurrentSearch = null; diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java index 1d465eedcd8..518668a848f 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.provider.dstu3; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.ProcessMessageProvider; import ca.uhn.fhir.jpa.provider.ServerConfiguration; import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; +import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/batch2/Batch2CoordinatorIT.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/batch2/Batch2CoordinatorIT.java index c13e09daece..1ae42a58384 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/batch2/Batch2CoordinatorIT.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/batch2/Batch2CoordinatorIT.java @@ -39,10 +39,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Sort; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.support.ExecutorChannelInterceptor; import javax.annotation.Nonnull; import java.util.ArrayList; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTest.java index de444eba863..2097c6d1f2c 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTest.java @@ -59,7 +59,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTestAnyMode.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTestAnyMode.java index 600fdb4ce8c..62028176ede 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTestAnyMode.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkExportUseCaseTestAnyMode.java @@ -6,11 +6,6 @@ import org.junit.jupiter.api.BeforeEach; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.awaitility.Awaitility.await; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; - public class BulkExportUseCaseTestAnyMode extends BulkExportUseCaseTest { private static final Logger ourLog = LoggerFactory.getLogger(BulkExportUseCaseTestAnyMode.class); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java index ef3646d3543..64681ca6ef2 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java @@ -40,11 +40,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import javax.persistence.EntityManager; import java.util.List; - -import java.util.List; - -import java.util.List; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java index 7d279e8cbeb..2866978ff6b 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.test.BaseJpaR4Test; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.TokenParam; +import ca.uhn.fhir.system.HapiTestSystemProperties; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.InstantType; @@ -38,12 +39,12 @@ public class FhirResourceDaoR4MetaTest extends BaseJpaR4Test { // TODO testConcurrentAddTag() can deadlock if we don't increase this @BeforeAll public static void beforeAll() { - System.setProperty("unlimited_db_connection", "true"); + HapiTestSystemProperties.enableUnlimitedDbConnections(); } @AfterAll public static void afterAll() { - System.clearProperty("unlimited_db_connection"); + HapiTestSystemProperties.disableUnlimitedDbConnections(); } /** diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java index 9f61b107e07..36f19ffbcea 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java @@ -173,7 +173,7 @@ import static ca.uhn.fhir.rest.param.ParamPrefixEnum.GREATERTHAN_OR_EQUALS; import static ca.uhn.fhir.rest.param.ParamPrefixEnum.LESSTHAN; import static ca.uhn.fhir.rest.param.ParamPrefixEnum.LESSTHAN_OR_EQUALS; import static ca.uhn.fhir.rest.param.ParamPrefixEnum.NOT_EQUAL; -import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.*; +import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.assertDoesNotContainAnyOf; import static org.apache.commons.lang3.StringUtils.countMatches; import static org.apache.commons.lang3.StringUtils.leftPad; import static org.hamcrest.CoreMatchers.is; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithHSearchDisabledTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithHSearchDisabledTest.java index bdebc6c74dd..52c56951080 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithHSearchDisabledTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithHSearchDisabledTest.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; @@ -27,19 +26,9 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.model.AllergyIntolerance; -import org.hl7.fhir.r4.model.Appointment; -import org.hl7.fhir.r4.model.AuditEvent; import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.CarePlan; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeType; -import org.hl7.fhir.r4.model.CompartmentDefinition; -import org.hl7.fhir.r4.model.ConceptMap; -import org.hl7.fhir.r4.model.Condition; -import org.hl7.fhir.r4.model.Device; -import org.hl7.fhir.r4.model.DiagnosticReport; -import org.hl7.fhir.r4.model.Encounter; import org.hl7.fhir.r4.model.Meta; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Organization; @@ -56,7 +45,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.EntityManager; import java.io.IOException; import java.util.List; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java index b8ec548e4cd..72c8c25b83a 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java @@ -157,7 +157,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.reset; @SuppressWarnings({"unchecked", "deprecation", "Duplicates"}) public class FhirResourceDaoR4Test extends BaseJpaR4Test { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java index bf460345994..f0acc71253c 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java @@ -31,7 +31,6 @@ import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Resource; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -57,7 +56,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; public class FhirResourceDaoR4UpdateTest extends BaseJpaR4Test { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index 9010e2befa5..a4a4bd874b1 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -108,7 +108,6 @@ import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.in; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.not; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java index 19822076c3f..0a8903407ad 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java @@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.test.BaseJpaTest; import ca.uhn.fhir.jpa.test.config.TestHSearchAddInConfig; import ca.uhn.fhir.jpa.test.config.TestR4Config; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.util.StopWatch; import org.apache.commons.lang3.Validate; import org.hl7.fhir.r4.model.Bundle; @@ -111,14 +112,14 @@ public class SyntheaPerfTest extends BaseJpaTest { @BeforeAll public static void beforeAll() { - System.setProperty("unlimited_db_connection", "true"); - System.setProperty("mass_ingestion_mode", "true"); + HapiTestSystemProperties.enableUnlimitedDbConnections(); + HapiTestSystemProperties.enableMassIngestionMode(); } @AfterAll public static void afterAll() { - System.clearProperty("unlimited_db_connection"); - System.clearProperty("mass_ingestion_mode"); + HapiTestSystemProperties.disableUnlimitedDbConnections(); + HapiTestSystemProperties.disableMassIngestionMode(); } private class Uploader { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java index 0eeb4d53cda..9626d2b15ee 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java @@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; +import static ca.uhn.fhir.rest.api.Constants.PARAM_CONSENT; import static ca.uhn.fhir.rest.api.Constants.PARAM_CONSENT_PATIENT_REFERENCE; import static ca.uhn.fhir.rest.api.Constants.PARAM_CONSENT_PERFORMER_REFERENCE; import static ca.uhn.fhir.rest.api.Constants.PARAM_MEMBER_PATIENT; @@ -40,7 +41,6 @@ import static ca.uhn.fhir.rest.api.Constants.PARAM_MEMBER_PATIENT_BIRTHDATE; import static ca.uhn.fhir.rest.api.Constants.PARAM_MEMBER_PATIENT_NAME; import static ca.uhn.fhir.rest.api.Constants.PARAM_NEW_COVERAGE; import static ca.uhn.fhir.rest.api.Constants.PARAM_OLD_COVERAGE; -import static ca.uhn.fhir.rest.api.Constants.PARAM_CONSENT; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java index b371c20024c..7630a731edf 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java @@ -8,7 +8,6 @@ import ca.uhn.fhir.jpa.test.config.TestR4Config; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.apache.commons.io.IOUtils; -import org.apache.derby.iapi.error.ThreadDump; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.hl7.fhir.r4.model.Bundle; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetHSearchDisabledTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetHSearchDisabledTest.java index b11d08b96f3..67dc5a72e85 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetHSearchDisabledTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetHSearchDisabledTest.java @@ -4,7 +4,6 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet; import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig; import ca.uhn.fhir.jpa.test.BaseJpaTest; @@ -23,8 +22,6 @@ import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.ValueSet; import org.junit.jupiter.api.BeforeEach; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java index 9f553c6c7ec..76617ec98f0 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java @@ -15,7 +15,6 @@ import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.SearchParameter; import org.hl7.fhir.r4.model.StructureDefinition; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java index 30b2c22735f..4c0ce9ac99a 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java @@ -23,7 +23,6 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.in; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java index de1beb2b2a8..c8cbdb78936 100755 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java @@ -29,7 +29,6 @@ import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; import java.util.ArrayList; import java.util.Arrays; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java index e8059b1eae9..fc982df6895 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java @@ -9,7 +9,6 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystem; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermValueSet; -import ca.uhn.fhir.jpa.term.api.TermCodeSystemDeleteJobSvc; import ca.uhn.fhir.jpa.test.Batch2JobHelper; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import org.hl7.fhir.instance.model.api.IIdType; @@ -34,7 +33,6 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.concurrent.TimeUnit; import static ca.uhn.fhir.batch2.jobs.termcodesystem.TermCodeSystemJobConfig.TERM_CODE_SYSTEM_VERSION_DELETE_JOB_NAME; import static org.awaitility.Awaitility.await; diff --git a/hapi-fhir-jpaserver-test-r4b/src/test/java/ca/uhn/fhir/jpa/dao/r4b/BaseJpaR4BTest.java b/hapi-fhir-jpaserver-test-r4b/src/test/java/ca/uhn/fhir/jpa/dao/r4b/BaseJpaR4BTest.java index 9fb11dd49e1..2641e00821f 100644 --- a/hapi-fhir-jpaserver-test-r4b/src/test/java/ca/uhn/fhir/jpa/dao/r4b/BaseJpaR4BTest.java +++ b/hapi-fhir-jpaserver-test-r4b/src/test/java/ca/uhn/fhir/jpa/dao/r4b/BaseJpaR4BTest.java @@ -76,8 +76,6 @@ import org.hl7.fhir.r4b.model.Bundle; import org.hl7.fhir.r4b.model.CarePlan; import org.hl7.fhir.r4b.model.ChargeItem; import org.hl7.fhir.r4b.model.CodeSystem; -import org.hl7.fhir.r4b.model.CodeableConcept; -import org.hl7.fhir.r4b.model.Coding; import org.hl7.fhir.r4b.model.Communication; import org.hl7.fhir.r4b.model.CommunicationRequest; import org.hl7.fhir.r4b.model.CompartmentDefinition; diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java index 1209d6fcedd..b304c94ea56 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java @@ -53,9 +53,9 @@ import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.search.warm.ICacheWarmingSvc; import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl; import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry; -import ca.uhn.fhir.jpa.term.TermReadSvcImpl; import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl; import ca.uhn.fhir.jpa.term.TermDeferredStorageSvcImpl; +import ca.uhn.fhir.jpa.term.TermReadSvcImpl; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; @@ -85,8 +85,6 @@ import org.hl7.fhir.r5.model.CarePlan; import org.hl7.fhir.r5.model.ChargeItem; import org.hl7.fhir.r5.model.ClinicalUseDefinition; import org.hl7.fhir.r5.model.CodeSystem; -import org.hl7.fhir.r5.model.CodeableConcept; -import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.Communication; import org.hl7.fhir.r5.model.CommunicationRequest; import org.hl7.fhir.r5.model.CompartmentDefinition; diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/BaseResourceProviderR5Test.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/BaseResourceProviderR5Test.java index 2725a850872..240ac960ce2 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/BaseResourceProviderR5Test.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/BaseResourceProviderR5Test.java @@ -6,13 +6,13 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider; import ca.uhn.fhir.jpa.dao.r5.BaseJpaR5Test; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.DiffProvider; import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.ProcessMessageProvider; import ca.uhn.fhir.jpa.provider.ServerConfiguration; import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; +import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java index aea22a39e09..2ac011157cc 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java @@ -35,7 +35,6 @@ import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; -import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor; import ca.uhn.fhir.test.utilities.HttpClientExtension; import ca.uhn.fhir.test.utilities.server.RestfulServerConfigurerExtension; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java index ee40ec8069b..98e047c4ac5 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; import ca.uhn.fhir.jpa.dao.data.IPartitionDao; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; import ca.uhn.fhir.jpa.provider.DiffProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemDeleteJobSvcWithUniTestFailures.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemDeleteJobSvcWithUniTestFailures.java index 6667050bf07..7f72cf3da5e 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemDeleteJobSvcWithUniTestFailures.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemDeleteJobSvcWithUniTestFailures.java @@ -24,7 +24,6 @@ import ca.uhn.fhir.jpa.term.api.ITermCodeSystemDeleteJobSvc; import ca.uhn.fhir.jpa.term.api.TermCodeSystemDeleteJobSvc; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.lang3.Validate; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java index 6d625ed8f04..00d54d7925a 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java @@ -102,7 +102,6 @@ import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.BasePagingProvider; -import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; import ca.uhn.fhir.test.utilities.ITestDataBuilder; import ca.uhn.fhir.util.UrlUtil; @@ -199,7 +198,6 @@ import org.springframework.transaction.PlatformTransactionManager; import javax.persistence.EntityManager; import java.io.IOException; import java.util.ArrayList; -import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -210,9 +208,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.mock; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestR4Config.class}) diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java index 012a6ec4540..54e5f3538bc 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java @@ -72,12 +72,12 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader; import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.MemoryCacheService; -import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.BaseTest; import ca.uhn.fhir.test.utilities.LoggingExtension; import ca.uhn.fhir.test.utilities.ProxyUtil; @@ -163,9 +163,9 @@ public abstract class BaseJpaTest extends BaseTest { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class); static { - System.setProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS, "1000"); - System.setProperty("test", "true"); - System.setProperty("unit_test_mode", "true"); + HapiSystemProperties.setTestValidationResourceCachesMs(1000); + HapiSystemProperties.enableTestMode(); + HapiSystemProperties.enableUnitTestMode(); TestUtil.setShouldRandomizeTimezones(false); } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java index d716e03a0fc..491dee780e0 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java @@ -61,8 +61,6 @@ import org.hibernate.search.mapper.orm.common.EntityReference; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.ValueSet; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu2Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu2Config.java index ab003ab9359..9db1aa1633b 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu2Config.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu2Config.java @@ -30,6 +30,7 @@ import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.validation.IInstanceValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.ThreadQueryCountHolder; @@ -76,7 +77,7 @@ public class TestDstu2Config { */ ourMaxThreads = (int) (Math.random() * 6.0) + 2; - if ("true".equals(System.getProperty("single_db_connection"))) { + if (HapiTestSystemProperties.isSingleDbConnectionEnabled()) { ourMaxThreads = 1; } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu3Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu3Config.java index eca84dc9e04..aca8a134df5 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu3Config.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestDstu3Config.java @@ -26,17 +26,16 @@ import ca.uhn.fhir.jpa.batch2.JpaBatch2Config; import ca.uhn.fhir.jpa.config.HapiJpaConfig; import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config; import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; -import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl; import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl; import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; -import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.mail.IMailSvc; import ca.uhn.fhir.rest.server.mail.MailConfig; import ca.uhn.fhir.rest.server.mail.MailSvc; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; @@ -141,7 +140,7 @@ public class TestDstu3Config { */ int maxThreads = (int) (Math.random() * 6.0) + 2; - if ("true".equals(System.getProperty("single_db_connection"))) { + if (HapiTestSystemProperties.isSingleDbConnectionEnabled()) { maxThreads = 1; } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestJPAConfig.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestJPAConfig.java index 0a3c5ce1fee..d432c92e8d4 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestJPAConfig.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestJPAConfig.java @@ -36,10 +36,10 @@ import ca.uhn.fhir.jpa.subscription.match.deliver.resthook.SubscriptionDeliverin import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig; import ca.uhn.fhir.jpa.term.TermCodeSystemDeleteJobSvcWithUniTestFailures; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemDeleteJobSvc; -import ca.uhn.fhir.jpa.term.api.TermCodeSystemDeleteJobSvc; import ca.uhn.fhir.jpa.test.Batch2JobHelper; import ca.uhn.fhir.jpa.test.util.StoppableSubscriptionDeliveringRestHookSubscriber; import ca.uhn.fhir.jpa.test.util.SubscriptionTestUtil; +import ca.uhn.fhir.system.HapiTestSystemProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -62,7 +62,7 @@ public class TestJPAConfig { public DaoConfig daoConfig() { DaoConfig retVal = new DaoConfig(); - if ("true".equals(System.getProperty("mass_ingestion_mode"))) { + if (HapiTestSystemProperties.isMassIngestionModeEnabled()) { retVal.setMassIngestionMode(true); } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4BConfig.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4BConfig.java index e866d9a9e4e..a8ceb0822ac 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4BConfig.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4BConfig.java @@ -26,13 +26,13 @@ import ca.uhn.fhir.jpa.batch2.JpaBatch2Config; import ca.uhn.fhir.jpa.binary.api.IBinaryStorageSvc; import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; import ca.uhn.fhir.jpa.config.HapiJpaConfig; -import ca.uhn.fhir.jpa.config.r4.JpaR4Config; import ca.uhn.fhir.jpa.config.r4b.JpaR4BConfig; import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; @@ -83,10 +83,10 @@ public class TestR4BConfig { if (ourMaxThreads == null) { ourMaxThreads = (int) (Math.random() * 6.0) + 3; - if ("true".equals(System.getProperty("single_db_connection"))) { + if (HapiTestSystemProperties.isSingleDbConnectionEnabled()) { ourMaxThreads = 1; } - if ("true".equals(System.getProperty("unlimited_db_connection"))) { + if (HapiTestSystemProperties.isUnlimitedDbConnectionsEnabled()) { ourMaxThreads = 100; } } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4Config.java index dbfcecc4e51..8c5f43d4cfe 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4Config.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR4Config.java @@ -32,6 +32,7 @@ import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; @@ -82,10 +83,10 @@ public class TestR4Config { if (ourMaxThreads == null) { ourMaxThreads = (int) (Math.random() * 6.0) + 3; - if ("true".equals(System.getProperty("single_db_connection"))) { + if (HapiTestSystemProperties.isSingleDbConnectionEnabled()) { ourMaxThreads = 1; } - if ("true".equals(System.getProperty("unlimited_db_connection"))) { + if (HapiTestSystemProperties.isUnlimitedDbConnectionsEnabled()) { ourMaxThreads = 100; } } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR5Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR5Config.java index 2e53849c9fa..76cc0cd24b0 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR5Config.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestR5Config.java @@ -32,6 +32,7 @@ import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; @@ -78,7 +79,7 @@ public class TestR5Config { if (ourMaxThreads == null) { ourMaxThreads = (int) (Math.random() * 6.0) + 2; - if ("true".equals(System.getProperty("single_db_connection"))) { + if (HapiTestSystemProperties.isSingleDbConnectionEnabled()) { ourMaxThreads = 1; } diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/DaoConfigTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/DaoConfigTest.java index ea889b06954..ca962fafd09 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/DaoConfigTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/DaoConfigTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; +import ca.uhn.fhir.system.HapiSystemProperties; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -37,9 +38,9 @@ public class DaoConfigTest { @Test public void testDisableStatusBasedReindexUsingSystemProperty() { assertEquals(false, new DaoConfig().isStatusBasedReindexingDisabled()); - System.setProperty(DaoConfig.DISABLE_STATUS_BASED_REINDEX, "true"); + HapiSystemProperties.disableStatusBasedReindex(); assertEquals(true, new DaoConfig().isStatusBasedReindexingDisabled()); - System.clearProperty(DaoConfig.DISABLE_STATUS_BASED_REINDEX); + HapiSystemProperties.enableStatusBasedReindex(); } } diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java index e78af457bae..1a8877d9ccc 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java @@ -19,6 +19,7 @@ import ca.uhn.fhir.jpa.term.loinc.LoincMapToHandler; import ca.uhn.fhir.jpa.test.BaseJpaTest; import ca.uhn.fhir.jpa.test.config.TestHSearchAddInConfig; import ca.uhn.fhir.jpa.test.config.TestR4Config; +import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.util.StopWatch; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; @@ -162,7 +163,7 @@ public class LoincFullLoadR4SandboxIT extends BaseJpaTest { ); static { - System.setProperty("unlimited_db_connection", "true"); + HapiTestSystemProperties.enableUnlimitedDbConnections(); } // ----------------------------------------------------------------------------------------- diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java index 0a1ce0710ff..1cf2d86b133 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java @@ -1,19 +1,18 @@ package ca.uhn.fhirtest; import ca.uhn.fhir.batch2.jobs.reindex.ReindexProvider; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.IValidationSupport; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider; import ca.uhn.fhir.jpa.delete.ThreadSafeResourceDeleterSvc; +import ca.uhn.fhir.jpa.graphql.GraphQLProvider; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; import ca.uhn.fhir.jpa.provider.DiffProvider; -import ca.uhn.fhir.jpa.graphql.GraphQLProvider; -import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProvider; @@ -21,11 +20,10 @@ import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; -import ca.uhn.fhir.rest.openapi.OpenApiInterceptor; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.rest.api.EncodingEnum; +import ca.uhn.fhir.rest.openapi.OpenApiInterceptor; import ca.uhn.fhir.rest.server.ETagSupportEnum; import ca.uhn.fhir.rest.server.ElementsSupportEnum; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; @@ -36,6 +34,7 @@ import ca.uhn.fhir.rest.server.interceptor.FhirPathFilterInterceptor; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhirtest.config.SqlCaptureInterceptor; import ca.uhn.fhirtest.config.TestDstu2Config; import ca.uhn.fhirtest.config.TestDstu3Config; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index 86b69cfb506..c4d595d4314 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -56,7 +56,6 @@ import ca.uhn.fhir.rest.server.interceptor.ExceptionHandlingInterceptor; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.method.BaseMethodBinding; import ca.uhn.fhir.rest.server.method.ConformanceMethodBinding; -import ca.uhn.fhir.rest.server.method.BaseMethodBinding; import ca.uhn.fhir.rest.server.method.MethodMatchEnum; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.tenant.ITenantIdentificationStrategy; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java index a284ea7b1c7..2e86dbe7244 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java @@ -1,9 +1,9 @@ package ca.uhn.fhir.rest.server.method; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.model.api.IResource; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java index 58e9d670876..90bd81ff8ba 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java @@ -39,6 +39,7 @@ import ca.uhn.fhir.rest.server.SimpleBundleProvider; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import ca.uhn.fhir.system.HapiSystemProperties; import org.hl7.fhir.instance.model.api.IBaseConformance; import javax.annotation.Nonnull; @@ -136,7 +137,7 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding conf = null; else { conf = myCachedResponse.get(); - if ("true".equals(System.getProperty("test"))) { + if (HapiSystemProperties.isTestModeEnabled()) { conf = null; } if (conf != null) { diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java index a82ae771244..63d9c074bdf 100644 --- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java +++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.migrate.dao.HapiMigrationDao; import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask; import ca.uhn.fhir.jpa.migrate.taskdef.InitializeSchemaTask; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.StopWatch; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang3.Validate; @@ -171,7 +172,7 @@ public class HapiMigrator { } public void addTasks(Iterable theMigrationTasks) { - if ("true".equals(System.getProperty("unit_test_mode"))) { + if (HapiSystemProperties.isUnitTestModeEnabled()) { // Tests only need to initialize the schemas. No need to run all the migrations for every test. for (BaseTask task : theMigrationTasks) { if (task instanceof InitializeSchemaTask) { diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java index 8c6a213fb04..fcf7017fcb1 100644 --- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java +++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java @@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.migrate.taskdef; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.migrate.DriverTypeEnum; import ca.uhn.fhir.jpa.migrate.HapiMigrationException; +import ca.uhn.fhir.system.HapiSystemProperties; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -187,7 +188,7 @@ public abstract class BaseTask { jdbcTemplate.setQueryTimeout(0); try { int changesCount = jdbcTemplate.update(theSql, theArguments); - if (!"true".equals(System.getProperty("unit_test_mode"))) { + if (!HapiSystemProperties.isUnitTestModeEnabled()) { logInfo(ourLog, "SQL \"{}\" returned {}", theSql, changesCount); } return changesCount; diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java index d512e8c79e0..bcb7bf0682a 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java @@ -26,12 +26,11 @@ import ca.uhn.fhir.batch2.api.JobExecutionFailedException; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.api.VoidModel; -import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; +import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; import ca.uhn.fhir.batch2.jobs.models.Id; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.bulk.export.api.IBulkExportProcessor; import ca.uhn.fhir.jpa.bulk.export.model.ExportPIDIteratorParameters; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/BulkExportJobParametersValidatorTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/BulkExportJobParametersValidatorTest.java index 16179fda782..9da414afa05 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/BulkExportJobParametersValidatorTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/BulkExportJobParametersValidatorTest.java @@ -2,8 +2,6 @@ package ca.uhn.fhir.batch2.jobs.export; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; -import ca.uhn.fhir.jpa.api.model.BulkExportJobInfo; -import ca.uhn.fhir.jpa.bulk.export.api.IBulkExportProcessor; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import org.junit.jupiter.api.Test; @@ -12,7 +10,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -21,7 +18,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; diff --git a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistry.java b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistry.java index d6d63e32e8a..319de09c924 100644 --- a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistry.java +++ b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistry.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.batch.log.Logs; import ca.uhn.fhir.model.api.IModelJson; -import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import com.google.common.collect.ImmutableSortedMap; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; diff --git a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobCoordinatorImplTest.java b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobCoordinatorImplTest.java index d83dcde9e6d..79da318bcb2 100644 --- a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobCoordinatorImplTest.java +++ b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobCoordinatorImplTest.java @@ -22,7 +22,6 @@ import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse; import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver; import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannel; import ca.uhn.fhir.model.api.IModelJson; -import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import com.google.common.collect.Lists; import org.junit.jupiter.api.AfterEach; @@ -44,7 +43,6 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; diff --git a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistryTest.java b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistryTest.java index 3582eb07e89..b08f81bea50 100644 --- a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistryTest.java +++ b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/coordinator/JobDefinitionRegistryTest.java @@ -5,7 +5,6 @@ import ca.uhn.fhir.batch2.api.JobExecutionFailedException; import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.model.JobDefinition; import ca.uhn.fhir.context.ConfigurationException; -import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java index d82d55cdd76..bc60a0e04cc 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java @@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; import ca.uhn.fhir.rest.api.SearchTotalModeEnum; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.HapiExtensions; import ca.uhn.fhir.validation.FhirValidator; import com.google.common.annotations.VisibleForTesting; @@ -54,10 +55,6 @@ public class DaoConfig { * Default value for {@link #setReuseCachedSearchResultsForMillis(Long)}: 60000ms (one minute) */ public static final Long DEFAULT_REUSE_CACHED_SEARCH_RESULTS_FOR_MILLIS = DateUtils.MILLIS_PER_MINUTE; - /** - * See {@link #setStatusBasedReindexingDisabled(boolean)} - */ - public static final String DISABLE_STATUS_BASED_REINDEX = "disable_status_based_reindex"; /** * Default value for {@link #myTranslationCachesExpireAfterWriteInMinutes}: 60 minutes * @@ -354,7 +351,7 @@ public class DaoConfig { setEnableTaskPreExpandValueSets(DEFAULT_ENABLE_TASKS); setEnableTaskResourceReindexing(DEFAULT_ENABLE_TASKS); - if ("true".equalsIgnoreCase(System.getProperty(DISABLE_STATUS_BASED_REINDEX))) { + if (HapiSystemProperties.isDisableStatusBasedReindex()) { ourLog.info("Status based reindexing is DISABLED"); setStatusBasedReindexingDisabled(true); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java index 7ad5800294d..5383961692c 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java @@ -11,9 +11,9 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.codesystems.ConceptSubsumptionOutcome; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Nonnull; -import org.springframework.transaction.annotation.Transactional; import java.util.List; /* diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java index 6aece8a0adc..ffa2c7f8df5 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java @@ -20,13 +20,13 @@ package ca.uhn.fhir.jpa.dao.index; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; @@ -36,14 +36,14 @@ import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; import ca.uhn.fhir.jpa.model.cross.IResourceLookup; import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver; import ca.uhn.fhir.jpa.searchparam.extractor.PathAndRef; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; -import ca.uhn.fhir.util.CanonicalIdentifier; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; +import ca.uhn.fhir.util.CanonicalIdentifier; import ca.uhn.fhir.util.HapiExtensions; import ca.uhn.fhir.util.TerserUtil; import org.apache.http.NameValuePair; diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java index c6669a32cd9..0d730633379 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java @@ -23,11 +23,10 @@ package ca.uhn.fhir.jpa.util; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.model.TranslationQuery; import ca.uhn.fhir.jpa.model.entity.TagTypeEnum; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.time.DateUtils; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -36,7 +35,6 @@ import javax.annotation.Nonnull; import javax.annotation.PostConstruct; import java.util.EnumMap; import java.util.Map; -import java.util.concurrent.TimeUnit; import java.util.function.Function; import static java.util.concurrent.TimeUnit.MINUTES; diff --git a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2_1Test.java b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2_1Test.java index 6ac4f079a49..bfb5272c179 100644 --- a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2_1Test.java +++ b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2_1Test.java @@ -17,12 +17,12 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException; -import ca.uhn.fhir.rest.client.impl.BaseClient; import ca.uhn.fhir.rest.client.interceptor.CookieInterceptor; import ca.uhn.fhir.rest.client.interceptor.UserInfoInterceptor; import ca.uhn.fhir.rest.param.ParamPrefixEnum; import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; import ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.VersionUtil; @@ -96,7 +96,7 @@ public class GenericClientDstu2_1Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myAnswerCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String expectedUserAgent() { diff --git a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu2_1Test.java b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu2_1Test.java index d88582b7086..6e3b08b671d 100644 --- a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu2_1Test.java +++ b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu2_1Test.java @@ -12,7 +12,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.client.api.IRestfulClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.ReaderInputStream; @@ -58,7 +58,7 @@ public class NonGenericClientDstu2_1Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2Test.java index dfbea0c0fc8..159424fbb0e 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu2Test.java @@ -43,10 +43,10 @@ import ca.uhn.fhir.rest.client.api.IHttpClient; import ca.uhn.fhir.rest.client.api.IRestfulClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException; -import ca.uhn.fhir.rest.client.impl.BaseClient; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.ReaderInputStream; @@ -119,7 +119,7 @@ public class GenericClientDstu2Test { myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myResponseCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String extractBody(ArgumentCaptor capt, int count) throws IOException { diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/MessageClientDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/MessageClientDstu2Test.java index bdd5ffa8d44..518e1303b0f 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/MessageClientDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/MessageClientDstu2Test.java @@ -12,7 +12,7 @@ import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.input.ReaderInputStream; import org.apache.http.HttpResponse; @@ -67,7 +67,7 @@ public class MessageClientDstu2Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } @Test diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java index 67b996c1492..bfcbfaedbaf 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java @@ -1,16 +1,16 @@ package org.hl7.fhir.dstu3.hapi.ctx; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.util.CoverageIgnore; -import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.time.DateUtils; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import ca.uhn.fhir.system.HapiSystemProperties; +import ca.uhn.fhir.util.CoverageIgnore; +import org.apache.commons.lang3.Validate; import org.hl7.fhir.dstu3.context.IWorkerContext; import org.hl7.fhir.dstu3.formats.IParser; import org.hl7.fhir.dstu3.formats.ParserType; @@ -59,12 +59,8 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext myCtx = theCtx; myValidationSupport = theValidationSupport; - long timeoutMillis = 10 * DateUtils.MILLIS_PER_SECOND; - if (System.getProperties().containsKey(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)) { - timeoutMillis = Long.parseLong(System.getProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)); - } + long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); myFetchedResourceCache = CacheFactory.build(timeoutMillis); - // Set a default locale setValidationMessageLanguage(getLocale()); } diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu3Test.java index 44d71841270..eec314b69e2 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/GenericClientDstu3Test.java @@ -16,12 +16,12 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException; -import ca.uhn.fhir.rest.client.impl.BaseClient; import ca.uhn.fhir.rest.client.interceptor.CookieInterceptor; import ca.uhn.fhir.rest.client.interceptor.UserInfoInterceptor; import ca.uhn.fhir.rest.param.ParamPrefixEnum; import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; import ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.VersionUtil; @@ -96,7 +96,7 @@ public class GenericClientDstu3Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myAnswerCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String expectedUserAgent() { diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu3Test.java index beed3cb442f..6aadda7c8a2 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientDstu3Test.java @@ -12,7 +12,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.client.api.IRestfulClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.ReaderInputStream; @@ -58,7 +58,7 @@ public class NonGenericClientDstu3Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/server/MetadataCapabilityStatementDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/server/MetadataCapabilityStatementDstu3Test.java index fc78bb93794..62f7c77ac8a 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/server/MetadataCapabilityStatementDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/server/MetadataCapabilityStatementDstu3Test.java @@ -9,6 +9,7 @@ import ca.uhn.fhir.rest.annotation.Validate; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.param.StringParam; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.JettyUtil; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.VersionUtil; @@ -51,7 +52,7 @@ public class MetadataCapabilityStatementDstu3Test { private static RestfulServer ourServlet; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @AfterEach diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationDuplicateServerHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationDuplicateServerHl7OrgDstu2Test.java index 7aabf4fc2fa..757476dbc16 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationDuplicateServerHl7OrgDstu2Test.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationDuplicateServerHl7OrgDstu2Test.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; import ca.uhn.fhir.rest.api.EncodingEnum; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.JettyUtil; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; @@ -37,7 +38,7 @@ public class OperationDuplicateServerHl7OrgDstu2Test { private static Server ourServer; static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } @Test diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderHl7OrgDstu2Test.java index 0d94828bfb9..a2b44b07ae7 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderHl7OrgDstu2Test.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderHl7OrgDstu2Test.java @@ -3,7 +3,20 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.annotation.Description; -import ca.uhn.fhir.rest.annotation.*; +import ca.uhn.fhir.rest.annotation.ConditionalUrlParam; +import ca.uhn.fhir.rest.annotation.Create; +import ca.uhn.fhir.rest.annotation.Delete; +import ca.uhn.fhir.rest.annotation.History; +import ca.uhn.fhir.rest.annotation.IdParam; +import ca.uhn.fhir.rest.annotation.IncludeParam; +import ca.uhn.fhir.rest.annotation.Operation; +import ca.uhn.fhir.rest.annotation.OperationParam; +import ca.uhn.fhir.rest.annotation.OptionalParam; +import ca.uhn.fhir.rest.annotation.Read; +import ca.uhn.fhir.rest.annotation.RequiredParam; +import ca.uhn.fhir.rest.annotation.ResourceParam; +import ca.uhn.fhir.rest.annotation.Search; +import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.RequestDetails; @@ -15,6 +28,7 @@ import ca.uhn.fhir.rest.server.method.BaseMethodBinding; import ca.uhn.fhir.rest.server.method.SearchMethodBinding; import ca.uhn.fhir.rest.server.method.SearchParameter; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import ca.uhn.fhir.system.HapiSystemProperties; import org.hl7.fhir.dstu2.hapi.rest.server.ServerConformanceProvider; import org.hl7.fhir.dstu2.model.Conformance; import org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus; @@ -49,7 +63,7 @@ import static org.mockito.Mockito.when; public class ServerConformanceProviderHl7OrgDstu2Test { static { - System.setProperty("test", "true"); + HapiSystemProperties.enableTestMode(); } private static FhirContext ourCtx = FhirContext.forDstu2Hl7Org(); diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java index d3e63d17e7a..1fbdd91ed73 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java @@ -1,17 +1,17 @@ package org.hl7.fhir.r4.hapi.ctx; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.util.CoverageIgnore; -import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.time.DateUtils; -import org.fhir.ucum.UcumService; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import ca.uhn.fhir.system.HapiSystemProperties; +import ca.uhn.fhir.util.CoverageIgnore; +import org.apache.commons.lang3.Validate; +import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.r4.context.IWorkerContext; @@ -44,7 +44,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.concurrent.TimeUnit; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -61,10 +60,7 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext myCtx = theCtx; myValidationSupport = theValidationSupport; - long timeoutMillis = 10 * DateUtils.MILLIS_PER_SECOND; - if (System.getProperties().containsKey(ca.uhn.fhir.rest.api.Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)) { - timeoutMillis = Long.parseLong(System.getProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)); - } + long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); myFetchedResourceCache = CacheFactory.build(timeoutMillis); diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/BaseGenericClientR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/BaseGenericClientR4Test.java index cf0e1e344af..725728ea232 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/BaseGenericClientR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/BaseGenericClientR4Test.java @@ -4,7 +4,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.VersionUtil; import org.apache.commons.io.IOUtils; @@ -50,7 +50,7 @@ public abstract class BaseGenericClientR4Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myAnswerCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String expectedUserAgent() { diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientR4Test.java index 035b09841b5..cf8eb15114b 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/NonGenericClientR4Test.java @@ -12,7 +12,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.client.api.IRestfulClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.ReaderInputStream; @@ -58,7 +58,7 @@ public class NonGenericClientR4Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/ThreadLocalCapturingInterceptorR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/ThreadLocalCapturingInterceptorR4Test.java index df129486b83..1601aa5f0e3 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/ThreadLocalCapturingInterceptorR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/ThreadLocalCapturingInterceptorR4Test.java @@ -6,9 +6,9 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; import ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.VersionUtil; import org.apache.commons.io.IOUtils; @@ -54,7 +54,7 @@ public class ThreadLocalCapturingInterceptorR4Test { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myAnswerCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } private String expectedUserAgent() { diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/BlockingContentR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/BlockingContentR4Test.java index c2ae5297345..020c1b4039e 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/BlockingContentR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/BlockingContentR4Test.java @@ -1,9 +1,7 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor; -import ca.uhn.fhir.interceptor.api.IPointcut; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.rest.annotation.Transaction; import ca.uhn.fhir.rest.annotation.TransactionParam; @@ -11,7 +9,6 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.test.utilities.server.ResourceProviderExtension; import ca.uhn.fhir.test.utilities.server.RestfulServerExtension; import com.google.common.base.Charsets; -import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -31,7 +28,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.concurrent.TimeUnit; diff --git a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/FhirR4B.java b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/FhirR4B.java index 0f4624fd57b..999c0a7b3bc 100644 --- a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/FhirR4B.java +++ b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/FhirR4B.java @@ -20,12 +20,12 @@ package org.hl7.fhir.r4b.hapi.ctx; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.fhirpath.IFhirPath; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.model.api.IFhirVersion; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory; diff --git a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/HapiWorkerContext.java index c0214dcb990..61be6cbaf83 100644 --- a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/ctx/HapiWorkerContext.java @@ -9,9 +9,9 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.CoverageIgnore; import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.time.DateUtils; import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; @@ -65,10 +65,7 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext myCtx = theCtx; myValidationSupport = theValidationSupport; - long timeoutMillis = 10 * DateUtils.MILLIS_PER_SECOND; - if (System.getProperties().containsKey(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)) { - timeoutMillis = Long.parseLong(System.getProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)); - } + long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); myFetchedResourceCache = CacheFactory.build(timeoutMillis); diff --git a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java index a622f618af5..53bd7095ff2 100644 --- a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java +++ b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java @@ -1,10 +1,10 @@ package org.hl7.fhir.r4b.hapi.fhirpath; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.fhirpath.FhirPathExecutionException; import ca.uhn.fhir.fhirpath.IFhirPath; +import ca.uhn.fhir.i18n.Msg; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.r4b.hapi.ctx.HapiWorkerContext; diff --git a/hapi-fhir-structures-r4b/src/test/java/ca/uhn/fhir/rest/client/GenericClientR4BTest.java b/hapi-fhir-structures-r4b/src/test/java/ca/uhn/fhir/rest/client/GenericClientR4BTest.java index aac112a2ed8..b1398208433 100644 --- a/hapi-fhir-structures-r4b/src/test/java/ca/uhn/fhir/rest/client/GenericClientR4BTest.java +++ b/hapi-fhir-structures-r4b/src/test/java/ca/uhn/fhir/rest/client/GenericClientR4BTest.java @@ -7,7 +7,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -import ca.uhn.fhir.rest.client.impl.BaseClient; +import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.input.ReaderInputStream; import org.apache.http.Header; @@ -53,7 +53,7 @@ public class GenericClientR4BTest { ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs()); myAnswerCount = 0; - System.setProperty(BaseClient.HAPI_CLIENT_KEEPRESPONSES, "true"); + HapiSystemProperties.enableHapiClientKeepResponses(); } @Test diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java index c05f5e8941e..550495e8519 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java @@ -6,12 +6,12 @@ import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.util.CoverageIgnore; -import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.time.DateUtils; -import org.fhir.ucum.UcumService; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import ca.uhn.fhir.system.HapiSystemProperties; +import ca.uhn.fhir.util.CoverageIgnore; +import org.apache.commons.lang3.Validate; +import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.r5.context.IWorkerContext; @@ -49,7 +49,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -66,10 +65,7 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext myCtx = theCtx; myValidationSupport = theValidationSupport; - long timeoutMillis = 10 * DateUtils.MILLIS_PER_SECOND; - if (System.getProperties().containsKey(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)) { - timeoutMillis = Long.parseLong(System.getProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)); - } + long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); myFetchedResourceCache = CacheFactory.build(timeoutMillis); diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/system/HapiTestSystemProperties.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/system/HapiTestSystemProperties.java new file mode 100644 index 00000000000..afbc174c4f8 --- /dev/null +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/system/HapiTestSystemProperties.java @@ -0,0 +1,54 @@ +package ca.uhn.fhir.system; + +public final class HapiTestSystemProperties { + private static final String MASS_INGESTION_MODE = "mass_ingestion_mode"; + private static final String SINGLE_DB_CONNECTION = "single_db_connection"; + private static final String UNLIMITED_DB_CONNECTION = "unlimited_db_connection"; + + private HapiTestSystemProperties() {} + + /** + * Set the database connection pool size to 100 + */ + public static void enableUnlimitedDbConnections() { + System.setProperty(UNLIMITED_DB_CONNECTION, "true"); + } + + public static boolean isUnlimitedDbConnectionsEnabled() { + return "true".equals(System.getProperty(UNLIMITED_DB_CONNECTION)); + } + + public static void disableUnlimitedDbConnections() { + System.clearProperty(UNLIMITED_DB_CONNECTION); + } + + /** + * Creates a DaoConfig with setMassIngestionMode(true) at test app context startup time + */ + public static void enableMassIngestionMode() { + System.setProperty(MASS_INGESTION_MODE, "true"); + } + + public static boolean isMassIngestionModeEnabled() { + return "true".equals(System.getProperty(MASS_INGESTION_MODE)); + } + + public static void disableMassIngestionMode() { + System.clearProperty(MASS_INGESTION_MODE); + } + + /** + * Set the database connection pool size to 1 + */ + public static boolean isSingleDbConnectionEnabled() { + return "true".equals(System.getProperty(SINGLE_DB_CONNECTION)); + } + + public static void enableSingleDbConnection() { + System.setProperty(SINGLE_DB_CONNECTION, "true"); + } + + public static void disableSingleDbConnection() { + System.clearProperty(SINGLE_DB_CONNECTION); + } +} diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java index 9b6a5a1696b..5a1e8778e6b 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java @@ -6,10 +6,10 @@ import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; -import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.apache.commons.lang3.time.DateUtils; import ca.uhn.fhir.sl.cache.Cache; import ca.uhn.fhir.sl.cache.CacheFactory; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; +import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.slf4j.Logger; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java index c02d7740311..8afb0065b4f 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java @@ -6,17 +6,15 @@ import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; +import ca.uhn.fhir.sl.cache.CacheFactory; +import ca.uhn.fhir.sl.cache.LoadingCache; +import ca.uhn.fhir.system.HapiSystemProperties; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.time.DateUtils; import org.fhir.ucum.UcumService; -import ca.uhn.fhir.sl.cache.Cache; -import ca.uhn.fhir.sl.cache.CacheFactory; -import ca.uhn.fhir.sl.cache.LoadingCache; import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; import org.hl7.fhir.exceptions.FHIRException; @@ -52,7 +50,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -71,10 +68,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo myValidationSupportContext = theValidationSupportContext; myModelConverter = theModelConverter; - long timeoutMillis = 10 * DateUtils.MILLIS_PER_SECOND; - if (System.getProperties().containsKey(ca.uhn.fhir.rest.api.Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)) { - timeoutMillis = Long.parseLong(System.getProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS)); - } + long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); myFetchResourceCache = CacheFactory.build(timeoutMillis, 10000, key -> {