
Package ca.uhn.fhir.util
Class TestUtil
java.lang.Object
ca.uhn.fhir.util.TestUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidSet 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 environmentstatic voidTHIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic voidsetShouldRandomizeTimezones(boolean theShouldRandomizeTimezones) static voidsleepAtLeast(long theMillis) In production code, instead of this static method, it is better to use an instance of SleepUtil.static voidsleepAtLeast(long theMillis, boolean theLogProgress) In production code, instead of this static method, it is better to use an instance of SleepUtil.static StringstripReturns(String theString) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic StringstripWhitespace(String theString) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic voidwaitForSize(int theTarget, AtomicInteger theInteger) THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODEstatic voidwaitForSize(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
-