Package ca.uhn.fhir.util
Class TestUtil
java.lang.Object
ca.uhn.fhir.util.TestUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Set some system properties randomly after each test..static void
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic void
setShouldRandomizeTimezones
(boolean theShouldRandomizeTimezones) static void
sleepAtLeast
(long theMillis) In production code, instead of this static method, it is better to use an instance of SleepUtil.static void
sleepAtLeast
(long theMillis, boolean theLogProgress) In production code, instead of this static method, it is better to use an instance of SleepUtil.static String
stripReturns
(String theString) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic String
stripWhitespace
(String theString) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic void
waitForSize
(int theTarget, AtomicInteger theInteger) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic void
waitForSize
(int theTarget, Callable<Integer> theSource) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODE
-
Constructor Details
-
TestUtil
public TestUtil()
-
-
Method Details
-
setShouldRandomizeTimezones
-
randomizeLocaleAndTimezone
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEWhen we run the unit tests in cobertura, JUnit doesn't seem to clean up static fields which leads to tons of memory being used by the end and the JVM crashes in Travis. Manually clearing all of the static fields seems to solve this.
-
doRandomizeLocaleAndTimezone
Set some system properties randomly after each test.. this is kind of hackish, but it helps us make sure we don't have any tests that depend on a particular environment -
waitForSize
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEWait for an atomicinteger to hit a given site and fail if it never does
-
waitForSize
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEWait for an atomicinteger to hit a given site and fail if it never does
- Throws:
Exception
-
stripReturns
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEStrip \r chars from a string to account for line ending platform differences
-
stripWhitespace
THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEStrip \r chars from a string to account for line ending platform differences
-
sleepAtLeast
In production code, instead of this static method, it is better to use an instance of SleepUtil. Since SleepUtil isn't using static methods, it is easier to mock for unit test and avoid unnecessary waits in unit tests -
sleepAtLeast
In production code, instead of this static method, it is better to use an instance of SleepUtil. Since SleepUtil isn't using static methods, it is easier to mock for unit test and avoid unnecessary waits in unit tests
-