Package com.itextpdf.test
Class AssertUtil
java.lang.Object
com.itextpdf.test.AssertUtil
Utilities class for assertion operation.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertPassedWithinRandomTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout, Duration maxSleepTime) Assert that the assertion passed within the random timeout.static voidassertPassedWithinTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout) Assert that the assertion passed within the timeoutstatic voidassertPassedWithinTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout, Duration sleepTime) Assert that the assertion passed within the timeoutstatic voiddoesNotThrow(Executor executor) Asserts thatExecutor.execute()method call doesn't produce anyExceptionotherwise test will fail by throwingAssertionError.static voiddoesNotThrow(Executor executor, String message) Asserts thatExecutor.execute()method call doesn't produce anyExceptionotherwise test will fail by throwingAssertionError.
-
Method Details
-
doesNotThrow
Asserts thatExecutor.execute()method call doesn't produce anyExceptionotherwise test will fail by throwingAssertionError.- Parameters:
-
executor- the instance ofExecutorwhoseExecutor.execute()method will be checked for exception throwing
-
doesNotThrow
Asserts thatExecutor.execute()method call doesn't produce anyExceptionotherwise test will fail by throwingAssertionError.- Parameters:
-
executor- the instance ofExecutorwhoseExecutor.execute()method will be checked for exception throwing -
message- the identifying message for theAssertionErrormay be null
-
assertPassedWithinTimeout
public static void assertPassedWithinTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout) throws Exception Assert that the assertion passed within the timeout- Parameters:
-
assertion- callback to the actual asserts to be safeguarded -
timeout- the maximum time it can take before passing the assertions - Throws:
-
Exception- any exception thrown by the assertion callback
-
assertPassedWithinTimeout
public static void assertPassedWithinTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout, Duration sleepTime) throws Exception Assert that the assertion passed within the timeout- Parameters:
-
assertion- callback to the actual asserts to be safeguarded -
timeout- the maximum time it can take before passing the assertions -
sleepTime- the time to sleep between polls - Throws:
-
Exception- any exception thrown by the assertion callback
-
assertPassedWithinRandomTimeout
public static void assertPassedWithinRandomTimeout(AssertUtil.ThrowingRunnable assertion, Duration timeout, Duration maxSleepTime) throws Exception Assert that the assertion passed within the random timeout.This method may be useful when your tests fetch some stateful resources concurrently. It allows to de-synchronize access from different clients. It's exponential backoff with jitter but without 'exponential' part. Because it does not really care if tests become longer, the main goal is to pass the tests.
- Parameters:
-
assertion- callback to the actual asserts to be safeguarded -
timeout- the maximum time it can take before passing the assertions -
maxSleepTime- the maximum time to sleep between polls - Throws:
-
Exception- any exception thrown by the assertion callback
-