system property cleanup; added missing tests; (#4342)
This commit is contained in:
parent
017cc4e29c
commit
c6733b1111
|
@ -132,6 +132,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.org.webcompere</groupId>
|
||||
<artifactId>system-stubs-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -23,18 +23,18 @@ 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";
|
||||
static final String SUPPRESS_HAPI_FHIR_VERSION_LOG = "suppress_hapi_fhir_version_log";
|
||||
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;
|
||||
static final String TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS = "TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS";
|
||||
static final String UNIT_TEST_CAPTURE_STACK = "unit_test_capture_stack";
|
||||
static final String STACKFILTER_PATTERN_PROP = "log.stackfilter.pattern";
|
||||
static final String HAPI_CLIENT_KEEPRESPONSES = "hapi.client.keepresponses";
|
||||
static final String TEST_MODE = "test";
|
||||
static final String UNIT_TEST_MODE = "unit_test_mode";
|
||||
static final long DEFAULT_TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS = 10 * DateUtils.MILLIS_PER_SECOND;
|
||||
|
||||
private HapiSystemProperties() {
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public final class HapiSystemProperties {
|
|||
* way in your own code, just use client interceptors
|
||||
*/
|
||||
public static void enableHapiClientKeepResponses() {
|
||||
System.setProperty(HAPI_CLIENT_KEEPRESPONSES, "true");
|
||||
System.setProperty(HAPI_CLIENT_KEEPRESPONSES, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
public static void disableHapiClientKeepResponses() {
|
||||
|
@ -58,7 +58,7 @@ public final class HapiSystemProperties {
|
|||
* way in your own code, just use client interceptors
|
||||
*/
|
||||
public static boolean isHapiClientKeepResponsesEnabled() {
|
||||
return ("true".equals(System.getProperty(HAPI_CLIENT_KEEPRESPONSES)));
|
||||
return (Boolean.parseBoolean(System.getProperty(HAPI_CLIENT_KEEPRESPONSES)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,29 +97,29 @@ public final class HapiSystemProperties {
|
|||
* When this property is primarily used to control application shutdown behavior
|
||||
*/
|
||||
public static void enableTestMode() {
|
||||
System.setProperty(TEST_MODE, "true");
|
||||
System.setProperty(TEST_MODE, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
public static boolean isTestModeEnabled() {
|
||||
return "true".equals(System.getProperty(TEST_MODE));
|
||||
return Boolean.parseBoolean(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");
|
||||
System.setProperty(UNIT_TEST_MODE, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
public static boolean isUnitTestModeEnabled() {
|
||||
return "true".equals(System.getProperty(UNIT_TEST_MODE));
|
||||
return Boolean.parseBoolean(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");
|
||||
System.setProperty(UNIT_TEST_CAPTURE_STACK, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
public static void disableUnitTestCaptureStack() {
|
||||
|
@ -127,15 +127,15 @@ public final class HapiSystemProperties {
|
|||
}
|
||||
|
||||
public static boolean isUnitTestCaptureStackEnabled() {
|
||||
return "true".equals(System.getProperty(HapiSystemProperties.UNIT_TEST_CAPTURE_STACK));
|
||||
return Boolean.parseBoolean(System.getProperty(HapiSystemProperties.UNIT_TEST_CAPTURE_STACK));
|
||||
}
|
||||
|
||||
public static boolean isDisableStatusBasedReindex() {
|
||||
return "true".equals(System.getProperty(DISABLE_STATUS_BASED_REINDEX));
|
||||
return Boolean.parseBoolean(System.getProperty(DISABLE_STATUS_BASED_REINDEX));
|
||||
}
|
||||
|
||||
public static void disableStatusBasedReindex() {
|
||||
System.setProperty(DISABLE_STATUS_BASED_REINDEX, "true");
|
||||
System.setProperty(DISABLE_STATUS_BASED_REINDEX, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,11 +150,11 @@ public final class HapiSystemProperties {
|
|||
*/
|
||||
// TODO KHS use this in cdr
|
||||
public static void enableSuppressHapiFhirVersionLog() {
|
||||
System.setProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG, "true");
|
||||
System.setProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
public static boolean isSuppressHapiFhirVersionLogEnabled() {
|
||||
return "true".equals(System.getProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG));
|
||||
return Boolean.parseBoolean(System.getProperty(SUPPRESS_HAPI_FHIR_VERSION_LOG));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package ca.uhn.fhir.system;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
|
||||
import uk.org.webcompere.systemstubs.properties.SystemProperties;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ExtendWith(SystemStubsExtension.class)
|
||||
class HapiSystemPropertiesTest {
|
||||
|
||||
@SystemStub
|
||||
private SystemProperties mySystemProperties;
|
||||
|
||||
@Test
|
||||
void isHapiClientKeepResponsesEnabled() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.HAPI_CLIENT_KEEPRESPONSES, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isHapiClientKeepResponsesEnabled();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isTestModeEnabled() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.TEST_MODE, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isTestModeEnabled();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isUnitTestModeEnabled() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.UNIT_TEST_MODE, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isUnitTestModeEnabled();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isUnitTestCaptureStackEnabled() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.UNIT_TEST_CAPTURE_STACK, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isUnitTestCaptureStackEnabled();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isDisableStatusBasedReindex() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.DISABLE_STATUS_BASED_REINDEX, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isDisableStatusBasedReindex();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSuppressHapiFhirVersionLogEnabled() {
|
||||
// setup
|
||||
mySystemProperties.set(HapiSystemProperties.SUPPRESS_HAPI_FHIR_VERSION_LOG, Boolean.TRUE);
|
||||
// execute
|
||||
final boolean actual = HapiSystemProperties.isSuppressHapiFhirVersionLogEnabled();
|
||||
// validate
|
||||
assertTrue(actual);
|
||||
}
|
||||
}
|
5
pom.xml
5
pom.xml
|
@ -2085,6 +2085,11 @@
|
|||
<artifactId>flyway-core</artifactId>
|
||||
<version>${flyway_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.org.webcompere</groupId>
|
||||
<artifactId>system-stubs-jupiter</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
Loading…
Reference in New Issue